We help IT Professionals succeed at work.

bytes per inode question

ltsun asked
Dear experts,

   My question is about bytes-per-inode when formatting a partition. The followings are what I did:

#mke2fs -i 8192 /dev/hda3  
#mount /dev/hda3  /tmp/mydir
#cd /tmp/mydir
#mkdir  hello
#ls -al
drwxr-xr-x   2  root   root  4096  Oct 23  16:28 hello

I already indicated one inode points to 8192 (2 blocks) bytes. Since a directory uses one inode, I suppose the size of the directory should be 8192. But it seemes that I am wrong. Why the directory size is 4096?

Thanks in advance


Watch Question

An inode holds the meta-data for a file (ie. its type, size, owner, ...). The inode table on a e2 file system must be created at the same time as the file system itself, it can not grow or shrink afterwards. This means that once an e2fs is made the number of files (including directories, devs, etc) is fixed.

The 'i' switch to mke2fs sets the number of inodes on the file system to a ratio of the size of the filesystem. In your case one inode was created for every 8192 bytes of capacity on the /dev/hda3 partition.

Your 'ls' command shows you the size of the file not the inode. From your example you can see that the allocation unit on that fs is 4096 bytes. Directories always use whole allocation units.

You can use 'dumpe2fs' to get all kinds of info on an exsisting e2fs. Check the man page.

  there are currently two thoughts I have here:

  the inode size defines the maximum space that can be used within an inode. If the directory listing is smaller than the required space, it may not be needing all of the 8192 bytes initially. Once the directory index exceeds the required size, the structure gets expanded.

  and secondly, according to my quick browse through the sources,  I doubt somehow that you can allocate inodes of this size . The maximum (according to the sources in 2.2.19 kernel ) is 4096 bytes. Since mke2fs is not a kernel tool, it may have attempted to do more.

Both of which may account independantly. You may want to check the block size tune2fs -l /dev/hda3 too see if you actually got 8192 or 4096.


You can not change the size of an inode without modifying kernel source code. Inode size is fixed! The 'i' switch to the mke2fs command affects the _number_ of inodes, not their size.



   I got the idea. Thanks very much.


Explore More ContentExplore courses, solutions, and other research materials related to this topic.