18

About inodes

In Ubuntu, each file and directory is a so-called inode. You can use df -i to check the number of inodes in use and available for all mounted filesystems.

Question

If you create a new EXT4-partition, it uses the default number of inodes, which under normal conditions should be sufficient. However, if you run a system that produces millions of small files, how do you need to create a new EXT4 partition with an extra large number of inodes? What is the maximum?

Comments

  • You can NOT change the number of available inodes AFTER the EXT4-partition has been created
bzero
  • 512

3 Answers3

15

Using mkfs -t ext4 -N iNumberOfINodes /dev/XdY where iNumberOfINodes is a 32-bit number so the maximum possible number of inodes on any ext2/3/4 file system is 2^32-1, or 4,294,967,295 (~4 billion).

Fabby
  • 35,017
4

See the man page for mkfs.ext4.

man mkfs.ext4

Option -N allows you to set the number of inodes created in the filesystem, and option -I allows you to increase their size (so they can handle more extended attributes of files). Adjust to fit your situation when you create the filesystem.

ubfan1
  • 19,049
2

It's always a trade off between inodes and block size. 32-bit is the max, but the actual max depends on your disk/filesystem size divided by block size. Each file is at minimum one block. You can also specify the group size which determines how many blocks per inode. (i.e. bytes/inode)

All that will determine the number of inodes you can allocation for a particular disk size and block size.

It's also a trade off between performance versus file capacity. Smaller block size mean large files will be fragmented and require more I/O operations to load the file.

If you're gonna customize you need to read up or else you end up with a filesystem totally unsuitable for what you thought you wanted.