Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many bytes per inodes?

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

like image 872
oyo Avatar asked Sep 01 '10 13:09

oyo


People also ask

How large is an inode?

The default inode size is 256 bytes for most file systems, Except for small file systems where the inode size will be 128 bytes.

How much space does an inode use?

Just as files are stored in units of a given size, inodes are also stored in blocks, making it possible for a file as large as 4 MB to single-handedly overrun an inode that is 32 bytes.

Does inode have a maximum capacity?

First up, and less important, the theoretical maximum number of inodes is equal to 2^32 (approximately 4.3 billion inodes). Second, and far more important, is the number of inodes on your system. Generally, the ratio of inodes is 1:16KB of system capacity.


2 Answers

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.

like image 176
Brendon Baumgartner Avatar answered Oct 06 '22 01:10

Brendon Baumgartner


You can find out the approximate inode ratio by dividing the size of available space by the number of available inodes. For example:

$ sudo tune2fs -l /dev/sda1 | awk -F: ' \     /^Block count:/ { blocks = $2 } \     /^Inode count:/ { inodes = $2 } \     /^Block size:/ { block_size = $2 } \     END { blocks_per_inode = blocks/inodes; \           print "blocks per inode:\t", blocks_per_inode, \                 "\nbytes per inode:\t", blocks_per_inode * block_size }'  blocks per inode:    3.99759  bytes per inode:     16374.1 
like image 30
Stanislav German-Evtushenko Avatar answered Oct 06 '22 01:10

Stanislav German-Evtushenko