How many bytes per inodes?

oyo picture oyo · Sep 1, 2010 · Viewed 63.5k times · Source

I need to create a very high number of files which are not very large (like 4kb,8kb). It's not possible on my computer cause it takes all inodes up to 100% and I cannot create more files :

$ df -i /dev/sda5
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/sda5            54362112 36381206 17980906   67% /scratch

(I started deleting files, it's why it's now 67%)

The bytes-per-nodes are of 256 on my filesystem (ext4)

$ sudo tune2fs -l /dev/sda5 | grep Inode
Inode count:              54362112
Inodes per group:         8192
Inode blocks per group:   512
Inode size:               256

I wonder if it's possible to set this value very low even below 128(during reformating). If yes,what value should I use? Thx

Answer

Brendon Baumgartner picture Brendon Baumgartner · Mar 24, 2011

The default bytes per inode is usually 16384, which is the default inode_ratio in /etc/mke2fs.conf (it's read prior to filesystem creation). If you're running out of inodes, you might try for example:

mkfs.ext4 -i 8192 /dev/mapper/main-var2

Another option that affects this is -T, typically -T news which further reduces it to 4096.

Also, you can not change the number of inodes in a ext3 or ext4 filesystem without re-creating or hex-editing it. Reiser filesystems are dynamic so you'll never have an issue with them.