How to find the inode size of an ext2/ext3/ext4 filesystem?

By using the tune2fs tool with the option, -l, the inode size of the filesystem could be seen. Using the same option, other information of the filesystem superblock can also be seen. The superblock contains information about the filesystem, such as the number of free blocks available, and the number of mounts, that may be useful for tuning purposes.

Here is an example how a user can specify the -l option. The example used here is of RHEL 7 system:

# tune2fs -l /dev/sda1 
tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:   [none]
Last mounted on:          /boot
Filesystem UUID:          1a678f4f-85e4-43c6-b4b3-af1a732510ac
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              65536
Block count:              262144
Reserved block count:     13107
Free blocks:              228732
Free inodes:              65200
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      127
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
RAID stride:              64
RAID stripe width:        64
Flex block group size:    16
Filesystem created:       Tue Jan 26 18:26:17 2016
Last mount time:          Sun Jun 26 00:03:14 2016
Last write time:          Sun Jun 26 00:03:14 2016
Mount count:              5
Maximum mount count:      -1
Last checked:             Tue Jan 26 18:26:17 2016
Check interval:           0 ([none])
Lifetime writes:          176 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:           256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      27bb8d92-09a4-4734-89b8-f767a5f34fb3
Journal backup:           inode blocks

To get the size of inode, use :

# tune2fs -l /dev/sda1 | grep -i inode
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Inode count:              65536
Free inodes:              65200
Inodes per group:         8192
Inode blocks per group:   512
First inode:              11
Inode size:           256
Journal inode:            8
Journal backup:           inode blocks

As shown above the inode size in RHEL 7 on ext4 system is 256 bytes.

You can also use the df -i command to get the total number of inodes available and how many of them are already utilized.

# df -i /dev/sda1
Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/sda1       65536  1919 63617    3% /boot

How to calculate number of inode on ext4/etx3 FS will have before creating it?

As it is written in the man pages the value is based number of blocks and the bytes-per-inode ratio bytes-per-inode = (blocks/inodes) * block_size.

   -N number-of-inodes
      Overrides the default calculation of the number of inodes that should be reserved for
      the filesystem (which is based on the number of blocks and the bytes per-inode ratio). 
      This allows the user to specify the number of desired inodes directly.

To check how many inodes you will have, use -n option with mkfs.ext3/4.

# mkfs.ext4 -n /dev/sda
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=512 blocks
32768 inodes, 131072 blocks
6553 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33685504
16 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
    8193, 24577, 40961, 57345, 73729
Related Post