Are there any drawbacks to creating ext4 file systems with 2^32-1 inodes?
I have a 1tb drive and I would like to store 800 million to 1.5 billion small files on it. It seems that the max is 4 billion, so I'm wondering whether I could just set it to the max when creating an fs, or I should find some other solution.
According to similar questions over on Stack Overflow and Unix & Linux (see below) it is a bad idea to max out the number of inodes on an ext4 filesystem.
Better use another filesystem or split your disk into multiple filesystems.
To summarize:
An inode occupies 256 bytes. It may be configured to 128, but even though:
When creating an ext4 filesystem, you can specify the usage type as defined in
/etc/mke2fs.conf
:For storing many small files the type
small
might be used:This means: for every 4096 bytes of diskspace (filesystem size) one inode will be reserved each of which has a size of 128 bytes. The command
mkfs.ext4 -T small /dev/something
would thus create 244 million inodes on a 1TB filesystem that occupy 31 GB. These 244 million files will at least occupy 250 GB (min. 1024 bytes each).To hold 1 billion inodes with the small footprint (128 bytes) you would need 128 GB just for the inodes. If the smallest possible blocksize (1024 according to mk2efs's manpage) is used, then these 1 billion files would at least occupy 1TB (but remember you only have 872 GB left because of the 128 GB for the inodes).
The smallest possible blocksize for ext4 is 1024 bytes. Hence, you cannot store more than 1 TB / 1024 = 1 billion files and it's pointless to have more inodes.
As a general rule of thumb the
inode_ratio
should not be smaller than theblocksize
because you cannot (easily) store more than one file in one block.It is possible to store the first 60 bytes of a file directly whithin the inode if the filesystem is configured that way. In that case, the file would not occupy a (regular) block; read about such inline data here but also consider the inode size.
From a comment to the U&L question:
References: