Sub topic 1
Filesystems and mount points: what you are actually measuring
This chapter explains what the disk tools report before you use them. Later chapters build on these definitions.
Prerequisites
This chapter assumes you can log in to a Linux server over SSH, run commands with sudo, and read basic ls -l output. You should know what a file and a directory are. No prior experience with df or du is needed.
Filesystems and mount points
A filesystem is the structure that stores files on a storage device, such as ext4 or XFS. A mount point is the directory where that filesystem appears in the directory tree. The root filesystem is mounted at /, and /var is often a separate filesystem with its own limits.
This matters because disk usage is per filesystem, not per server. A full /var can stop logging while / still has free space.
Blocks and inodes: two separate limits
Every filesystem tracks two resources:
- Blocks hold file data. A block is a fixed-size chunk, often 4 KiB. Running out of blocks means you cannot write more data.
- Inodes are records that hold each file's metadata, such as owner, permissions, and size, plus pointers to its blocks. Each file and directory uses one inode. Running out of inodes means you cannot create new files, even when space remains.
A filesystem can report free space and still refuse new files. This happens when it has many small files and no inodes left.
Reading df: space used, available, and where it is mounted
The df command reports usage for each mounted filesystem. The -h flag prints sizes in readable units, and -T adds the filesystem type:
df -hTColumns to check:
- Size, Used, Avail: the block usage.
- Use%: the percentage used. Note that ext4 reserves a share of blocks for root, so
Availcan hit zero before the disk is physically full. - Mounted on: the mount point.
Reading df -i: inode usage per filesystem
To see inode usage, run:
df -ihThe output lists total inodes (Inodes), used inodes (IUsed), free inodes (IFree), and percentage used (IUse%). A filesystem with IUse% at 100% cannot create new files, even when df -h shows free space. If a filesystem shows - in the IUse% column, it has no fixed inode table, which is common for some virtual filesystems.
Exercise
A server shows Avail of 2 GB on /var in df -h, yet writing a new log file fails with "No space left on device". The df -ih output shows IUse% of 100% for /var. What is the likely cause, and which resource is exhausted?
Show answer
The inode table is full. Each new file needs an inode, so the write fails even with free blocks. The cause is usually a directory holding very many small files, such as sessions or mail queues.