Updated: 4 November 2026 · Applies to: ext4 (e2fsprogs 1.47.2), XFS (xfsprogs 6.13) and Btrfs, tested on Debian 13 with Linux 6.12; the same commands work on Ubuntu, AlmaLinux and Rocky Linux

An inode is the record a Linux file system keeps for every file and directory: its type, permissions, owner, size, timestamps, link count and where the data is stored. Each file, directory and symbolic link uses one inode. When a file system runs out of inodes, you get No space left on device even though df -h still shows free space. Check inode usage with df -i, find the folder with the most files with du --inodes, then delete files you do not need. On ext4 the number of inodes is fixed when the file system is created, so getting more means growing or recreating it; XFS can raise its limit while mounted.

What an inode contains

According to the inode(7) manual page, an inode holds the file type and mode (permissions), the owner's user and group ID, the size, the number of blocks allocated, the access, modification, status change and creation times, and the link count. The file name is not in the inode: a directory is a list of names, each pointing to an inode number. Inode numbers are unique only within one file system. ls -i and stat show them:

$ ls -li report*
1572966 -rw-r--r-- 2 root root  6 Oct 11 14:38 report-hardlink.txt
1572967 lrwxrwxrwx 1 root root 10 Oct 11 14:38 report-symlink.txt -> report.txt
1572966 -rw-r--r-- 2 root root  6 Oct 11 14:38 report.txt
$ stat report.txt
  File: report.txt
  Size: 6         	Blocks: 8          IO Block: 4096   regular file
Device: 0,43	Inode: 1572966     Links: 2

A hard link (report-hardlink.txt) is a second name for the same inode, so the link count is 2 and no extra inode is used. A symbolic link is a small file of its own with its own inode. This lab output (shortened) is from our Debian 13 test container.

1. Check inode usage: df -i

df -i
df -ih /home
df -iT

IUsed and IFree are inodes, not bytes; IUse% is the figure to watch. -h rounds the numbers (241K, 2.9M) and -T adds the file system type, which decides how you can add inodes later.

2. What running out of inodes looks like

To show it, we created a 64 MB ext4 file system with only 2,048 inodes on a test kernel and filled it with empty files, like a folder of PHP session or cache files:

created 2035 files
touch: cannot touch '/mnt/t/sessions/sess_2036': No space left on device
$ df -h /mnt/t
Filesystem      Size  Used Avail Use% Mounted on
/dev/ubda        59M  101K   54M   1% /mnt/t
$ df -i /mnt/t
Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/ubda        2048  2048     0  100% /mnt/t

Only 1% of the space is used, yet no new file can be created, because every inode is taken. Deleting the files brought IUsed back to 13. If df -h shows a full disk instead, it is a space problem: see No space left on device, which covers both causes and deleted files that are still open.

3. Find the folders with the most files

sudo du --inodes -x -d 1 / | sort -n | tail -5
sudo du --inodes -x -d 1 /var | sort -n | tail -5

--inodes counts files and folders instead of bytes, -x stays on one file system and -d 1 shows one level. Lab output from our test container:

$ du --inodes -x -d 1 /usr | sort -n | tail -5
140	/usr/sbin
328	/usr/bin
3943	/usr/lib
5896	/usr/share
10340	/usr

Run it again on the largest folder until you reach the one that holds the files. With find you can count regular files per folder in one pass:

sudo find /var -xdev -type f | cut -d / -f 2-4 | sort | uniq -c | sort -n | tail

Cache folders, session folders, mail queues and old backups made of many small files are worth checking first.

4. Free inodes by deleting files

Delete only what you are sure is not needed, for example cache or session files older than a few days. In a folder with hundreds of thousands of files, rm * fails with Argument list too long; use find instead, as shown in delete files in Linux:

sudo find /path/to/cache -type f -mtime +7 -print | head     # check first
sudo find /path/to/cache -type f -mtime +7 -delete

Then fix the cause (a cache that never expires, a cron job that writes a file per run), or the inodes fill up again.

5. Increase the number of inodes

ext4: grow or recreate the file system

The mke2fs manual says that it is not possible to change the bytes-per-inode ratio after the file system is created. Two things still give you more inodes:

  1. Grow the file system. When you enlarge the disk or volume and run resize2fs, ext4 adds inodes in proportion. In our test a 1 GiB file system had 65,536 inodes; after growing it to 2 GiB with resize2fs it had 131,072.
  2. Recreate it with more inodes. This erases the file system, so back up and restore the data. -i sets bytes per inode, -N a total count. On a 1 GiB test volume:
    • mkfs.ext4 /dev/sdX1 (default, one inode per 16384 bytes): 65,536 inodes
    • mkfs.ext4 -i 4096 /dev/sdX1: 262,144 inodes
    • mkfs.ext4 -N 500000 /dev/sdX1: 500,224 inodes (rounded up)
    • mkfs.ext4 -T largefile /dev/sdX1: 1,024 inodes, for volumes that hold only big files

Check the result with sudo tune2fs -l /dev/sdX1 | grep -i "inode count". The defaults live in /etc/mke2fs.conf (inode_ratio = 16384, inode_size = 256 on Debian 13), and mke2fs picks a usage type by size: small (one inode per 4096 bytes) below 512 MB, default up to 4 TB, then big and huge with fewer inodes. A third option avoids reformatting the main disk: move the folder with millions of small files to its own volume created with -i 4096.

XFS: raise the inode limit online

XFS creates inodes as needed, up to a maximum percentage of the space (imaxpct, 25 on our test file system). Check it with xfs_info /mountpoint | grep imaxpct and raise it while mounted:

$ sudo xfs_growfs -m 25 /mnt/x
inode max percent changed from 1 to 25
$ df -i /mnt/x
Filesystem     Inodes IUsed  IFree IUse% Mounted on
/dev/ubda      163840  6528 157312    4% /mnt/x

In this lab the file system was made with imaxpct=1 on purpose: it stopped at 6,528 inodes with 232 MB free, and after the change new files could be created again (output shortened).

Btrfs: no fixed inode count

Btrfs allocates inodes dynamically and df -i shows 0 in every column. On Btrfs, No space left on device is about space, not inodes.

Inode limits on shared hosting

Hosting accounts often have their own inode limit, separate from the disk. On Ucartz shared and reseller hosting, section 4 of the Acceptable Use Policy sets 300,000 inodes per account, and every file and folder in the account counts. cPanel can show your account's inode count: see inode usage in cPanel. If you get close, check old backups, cache folders and large mailboxes first, or move a site that needs millions of small files to a KVM VPS with full root access, where only the file system limits described above apply.

Official documentation: inode(7), mke2fs(8) and xfs_growfs(8).

Was this answer helpful?

Still stuck? Open a ticket