Some times you may come across below error.
touch: cannot touch `abc.txt’: No space left on device // using touch.
This will be bit annoying when you come to know there is a space left in your desk. The culprit in this case is total number of used inodes. If all your inodes are used away you can not create a file/folder though you have plenty of free space left in your machine. Ok, how can I conform how many inodes I used in my machine? We can use df command to get those details.
root@linuxnix:/home# df -i Filesystem Inodes IUsed IFree IUse% Mounted on udev 990478 556 989922 1% /dev tmpfs 993174 622 992552 1% /run /dev/sdb1 1466368 698247 768121 48% / none 993174 11 993163 1% /sys/fs/cgroup none 993174 3 993171 1% /run/lock none 993174 272 992902 1% /run/shm none 993174 32 993142 1% /run/user /dev/sda1 0 0 0 - /boot/efi /dev/sda4 53968896 11752 53957144 1% /opt /dev/sda2 6111232 46648 6064584 1% /home /dev/mmcblk0p1 0 0 0 - /media/surendra/9016-4EF8
From the above output Second column represents total number of available inodes and third column shows how many inodes you used.
To get total inodes in your machine use below command.
root@linuxnix:/home# df -i --total Filesystem Inodes IUsed IFree IUse% Mounted on udev 990478 556 989922 1% /dev tmpfs 993174 622 992552 1% /run /dev/sdb1 1466368 698248 768120 48% / none 993174 11 993163 1% /sys/fs/cgroup none 993174 3 993171 1% /run/lock none 993174 272 992902 1% /run/shm none 993174 32 993142 1% /run/user /dev/sda1 0 0 0 - /boot/efi /dev/sda4 53968896 11752 53957144 1% /opt /dev/sda2 6111232 46648 6064584 1% /home /dev/mmcblk0p1 0 0 0 - /media/surendra/9016-4EF8 email@example.com:/root 1310720 124303 1186417 10% /mnt total 68813564 882447 67931117 2% -
If you see any thing like 100% inodes used in df -i output, then it’s time to dig more to see where are my maximum number of inodes located. In Linux/Unix we don’t have a direct command to check which folder have maximum number of inodes available. We have to use our scripting knowledge to get those details. By this time you should know each file(any file like regular file, directory, socket etc) will corresponds to one inode. This is the clue to find out where maximum files/inodes are located. Use below one liner script to check which folder under / have maximum number of inodes.
root@linuxnix:/home# for i in /*;do echo "Number of inodes in $i is $(find $i | wc -l)";done Number of inodes in /bin is 162 Number of inodes in /boot is 645 Number of inodes in cdrom is 1 Number of inodes in /dev is 580 Number of inodes in /etc is 3148 Number of inodes in /home is 46619 Number of inodes in /initrd.img is 1 Number of inodes in /initrd.img.old is 1 Number of inodes in /lib is 74086 Number of inodes in /lib32 is 44 Number of inodes in /lib64 is 4 Number of inodes in /lost+found is 1 Number of inodes in /media is 152 Number of inodes in /mnt is 1333 Number of inodes in /opt is 11743 Number of inodes in /proc is 312948 Number of inodes in /root is 997 Number of inodes in /run is 653 Number of inodes in /sbin is 192 Number of inodes in /srv is 1 Number of inodes in /sys is 36835 Number of inodes in /tmp is 32 Number of inodes in /usr is 573832 Number of inodes in /var is 45105 Number of inodes in /vmlinuz is 1 Number of inodes in /vmlinuz.old is 1
From the above list we can concentrate on /usr folder to dig more and check which folder with in /usr have maximum number of inodes.
root@linuxnix:/home# for i in /usr/*;do echo "Number of inodes in $i is $(find $i | wc -l)";done Number of inodes in /usr/bin is 2843 Number of inodes in /usr/games is 6 Number of inodes in /usr/include is 2907 Number of inodes in /usr/lib is 39360 Number of inodes in /usr/lib32 is 258 Number of inodes in /usr/local is 1550 Number of inodes in /usr/sbin is 240 Number of inodes in /usr/share is 154729 Number of inodes in /usr/src is 371938
In this way, you can go as deep as possible and try to remove unwanted files to free up some inodes. Keep visiting www.linuxnix.com for more Linux/Unix tips.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
Anisble: ERROR! unexpected parameter type in action:
Fix- June 29, 2020
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018