Why Your Disk Shows 30% Free Space Yet Won’t Write Files – Boost Inodes with ext4 -T small
The article explains why a Linux server can run out of inodes despite having plenty of free disk space, demonstrates how creating an ext4 filesystem with the -T small option dramatically increases inode count, and discusses the performance trade‑offs and quick fixes for inode exhaustion.
When a Linux server stores a large number of very small files (≈1 KB), the ext4 filesystem can run out of inodes long before the data blocks are exhausted. The command df -iT will show 100 % inode usage while the disk appears only partially full.
Why inode exhaustion occurs
Each file consumes one inode, which stores metadata and pointers to the file’s data blocks. If the workload consists mainly of tiny files, the fixed inode pool can be depleted even though there is ample free space for data.
Creating a filesystem with more inodes
During filesystem creation, the -T preset can be used to adjust the inode density. The preset small tells mke2fs (or mkfs.ext4) to use a 1 KB block size instead of the default 4 KB, which results in a larger inode table. # mkfs.ext4 /dev/sdb1 Output (default preset) shows 261 888 blocks of 4 KB and 65 536 inodes. # mkfs.ext4 -T small /dev/sdc1 Output (small preset) shows 1 048 576 blocks of 1 KB and 262 144 inodes – roughly four times more inodes.
Filesystem Type Inodes IUsed IFree IUse% Mounted on
/dev/sdb1 ext4 65536 11 65525 1% /root/default
/dev/sdc1 ext4 262144 11 262133 1% /root/smallTrade‑offs
Using -T small reduces the block size to 1 KB. Smaller blocks increase the number of blocks required to store a given file, which can lead to higher fragmentation and slower read performance for larger files. The benefit is a higher inode count, which is essential for workloads dominated by tiny files.
The -T option selects a preset defined in /etc/mke2fs.conf . Multiple presets can be combined with commas.
Temporary remedies for an existing filesystem
If a deployed filesystem has run out of inodes, you can mitigate the problem without reformatting:
Delete zero‑byte files, which still consume inodes. Example command: find /path/to/dir -type f -size 0c Be careful not to use -size 1k , which matches files that occupy 1 KB of space; to match a file whose size is exactly 1 KB, use -size 1024c .
Periodically archive or pack historic small files to reduce the total file count.
These steps can relieve inode pressure until a permanent solution (e.g., backing up data, recreating the filesystem with a higher inode density) is applied.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
