What is Inodes in Linux
What is Inodes in Linux
In this post we are going to discuss about what is inodes in linux. inode normally referred as Index Node. inode is layout structure in a unix based file system which describes a file system object like files and directories.Let us deep dive about what is inodes in linux.
Every inode contains attributes and disk block target location of the file or directory. Inode include 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 entry for itself, parent and its children.
You might have seen while creating any new file system in linux. inodes gets created at that time of new file system when using mkfs command and number of inodes depends upon file system size because inode size depends upon block size.
You also might have faced situation when inodes gets full even file system have enough free space.For example many times not always mail system like sendmail or postfix creates too many files and it fills up inodes of the file system and no more files gets created or updated and have good chance application to fail as it have no space to write any data.Normally mail system creates too many files in /var/spool/clientmqueue directory.
Logically it happens because if any inode consume one block of 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 have similar inode concepts.
This was few details about what is inodes in linux. Let us see how we can check inodes in linux and unix.
How to check inodes in linux
Procedure for how to check inodes in linux is as below.ls,df,stat command is really helpful in getting details of inodes in linux. Few examples has been dsplayed below which might be helpful to understand. [[email protected] ~]# stat passwd |grep Inode Device: 802h/2050d Inode: 1193625 Links: 1 [[email protected] ~]# ls -i passwd 1193625 passwd [[email protected] ~]# ls -ai passwd 1193625 passwd [[email protected] ~]# 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 [[email protected] ~]#$ 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: - [[email protected] ~]# df -i /var Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda5 525200 9159 516041 2% /var
How to check inodes in unix
Process for how to check inodes in unix is as below.
[[email protected] ~]# df -oi /var Filesystem iused ifree %iused Mounted on /dev/vx/dsk/bootdg/var 52637 943267 5% /var
So now we have fair idea how to check inodes in linux in file system in linux and unix. 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 messages file with message like no space left on device .
That,s it about what is inodes in linux .Please go through other similar kind of posts for making your understandings clear on various linux related articles.