Skip to Content

2 Ways to check inode in Linux

Inodes are one of the most important aspects of any Linux system. They keep track of all the files and directories on your system, and if they fill up, your system can become unusable. In this blog post, we will discuss two different ways to check inode usage on your Linux system. We will also provide some tips on how to free up disk space if you are running low on inodes. Let’s get started!

What is an inode in Linux?

In computing, an inode is a data structure that represents a file system object such as a file or directory. Each inode stores information about the object, including its location on disk, permissions, and timestamps.

How are inodes used in Linux?

Inodes are used to keep track of files and directories on a Linux system. When you create a new file or directory, an inode is created for it. Inodes contain all the information about a file or directory except its actual data (the name, owner, permissions, etc).

Understanding Inodes and file system in Linux

an inode is an index node. It serves as a unique identifier for a specific piece of metadata on a given filesystem. Each piece of metadata describes a file. That’s right, inodes operate on each filesystem, independent of the others. They keep track of all the files and directories on your system, and if they fill up, your system can become unusable.

The difference between an inode and a file system is that an inode is a data structure that stores information about a specific file, while a file system is a collection of inodes that organizes all the files on your system.

In short, an inode is like a card in a library catalog that stores information about where to find a book. The file system is the library itself, which contains all the books (files) organized into shelves (directories).

Check inodes usage with df command in Linux

The best way to check inodes usage in Linux is to use the “df” command. This command will show you the amount of free space on each partition of your system. It will also show you the inodes usage on each partition. To see just the inode information, you can use the “-i” flag like this: df -i

This command will show you the inode usage for all partitions on your system. As you can see from the following example, the “/” partition has the most inodes used, while the “/boot” partition has the least.

Filesystem    Inodes IUsed  IFree IUse% Mounted on
/dev/nvme0n1p9 24376320 132601 24243719  1% /
/dev/nvme0n1p6 2097152  258 2096894  1% /home
/dev/nvme0n1p2 5242880   11 5242869  1% /tmp
/dev/nvme0n1p3 4718592 12034 4706558  1% /var
/dev/nvme0n1p1  524288  312  523976  1% /boot

If you want to check the inodes usage of a specific partition, you can use the “df -i /directory” command. This command will show you the total number of inodes, used and free. For example, to check the inode usage of the “/home” directory, we would use this command:

Filesystem    Inodes IUsed  IFree IUse% Mounted on
/dev/nvme0n1p6 2097152  258 2096894  1% /home

As you can see, the “/home” directory is using a very small number of inodes. This is good! If you see a directory that is using a large number of inodes, it might be time to clean it up so that you don’t run out of space.

check inode number with ls command in Linux

The “ls” command can also be used to check inode number. This command will show you the inode number and size for each file and directory in a given directory. The first column is the inode number for each file. For example, to see the inode number and size for the “/etc” directory, we would use this command: ls -li /etc

67157114 drwxr-xr-x. 2 root   root     6 Apr 23 2020 xinetd.d
34152745 drwxr-xr-x. 2 root   root     57 Sep 5 2021 yum
610764 lrwxrwxrwx. 1 root   root     12 Mar 8 2021 yum.conf -> dnf/dnf.conf
831 drwxr-xr-x. 2 root   root    4096 Oct 12 2021 yum.repos.d

As you can see, this command will show you a lot of information about each file and directory in the “/etc” directory. To just see the inode information, you can use the “-i” flag like this: ls -i /etc

ls -i /etc
1703 DIR_COLORS         610844 dnsmasq.d    67157680 ld.so.conf.d         504600 pcp.conf        853 shells

Can I increase the number of inodes on my system?

No, Inodes are a finite resource and cannot be increased. If you’re running low on inodes, it might be time to take some steps to free up disk space so that you don’t run out completely!

In this blog post, we discussed three different ways to check inode usage on your Linux system. We also provided some tips on how to free up disk space if you are running low on inodes. If you have any questions or comments, please feel free to leave them below. Thanks for reading!