Back to Explore
GuideVibeFix editorialUpdated Dec 1, 2026

df From Zero: Disk Full? First Find Out Which Disk — and What 'Full' Means

df answers one question: how much space is left on each file system. This guide runs every command for real on GNU coreutils df 9.4 — a 100M file moving Use% from 2% to 21%, inodes with df -i, and the classic trap: a deleted-but-open file keeps its space until the process exits — with output pasted verbatim.

Real photograph of an open hard disk drive showing the platter and actuator arm (illustrative photo)

A full disk is one of the most common and most alarming errors on a server. Writes fail, the database will not start, logs stop being written, a deploy stalls halfway — and behind it all is often the same message: No space left on device. But "the disk is full" is itself vague: which disk is full? Is it out of space, or out of inodes? Is it really full, or is a deleted file still holding space? df is the tool that answers those questions. Its manual page defines it in one line: "df - report file system space usage". Every command in this guide was run for real on GNU coreutils df 9.4, and the output is pasted verbatim.

Check the version first, then start:

$ df --version
df (GNU coreutils) 9.4
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.
exit=0

With no arguments, df -h lists every mounted file system:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay         7.5G   52M  7.5G   1% /
tmpfs           512M  7.5M  505M   2% /tmp
tmpfs           4.0M     0  4.0M   0% /sys
tmpfs           4.0M     0  4.0M   0% /dev
tmpfs           794M     0  794M   0% /dev/shm
tmpfs           1.6G  40K  1.6G   1% /run
tmpfs           1.6G  9.5M  1.6G   1% /run/hatch/auth
/dev/mapper/rv  150G  6.8G  143G   5% /run/hatch/resume
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/mapper/rv  150G  6.8G  143G   5% /home/hatch
overlay         1.6G  9.5M  1.6G   1% /opt/hatch/connectors
overlay         1.6G  9.5M  1.6G   1% /opt/hatch/bin
tmpfs           2.0G     0  2.0G   0% /var/tmp
exit=0

Read it column by column. Filesystem is the source of the file system (a device name or a type name); Size is the total; Used is how much is taken; Avail is how much is left; Use% is the used proportion; Mounted on is the mount point. The -h means human-readable: powers of 1024 (M, G) instead of the default 1K blocks. Notice how many tmpfs entries there are — memory file systems that live in RAM and vanish on reboot — plus overlay, the stacked file system containers use, and /dev/mapper/rv, a real 150G disk mounted in two places. A first-time reader often asks why the same disk (/dev/mapper/rv) appears twice: because it is mounted at two places, and df lists by mount point, not deduplicated by device. Also note that /tmp in this sandbox is a 512M tmpfs, which is unusual on a normal machine — there, /tmp is usually part of the root file system. The demo uses that 512M tmpfs; the numbers will differ, the columns and the behaviour will not.

The most common use of df is not listing everything, but asking about one place: "which file system is this directory on, and how much is left?" Give df a file or directory as an argument and it answers for the file system containing it:

$ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           512M  7.5M  505M   2% /tmp
exit=0

That is step one of any "disk full" investigation: find which directory the error happened in, then run df -h on it. The tmpfs holding /tmp is 512M in total, 7.5M used, 505M available, 2% used. These numbers change on every run — other processes write to /tmp too — so this article quotes the structure, not the numbers as fixed values.

Add -T and you see the file system type:

$ df -hT /tmp
Filesystem     Type   Size  Used Avail Use% Mounted on
tmpfs          tmpfs  512M  7.5M  505M   2% /tmp
exit=0

The Type column says tmpfs: this is not a disk, it is memory. The type changes the investigation: a full tmpfs clears on reboot but may mean some process is writing into it furiously; a full ext4 or xfs means hunting for large files; a full overlay means looking at container layers. -T is the "first find out what you are dealing with" option, and it is worth making a habit.

Running out of space is not the only way to run out. A file system also has inodes — every file and every directory consumes one — and when the inodes are gone, no new file can be created even with space to spare. Check them with -i:

$ df -i /tmp
Filesystem      Inodes IUsed   IFree IUse% Mounted on
tmpfs          1015576    17 1015559    1% /tmp
exit=0

This tmpfs has 1,015,576 inodes in total, 17 used, 1,015,559 free. The classic inode-exhaustion scene: a program generates hundreds of thousands of small files — cache fragments, session files, temporary files left by failed retries — using only a few gigabytes of space while the inodes run out first. The error is still No space left on device, but df -h looks like it has space to spare. That is when to look at df -i. The rule to remember: df -h talks about space, df -i talks about inodes, and both tables deserve a look.

Too many columns, and you only want a few: use --output to pick your own:

$ df --output=source,size,used,avail,pcent,target /tmp
Filesystem     1K-blocks  Used  Avail Use% Mounted on
tmpfs             524288  7612 516676   2% /tmp
exit=0

One detail here: without -h, --output reports sizes in 1K blocks — 524,288 of them is 512M. That is df's default unit, and the manual page says so plainly: "Space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used." The field names --output accepts are the twelve the manual page lists: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file and target. For scripts and monitoring, --output is far more reliable than parsing the default df -h output — the columns and their order are yours to specify, and they will not shift with the system language or version.

df's two tables: the space table Size/Used/Avail/Use% and the inode table Inodes/IUsed/IFree/IUse%, plus how Avail moves when a 100M file is written

Numbers alone are not enough; they have to move. The demo script creates a 100M file in /tmp and looks again:

$ fallocate -l 100M /tmp/df-demo282/blob-100m
exit=0
$ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           512M  108M  405M  21% /tmp
exit=0

One 100M file moves Used from 7.5M to 108M, Avail from 505M down to 405M, Use% from 2% to 21%. Delete it, and the numbers return at once:

$ rm -f /tmp/df-demo282/blob-100m
exit=0
$ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           512M  7.5M  505M   2% /tmp
exit=0

That is the fundamental difference between df and du: df asks how much a file system has left, du asks how large the files in a directory add up to. Writing and deleting a file moves df's numbers — except in one case. Deleting a file does not always free its space. The next part of the demo is that classic trap.

Deleting a file does not necessarily return its space. If a process still has the file open, the kernel will not free its blocks — the file is invisible in the directory, but still alive on the disk. The demo script opens a 50M file in Python and never closes it, then deletes it from another shell:

$ rm -f /tmp/df-demo282/open-blob
exit=0
$ df -h /tmp   # file deleted, but the process still holds it open
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           512M   56M  457M  11% /tmp
exit=0

The file is deleted, but Used is still 56M, Avail still 457M, Use% stuck at 11% — the 50M has not come back. Only when the Python process holding it exits does the space return:

$ df -h /tmp   # holder exited: the space comes back
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           512M  7.5M  505M   2% /tmp
exit=0

This is one of the most common real causes of "disk full" in production: log rotation deletes old logs, but the process writing the log still holds the old file open, so the space is never freed. The way to find it is lsof (this series already has an lsof guide): lsof +L1 lists files that are deleted but still open; find the process, restart it or make it reopen its log file, and the space returns immediately. Remember the rule: rm deletes the directory entry; only the process exiting frees the space. df sees the latter, du sees the former — and that is the number-one reason their numbers disagree.

Next, filtering and totals. -x excludes a type, -t keeps only one type:

$ df -h -x tmpfs
Filesystem      Size  Used Avail Use% Mounted on
overlay         7.5G   52M  7.5G   1% /
/dev/mapper/rv  150G  6.8G  143G   5% /run/hatch/resume
/dev/mapper/rv  150G  6.8G  143G   5% /home/hatch
overlay         1.6G  9.5M  1.6G   1% /opt/hatch/connectors
overlay         1.6G  9.5M  1.6G   1% /opt/hatch/bin
exit=0

With tmpfs excluded, only real disks and overlay remain. --total adds a grand-total line:

$ df -h --total
Filesystem      Size  Used Avail Use% Mounted on
overlay         7.5G   52M  7.5G   1% /
tmpfs           512M  7.5M  505M   2% /tmp
tmpfs           4.0M     0  4.0M   0% /sys
tmpfs           4.0M     0  4.0M   0% /dev
tmpfs           794M     0  794M   0% /dev/shm
tmpfs           1.6G  40K  1.6G   1% /run
tmpfs           1.6G  9.5M  1.6G   1% /run/hatch/auth
/dev/mapper/rv  150G  6.8G  143G   5% /run/hatch/resume
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/mapper/rv  150G  6.8G  143G   5% /home/hatch
overlay         1.6G  9.5M  1.6G   1% /opt/hatch/connectors
overlay         1.6G  9.5M  1.6G   1% /opt/hatch/bin
tmpfs           2.0G     0  2.0G   0% /var/tmp
total           317G   14G  302G   5% -
exit=0

The last line sums every file system: 317G total, 14G used, 302G available. Note that the total also counts duplicate mounts (/dev/mapper/rv appears twice), so it is not "total disk capacity" — only "the sum of the mount points". Do not use it for capacity planning as if it were one disk. -l (--local) lists only local file systems, excluding network mounts (NFS, CIFS) — useful on machines with many network shares mounted.

df also fails, and the failure itself is information:

$ df -h /nonexistent
df: /nonexistent: No such file or directory
exit=1

A path that does not exist gives exit code 1. Scripts can use that: check the path exists before running df. Another common error is "Permission denied" — some mount points are unreadable by ordinary users, df skips them with an error, and root is unaffected.

Now string the investigation together. Suppose a deploy fails with No space left on device. Step one, df -h: which disk is full? Take the line with the highest Use% and note its mount point. Step two, df -i: is it space or inodes? If IUse% is at 100%, hunt for small files; if Use% is at 100%, hunt for large ones. Step three, find the large files: du -sh /mountpoint/* drills down one level at a time (du is another tool, coming later in this series), or find /mountpoint -xdev -type f -size +100M lists files over 100M directly. Step four, check for deleted-but-open files: lsof +L1, find the holder, restart it. Step five, check for mount-point shadowing: files written into a directory before something was mounted over it become invisible, but still occupy space — only unmounting reveals them. Step six, check reserved blocks: ext4 reserves 5% for root by default, so when ordinary users see Use% at 100%, root can still write. That is not a bug; it is an escape hatch left for the system. Six steps, and "disk full" is almost always located.

Two more traps. The first: -h versus -H. -h uses powers of 1024 (1K = 1,024 bytes); -H uses powers of 1000 (1KB = 1,000 bytes). The same disk reads 512M with -h and 537MB with -H — different numbers for the same thing. When reconciling numbers with another person or a vendor, confirm which unit set both sides are using, or you will spend an afternoon arguing over a missing 25M. The second: df sees file-system-level numbers, du sees file-level numbers, and they disagree by nature. Besides deleted-but-open files, there are sparse files (logically large, physically a few blocks), mount-point shadowing, and files on other mount points — all of which make the two disagree. A mismatch does not mean either tool is broken; they are measuring different things.

One more piece of semantics that trips people up the first time: the path you give df answers "which file system is this path on", not "how large is this path". The demo script ends with df -h /tmp/df-demo282:

$ df -h /tmp/df-demo282
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           512M  7.5M  505M   2% /tmp
exit=0

/tmp/df-demo282 is a directory that by then holds no files, yet df still reports the whole tmpfs — 512M, 7.5M, 505M — because it reports the file system's numbers. To find out how large a directory is, that is du's job. But this semantic is exactly what makes df useful: an error happens in some directory, feed that directory to df, and you immediately know which disk and how much is left. The manual page also states one limitation explicitly: df cannot show the space available on unmounted file systems — "because on most kinds of systems doing so requires non-portable intimate knowledge of file system structures". To inspect a disk that is not mounted yet, mount it first.

The other everyday use of df is monitoring. Disks do not fill suddenly; they creep — logs a few hundred megabytes a day, backups a few gigabytes a week, and six months later a 3 a.m. alert. The simplest monitoring is a scheduled job that runs df --output=source,pcent,target once a day and reports any line over 80%. The thresholds are a matter of experience: 80% warns, 90% alerts, 95% means act now. The reason for 80% is that many services degrade before they fail: databases stop writing, log rotation breaks, temporary files cannot be created. Waiting for Use% to reach 100% means you are already firefighting. In the demo, one 100M file moved Use% from 2% to 21% — a small-scale picture of the same dynamic: a small file system (a 512M tmpfs) cannot take many large writes, and a production root disk of tens or hundreds of gigabytes fills slowly but just as fatally.

Prevention is cheaper than firefighting, and three habits cover most of it. First, log rotation: configure logrotate with a retention period and compression, and stop logs growing forever — in many "disk full" incidents, opening the disk reveals years of logs nobody deleted. Second, clean temporary files on a schedule: /tmp and /var/tmp get tidied by systemd's tmpfiles mechanism, and container images and build caches deserve the same treatment — one docker system prune can free tens of gigabytes. Third, do the arithmetic on backups and snapshots: backup files take space too, and backing up onto the same disk as the source is no backup at all. Keep the backup target on a different disk from the source — common sense, and a baseline. None of this needs a new tool; it needs someone to look at df output regularly.

Put df and du side by side and their division of labour is easy to remember: df answers "how much does this file system have left", viewed by mount point, in blocks and inodes, reading the kernel's books; du answers "how large is this directory", summed down the directory tree, in blocks files actually occupy, reading the files' books. Their numbers disagreeing is normal: deleted-but-open files, sparse files and mount-point shadowing all make them fight. When investigating, use df first to find the disk, then du to find the directory, then lsof to find the process — three tools, each covering one stretch, in that order. Going the other way round works too, but df shows the whole picture at a glance while du has to drill down level by level, and in a fire the whole picture first is the cheaper move.

A few more words on reserved blocks. ext4 reserves 5% of a file system for root by default, so when ordinary users see Use% at 100%, root can still write. That 5% is an escape hatch for system processes: logs can still be written, root can still log in, an administrator can still delete files to recover. On a very large disk — 1TB, say — 5% is 50G locked away for nothing, and tune2fs -m 1 can lower it to 1%. But do not lower it to zero: with truly nothing left, even root cannot write, and the system can seize up. The Avail column in df shows what ordinary users can use (after the reserved blocks are subtracted), while Size minus Used is the physical remainder — the gap between them is the reservation. Once you know that, an output like "Size 100G, Used 95G, Avail 0" stops being confusing: nothing is miscalculated; the reservation is doing its job.

Finally, a note on this guide's environment, because the numbers will not match your machine. The demo ran in a sandbox: /tmp is a 512M tmpfs, the root file system is a 7.5G overlay, and /home/hatch sits on a 150G disk. On your machine, /tmp is very likely part of the root file system, the root disk is probably tens or hundreds of gigabytes, and the Use% baseline will differ. None of that changes the conclusions: df's columns, options and behaviour are the same on every Linux, and only the numbers move. Run the demo script on your own machine, on a different disk and a different directory, and you will really know df. The script removed every file it created and cleaned up its working directory; nothing is left behind.

One more handy habit: with no path, df shows everything; with a dot, it shows the current directory's file system. Standing in a project directory, df -h . immediately tells you which disk the project is on and how much is left — better checked before a deploy than discovered halfway through one that fails. Scripts can do the same: check the target directory's space at the start, and exit early with an error if there is not enough, instead of failing halfway through a write. Many scheduled jobs and backup scripts should carry that one-line check. It costs one command and saves a 3 a.m. alert.

When a disk fills during a write, the damage is more than "cannot write". A file being written stops mid-way: a database transaction log half-written, a configuration file saved half-way, a backup truncated in the middle. Worse, some programs do not fail loudly on a write error; they keep running and only surface the error at the end — by which time more than one file may be damaged. So treat "disk full" as high priority: free space first (delete old logs, clear caches, move large files), then check whether any file was damaged mid-write, and only then investigate the root cause. In the wrong order — root cause first, space second — more files can break in between. In a fire, stop the bleeding first, then ask why it bled.

A last small option worth knowing: --sync and --no-sync. By default df does not call sync; it reads the file system's current state. With --sync it flushes cached data to disk before reading, so the numbers are fresher but the command is slower. The default is right for daily use; only when you have just deleted a large batch of files and df's numbers have not moved is it worth re-running with --sync — cached bookkeeping can lag by half a beat. The exit code is also worth remembering: 0 on success, 1 when the path does not exist. In a monitoring script, use the exit code to judge whether the command itself ran, and Use% to judge whether the disk is full; handle the two separately, or the script will report "disk full" when the real problem is a mistyped path.

Stepping back, the learning curve for df is as gentle as ss's: one core concept — the file system — and two core tables, space and inodes. Remember df -h (which disk, how much left), df -i (are there inodes left), df -h /some/directory (which disk is this directory on) and df --output (pick your own columns for scripts), plus the trap that deleting a file does not always return its space, and daily troubleshooting is covered. The deeper topics — tuning reserved blocks, mount-point shadowing, sparse files — are for the day a specific problem sends you back to the manual page. The full df(1) text is public on man7.org.

One more practical use of --output is a monitoring script. A one-line check such as df --output=pcent,target / | tail -1 gives just the number and the mount point, ready for a comparison in a shell script or a cron job: alert at 80%, page at 90%, and keep the thresholds per filesystem rather than global, because a 90% full 512M /tmp is a different emergency from a 90% full 10 TB archive disk. Two details matter when you set those thresholds. First, df's Use% counts the root-reserved blocks: on a typical ext4 filesystem about 5% is reserved for root, so a disk can read 95% full while a normal user already sees "no space left". That reserve is why the system can still log in and clean up after users have filled the disk. Second, check the trend, not just the level: a filesystem that gains 2% a week will be full in a month, and the alert that fires on the trend is worth more than the one that fires at 95%. Record the numbers once a day, graph them, and the disk stops surprising you.

Boundary note: this guide covers only df (file-system space). It does not cover per-directory usage accounting (that is du's territory, coming later in this series), disk partitioning and formatting, or quotas and LVM. Boundaries against previously published guides: the lsof guide covers processes and files, including the deleted-but-open investigation; the rsync backup guide covers incremental backup and packaging; the tar guide covers archiving. df differs from all of them: it only reads a file system's space ledger. The demo in this guide ran in a sandbox: /tmp is a 512M tmpfs, the 100M and 50M files the demo script created have both been deleted, and the working directory has been cleaned up. In the transcript, Avail, Used and Use% differ on every run; this article quotes only structure and direction of change, and the transcript is the authority for exact numbers. The demo script ends by printing --- done (work dir removed, no file left) ---, meaning the working directory is gone and no file is left behind.

There is one more habit worth building around df: look at it before you need it. The engineers who never get woken by a full disk are not lucky; they are the ones who glance at df -h during ordinary work — after a deploy, after a backup, after importing a dataset — and notice the trend while there is still time. A disk that goes from 60% to 75% in a week is telling you something, and the message is free. The ones who get woken at 3 a.m. are the ones who only run df after something has already failed. The tool is the same either way; the difference is when you run it. Put it in your shell's login message, in your deploy checklist, in your weekly review — anywhere you will actually see it — and the 3 a.m. version of this story stops happening to you.

It is also worth saying plainly what df will never tell you. It will not tell you which files are large — that is du. It will not tell you which process is writing — that is lsof or iotop. It will not tell you whether a disk is failing — that is SMART data. df answers one question, "how much space is left on each file system", and it answers it well. The skill is not in the command but in the workflow around it: df to find the file system, du to find the directory, lsof to find the process, and a calendar reminder to look before it becomes urgent. Tools this small reward the person who uses them routinely far more than the person who memorises their manual pages.

Views 0Comments 0

Comments (0)

ME
0/1000
Loading comments...

Sources

Browse projectsPublish your project

Related articles

Real photograph of a data center corridor lined with server racks (illustrative photo)
Guide
ss From Zero: Who Holds the Port, Where the Connection Stalls — Read Sockets at a Glance

ss reads the kernel's socket table: who is listening, what state each connection is in, which process holds the socket. This guide runs every command for real on iproute2 ss 6.1.0 — a live http.server on 127.0.0.1:18080, LISTEN vs ESTABLISHED, state filters, ss -s, Unix sockets — with output pasted verbatim.

Developer WorkflowTool TipsDebugging
Real photograph of a server room patch panel filled with blue network cables (illustrative photo)
Guide
ping From Zero: One Packet Tells You If It Is Alive — the Exit Code Matters More Than the Output

ping does exactly one thing: send an ICMP echo request, wait for the echo reply, and report the round-trip time and packet loss. This guide runs every command for real on iputils ping 20240117 — packet count, interval, quiet mode, packet size, timestamps, IPv4 vs IPv6, the three failure modes, exit codes 0/1/2 — with output pasted verbatim.

Developer WorkflowTool TipsDebugging
Real photograph of a wooden desk with a white alarm clock beside a calendar page (illustrative photo)
Guide
crontab From Zero: Jobs That Just Run on Time, Five Fields Explained Once

cron is the scheduling daemon that has run on Linux for decades: write a crontab file saying 'run this command at this time', and it handles the rest. This guide runs everything for real on Debian cron 3.0pl1-162 — installing a job, waiting one minute for the trigger, verifying the log, removing the job — plus special strings, five classic mistakes, and a real 3 a.m. log-archiving job.

Developer WorkflowAutomationTool Tips