Support >
  About independent server >
  How do I increase the number of disk inodes in Linux
How do I increase the number of disk inodes in Linux
Time : 2024-12-04 14:58:08
Edit : Jtti

When creating a new file system on a disk partition in Linux, the kernel sets aside space for inodes during the initial build of the file system. The number of inodes in a file system directly affects the number of files. The maximum number of inodes is set when the file system is created, which also means that the maximum number of files is set. When all inodes in the file system are exhausted, the kernel cannot create new files even if there is free space on the disk. So how do you increase the number of inodes in your file system in Linux?

You can reformat the file system. Back up data first. Reformatting the file system clears all existing data. Therefore, back up important data in advance. Before reformatting, unmount the file system. If you want to increase the number of inodes for file systems mounted on /mnt/data:

sudo umount /mnt/data

To reformat the file system, use the mkfs command to recreate the file system and specify the number of inodes required, such as the ext4 file system.

sudo mkfs.ext4 -N <desired_inode_count> /dev/sdXn

Where <desired_inode_count> is the number of inodes you want to create, and /dev/sdXn is the device name (for example, /dev/sda1).

xfs file system:

sudo mkfs.xfs -i maxpct=<percentage> /dev/sdXn

Where <percentage> is the percentage of space devoted to the Inode.

After reformatting, mount the file system and recover the data:

sudo mount /dev/sdXn /mnt/data

Restore all the backup data to the new file system.

In addition to the above methods, you can also recreate a new file system. Sometimes reformatting the current file system is not feasible and you need to consider adding new disks or partitions and formatting to increase the Inode number. Add a new disk or partition, assuming that the new disk or partition is /dev/sdb1. To create a new file system:

sudo mkfs.ext4 -N <desired_inode_count> /dev/sdb1

Create a mount point and mount a new file system:

sudo mkdir /mnt/newdata

sudo mount /dev/sdb1 /mnt/newdata

Then migrate some data to the new mount point to reduce the burden on the original file system.

You can run the following commands to check the Inode usage in the file system, such as the number of inodes, used inodes, and remaining inodes.

These are two common ways to increase inodes in Linux file systems. The main thing is to reformat the file system and specify the number of new inodes, and to create a new file system. Before using these methods, you need to back up important data to prevent data loss. If reformatting is not feasible, consider adding a new disk or partition and formatting it to meet the requirements.

JTTI-Defl
JTTI-COCO
JTTI-Selina
JTTI-Ellis
JTTI-Eom