How many bytes per inodes?

最后都变了- 提交于 2020-11-30 08:01:09

问题


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


回答1:


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.




回答2:


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



回答3:


I have found solution to my problem on the mke2fs man page :

-I inode-size

Specify the size of each inode in bytes. mke2fs creates 256-byte inodes by default. In kernels after 2.6.10 and some earlier vendor kernels it is possible to utilize inodes larger than 128 bytes to store extended attributes for improved performance. The inode-size value must be a power of 2 larger or equal to 128. The larger the inode-size the more space the inode table will consume, and this reduces the usable space in the filesystem and can also negatively impact performance. Extended attributes stored in large inodes are not visible with older kernels, and such filesystems will not be mountable with 2.4 kernels at all. It is not possible to change this value after the filesystem is created.

The maximun you will be able to set is given by your block-size.

sudo tune2fs -l /dev/sda5 | grep "Block size"
Block size:               4096

Hope this can help....



来源:https://stackoverflow.com/questions/3618820/how-many-bytes-per-inodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!