本文标题:linux下的inodes【本站如从外站转载,会注明出处】
本文链接:http://www.validba.net/2009/02/linux%e4%b8%8b%e7%9a%84inodes/
linux文件系统中包含了一个所谓inodes的概念。其实每个格式化的分区包括两部分:block区域和inode table. block中保存了存储在该分区中的文件或档案的内容;inode table中保存了这些文件或档案的属性,以及这些文件存储在乃个block中.所有的文件都会占用一个或多个inode.通常在搜索文件时,系统会先搜索inode table,然后从inode table中找出这些文件的地址,然后再去相应的block中读取实际的文件内容.
这个inode table在磁盘进行格式化的时候就已经分配好了.如果是ext2/3格式,可通过tune2fs-l /dev/hdan(n为1,2,3…)查看分区的详细信息,这些信息中包括了Block size和Inode size的大小。或者在格式化分区时指定一个是适当大小inode. mke2fs命令是linux下的格式化命令.通过-i参数可以定义每个inode的大小.
查看Inode size和Block size的大小:
[root@db2 ~]# tune2fs -l /dev/hda1|grep ‘Inode size’
Inode size: 128
[root@db2 ~]# tune2fs -l /dev/hlda1|grep ‘Block size’
Block size: 4096
Inode size: 128
[root@db2 ~]# tune2fs -l /dev/hlda1|grep ‘Block size’
Block size: 4096
如果在一个产品系统上,根据存储的文件的大小,要严格规划inode的大小.目前已经碰见很多案例,在分区容量足够的情况下,inode饱满的问题.一般情况下,inode应当小于block的大小.
看看mke2fs对-i参数的解释:
-i bytes-per-inode
Specify the bytes/inode ratio. mke2fs creates an inode for
every bytes-per-inode bytes of space on the disk. The larger
the bytes-per-inode ratio, the fewer inodes will be created.
This value generally shouldn’t be smaller than the blocksize of
the filesystem, since then too many inodes will be made. Be
warned that is not possible to expand the number of inodes on a
filesystem after it is created, so be careful deciding the cor-
rect value for this parameter.
Specify the bytes/inode ratio. mke2fs creates an inode for
every bytes-per-inode bytes of space on the disk. The larger
the bytes-per-inode ratio, the fewer inodes will be created.
This value generally shouldn’t be smaller than the blocksize of
the filesystem, since then too many inodes will be made. Be
warned that is not possible to expand the number of inodes on a
filesystem after it is created, so be careful deciding the cor-
rect value for this parameter.

CopyRight Validba'S Home 版权所有.本站为个人学习之用,评论时请遵守本国法律