What is Inodes in Linux

inodes in linux

Wondering what is inodes in linux?. inode normally referred to as the Index Node. An inode is a layout structure in a UNIX-based file system that describes a file system object like files and directories.

Every inode contains attributes and disk block target location of the file or directory. Inode includes metadata of file system attributes like time of last change, time of last access, time of last modification, file ownership details, file permission details.

It can be treated as directories are lists of names assigned to inodes. Directory always contains an entry for itself, parent and its children.

You might have seen while creating any new file system in linux. inodes get created at that time of new file system creation when using mkfs command.

The number of inodes depends upon file system size because inode size depends upon block size. You also might have faced a situation when inodes get full even file system to have enough free space.

For example, mail systems like sendmail or postfix create too many files and it fills up inodes of the file system. No more files get created or updated and have a good chance application to fail as it has no space to write any data.

Normally mail system creates too many files in the /var/spool/clientmqueue directory. Logically it happens because if any inode consumes one block of the disk.

Normally 512 bytes block even inode size is anything below 512 bytes but it will not hold any other data.

Linux and Unix both use similar inode concepts. These were a few details about what is inode in linux. Let us see how we can check inode in linux and unix.

How to check inodes in linux

How to check inodes in linux is as below. ls,df,stat command is really helpful in 
getting details of inodes in linux. Few example has been displayed below which
might be helpful to understand.

[root@linsrv01 ~]#stat passwd |grep Inode
Device: 802h/2050d      Inode: 1193625     Links: 1
[root@linsrv01 ~]# ls -i passwd
1193625 passwd
[root@linsrv01 ~]# ls -ai passwd
1193625 passwd
[root@linsrv01 ~]# df -ih
Filesystem                    Inodes IUsed IFree IUse% Mounted on
/dev/sda2                    1.3M     149K  1.2M   12%  /
devtmpfs                     4.0M     455   4.0M    1%  /dev
tmpfs                          4.0M      1    4.0M    1%  /dev/shm
tmpfs                          4.0M      884   4.0M    1%  /run
tmpfs                          4.0M      16   4.0M    1%  /sys/fs/cgroup
/dev/sda1                    126K      349   125K    1%  /boot
/dev/sda3                    513K     13K   501K    3%  /var
/dev/sda5                    256K     106   256K    1%  /tmp
/dev/sda6                    256K     735   256K    1%  /var/log
/dev/sda7                    128K      16   128K    1%  /var/log/audit
[root@linsrv01 ~]# stat /var
File: â/varâSize: 4096            Blocks: 8          IO Block: 4096   directory
Device: 803h/2051d      Inode: 2           Links: 28
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-01-10 02:08:14.851047321 -0500
Modify: 2019-10-31 01:51:52.137319406 -0400
Change: 2019-10-31 01:51:52.137319406 -0400
Birth: -
[root@linsrv01 ~]#df -i /var
Filesystem  Inodes IUsed IFree  IUse% Mounted on
/dev/sda5   525200 9159  516041 2%   /var

How to check inodes in Solaris

The process for how to check inodes in solaris is as below.

[root@solsrv01 ~]# df -oi /var
Filesystem                    iused   ifree    %iused  Mounted on
/dev/vx/dsk/bootdg/var      52637 943267  5%      /var

So now we have a fair idea of how to check inodes in linux. This might be really helpful in case if you get inode full case.

If you see file system usage and if it is not filled it must be because of inodes are exhausted. You can validate this from the messages file with a message like no space left on the device.

That`s it about inodes in linux, and how to check inodes in linux, how to check inodes in solaris as a bonus. I hope you will like it and it must have given some clarity regarding the concept of the inode.

Read More other Linux Tutorials

1.How to install uuencode in linux

2.How to activate and deactivate VG in linux

3.How to create a file system in linux

4.Important Linux Commands

5.How to check Linux Version

6.How to change Linux Password

7.How to remove files and directory in Linux

8.How to check disk size in VxVM

9.How to check DG size in VxVM

10.How to remove file system in VxVM