brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: du --inodes shows which folder uses up all your inodes

Linux
~/tips/tip-disk-du-inodes-which-folder

sudo du --inodes -x -d2 /var | sort -n | tail

Counts files per directory instead of bytes, to find what exhausts the inodes.

When df -i says the inodes are gone but there are gigabytes free, the next question is which directory holds the millions of tiny files. Normal du is no help there, because it counts blocks. GNU du can count files instead.

Add --inodes and it lists inode usage instead of block usage:

sudo du --inodes -x -d2 /var | sort -n | tail

Each line has the number of inodes under that directory. The last lines of the sorted output show the culprits. A mail spool, a cache folder, or a program that writes one file per event are the usual suspects. I added -x so the scan stays on the filesystem that is full, and -d2 to limit the depth to two levels. Raise the depth to drill down.

I leave -h off and sort with -n, because the numbers are plain counts.

The caveat: counting a huge tree takes a while and reads a lot of metadata, which on a slow disk makes the system sluggish for the duration. Run it with nice or ionice if the machine is busy. And before you delete a folder that came out on top, check what it belongs to. A directory with ten million small files is often a cache that a program rebuilds, but not always.

Further reading: du(1) manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link