# How to free Inode usage on Linux?

LinuxOperating SystemOpen Source

The inode (also known as index node) is a data structure that is used to describe the file system object and is usually stored at the file system directory.

We can check the size of the different inodes present on our local machine with the help of the following command −

df -

The above command is known as df command which is a Linux utility command that is used to get the details of the space available on the disk.

After running the above command, you can expect an output something like this −

immukul@192 ~ % df -i
Filesystem 512-blocks Used Available Capacity iused ifree
/dev/disk1s5s1 236568496 44429928 45432792 50% 559993 1182282487
devfs 377 377 0 100% 652 0
/dev/disk1s4 236568496 6293880 45432792 13% 4 1182842476

We can notice in the output that one drive, namely the devfs one is completely used and in that case we won’t be able to write anything new to it.

Now we want to free that inode usage so that we can use it later.

In order to do that we can either create a shell script that will enable us to do that or we can run the commands shown below −

First find the root folders with large inodes with the command shown below −

for d in /*; do echo $d; find$d |wc -l; done

The above command will take some time but it will print the root folders with large inodes, in case you already know the directory that has large inodes then you can replace the above command with the command shown below −

for d in /devfs; do echo $d; find$d |wc -l; done

Now you just need to delete the linux-headers to free up some space. In order to do that just the run the command shown below −

sudo apt-get autoremove linux-headers-x.x


Replace the x.x with the previous version of linux-headers and you are done.

## Output

immukul@192 ~ % df -i
Filesystem 512-blocks Used Available Capacity iused ifree
/dev/disk1s5s1 236568496 44429928 45432792 50% 559993 1182282487
devfs 277 277 0 74% 652 0
/dev/disk1s4 236568496 6293880 45432792 13% 4 1182842476

An alternate way is to make use of the command shown below, that will help us to achieve the same result.

Just type the command shown below in your terminal −

sudo find . -xdev -type file | cut -d "/" -file 2 | sort | uniq -c | sort -n

## Output

immukul@192 ~ % df -i
Filesystem 512-blocks Used Available Capacity iused ifree
/dev/disk1s5s1 236568496 44429928 45432792 50% 559993 1182282487
devfs 207 207 0 63% 652 0
/dev/disk1s4 236568496 6293880 45432792 13% 4 1182842476
Published on 29-Jul-2021 12:12:00