Running out of inodes
I render my onw maps, as raster tiles, 256x256px, one tile per file. I don't render the whole world, just the places I'm interested in, but also a continent size area
$ sudo tune2fs -l /dev/sdc1 Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Inode count: 45006848 Block count: 179998028 Block size: 4096
mdione@diablo:~/src/projects/trash & toys$ sudo fdisk -l /dev/sdc Disk /dev/sdc: 698,64 GiB, 750156374016 bytes, 1465149168 sectors Device Boot Start End Sectors Size Id Type /dev/sdc1 2048 1439986274 1439984227 686,6G 83 Linux
In [1]: 1_439_984_227 * 512 Out[1]: 737_271_924_224
In [2]: _ / 1024**3 Out[2]: 686.6379866600037
In [3]: 179_998_028 * 4096 Out[3]: 737_271_922_688
In [4]: _ - 737_271_924_224 Out[4]: -1536
In [5]: 737_271_924_224 / 45006848 Out[5]: 16_381.327664270113
In [6]: 737_271_922_688 / 45006848 Out[6]: 16_381.327630141974
In [7]: 2 ** 14 Out[7]: 16_384
-i bytes-per-inode Specify the bytes/inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. The larger the bytes-per-inode ratio, the fewer inodes will be created. This value generally shouldn't be smaller than the blocksize of the file system, since in that case more inodes would be made than can ever be used. Be warned that it is not possible to change this ratio on a file system after it is created, so be careful deciding the correct value for this parameter. Note that resizing a file system changes the number of inodes to maintain this ratio.
So I have 1 inode every ~16KiB of space. Now, what are the sizes of my files?
1: 2285616, 2: 3284254, 3: 3125042, 4: 2937723, 5: 3186604, 6: 2596295, 7: 2311155, 8: 2232527, 9: 2185779, 10: 2769548, 11: 2397949, 12: 2006941, 13: 1832166, 14: 1642621, 15: 1434795, 16: 1230054, 17: 1070510, 18: 918275, 19: 775390, 20: 655504, 21: 563967, 22: 487856, 23: 449752, 24: 379450, 25: 332403, 26: 279349, 27: 227499, 28: 192968, 29: 165603, 30: 138523, 31: 116543, 32: 106422, 33: 87873, 34: 70284, 35: 57836, 36: 48718, 37: 41863, 38: 35292, 39: 30450, 40: 26861, 41: 24038, 42: 21687, 43: 19817, 44: 18565, 45: 17384, 46: 16305, 47: 14833, 48: 13640, 49: 12473, 50: 11106, 51: 10320, 52: 9282, 53: 8463, 54: 7591, 55: 6470, 56: 5417, 57: 4026, 58: 2433, 59: 1195, 60: 426, 61: 128, 62: 26, 44_943_951: 9832.050836763328
The histogram does not help much, but the average gives a hint: for 44M files, the average size is ~9KiB. The stats are going to be a bit skewed because I recently started to generate tiles in medium quality WebP instead the usual lossless PNG, and I hadn't rerendered all tiles. I think we can see that in the data above, where there's a peak at 5KiB but between 9 and 10KiB we see a new hump. 9216 sounds like a goot number (9Ki), so letś do that:
$ sudo mkfs.ext4 -i 9216 -L trash /dev/sdc1 mke2fs 1.47.2 (1-Jan-2025) /dev/sdc1 contains a ext4 file system labelled 'data' last mounted on /home/mdione/public_html on Sun Aug 10 20:31:43 2025 Proceed anyway? (y,N) y Creating filesystem with 179998028 4k blocks and 80080544 inodes Filesystem UUID: 27f363c9-bea9-494a-8b49-1cb2ff582899 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000 Allocating group tables: done Writing inode tables: done Creating journal (262144 blocks): done Writing superblocks and filesystem accounting information: done
I like the fact that it warns you about an existing filesystem in the partition.