To format a drive, using default options, in EXT4,
EXT4 also allows the number of inodes to be modified.
Each file requires its own inode and if you have lots of small files, you may run out of inodes before you run out of space. Alternatively, if you are only going to have a few large files, you can get more disk space by limiting the number of inodes.
To set the inode density, you can use the -i switch.
mkfs.ext4 -i 2048 /dev/xvdh
You can see how much disk space you are using with this command
and the number of iNodes you are using with this switch
As a comparison, taking a 200GB disk drive with different inode densities
|iNode Density||Disk Space Reported||Disk Spaces Used by iNodes||Number of iNodes||Percentage of Disk Used by INodes|
As you can see, with a high iNode density 25% of the disk is used up in preallocated spaces that you cannot use.
As a real world example, I have data being sent to a server that is processes. The data is small – less than 1KB per transaction. As well as processing the data, I also drop a copy into a file on a spare drive “just in case”.
- The drive is 200GB in size of which I am using 161GB (86%).
- The iNode density is 2048 Bytes/iNode, giving me 100M iNodes of which 35M are in use (35%)
- With the normal/default iNode density (16,384), I ran out of iNodes when the disk was only partially full.