increase inode number in linux

How to Increase Inode Limit in Linux

Inode number is the unique ID for each file in a Linux system. Every Linux system has a fixed number of inodes that determines the maximum number of files that it can support. When a file is created, it is assigned a file name and inode number. If your Linux system runs out of Inode numbers then you will not be able to create any new files on it, even if you have disk space available. In this article, we will look at how to increase inode limit in Linux.

How to Increase Inode Limit in Linux

Here are the steps to increase Inode Limit in Linux. Generally, when we create a new filesystem, the system administrators use -i option to keep aside some bytes-per-inode to store inode numbers. If you use many bytes per inode then you can store only limited number of inodes on disk.

Please note, once you have created a filesystem, its number of inodes remain fixed and cannot be changed unless you re-format it.

Here is an example to set a small bytes per inode number when you create a new filesystem. This will create large number of inodes in your system.

$ sudo mkfs.ext4 -i 16000 /dev/sdev

In the above example, we have set 16000 bytes per inode.

Here is another example with large byte space for inode, which will result in lesser number of inodes.

$ sudo mkfs.ext4 -i  196000 /dev/sdev

You can also configure your filesystem’s config file to set how to handle large files. Open mke2fs.conf file in a text editor and make changes as per your requirement.

$ sudo vi /etc/mke2fs.conf

You may also issue the following command from terminal using -T flag to configure how your filesystem handles large files.

$ sudo mkfs.ext4 -T largefile /dev/device
$ sudo mkfs.ext4 -T largefile4 /dev/device

In the above code we use largefile and largefile4 settings that stores 1 inode per 1Mb and 4Mb respectively.

If you want to check the number of inodes available and used you can do so with the following command.

$ df -i

You will see the following kind of output

Filesystem      Inodes  IUsed  IFree IUse% Mounted on
udev            250472    308 250164    1% /dev
tmpfs           254091    480 253611    1% /run
/dev/xvda1     1024000 352097 671903   35% /
tmpfs           254091      1 254090    1% /dev/shm
tmpfs           254091      4 254087    1% /run/lock
tmpfs           254091     18 254073    1% /sys/fs/cgroup
/dev/loop0       10794  10794      0  100% /snap/core18/2066
/dev/loop1       12850  12850      0  100% /snap/core/11316
tmpfs           254091     11 254080    1% /run/user/1000

That’s it. In this article, we have looked at how to increase inode number of disk. It is important to set this at the time of file system creation, since you cannot change it without re-formatting the disk. Also it is a static number that does not change dynamically.

Also read:

How to Enable HAProxy Stats
How to Convert DEB to RPM Files in Linux
How to Configure Access Control Lists (ACL) in Linux
How to Concatenate Multiple Lists in Python
How to Get MD5 Hash of String in Python

Leave a Reply

Your email address will not be published. Required fields are marked *