df · Linux command

Also known as: df command

On this page 7

df (short for disk free) is the Linux command that reports the total size, used space and available space of every mounted filesystem, together with the mount point where each one is attached. In Linux monitoring it is the first tool administrators reach for when a service fails with “No space left on device”, and it is a standard data source for alerting on filesystem capacity.

The df command reads its figures from the kernel through the statfs system call, so it answers instantly regardless of how many files a volume holds. It describes filesystems as a whole; to find out which directories consume the space, administrators turn to its neighbor du.

How df obtains its numbers

For each mount listed in /proc/self/mounts, df calls statfs() or statvfs(), which returns the block size, total blocks, free blocks and blocks available to unprivileged users, plus the matching inode counts. df multiplies these by the block size and prints the result. Because it never walks the directory tree, df is fast even on multi-terabyte volumes.

The difference between free and available blocks is essential. On ext4, about 5 percent of blocks are reserved for root by default, so ordinary users may hit a full disk while root can still write. df shows the reserved part neither as used nor as available, which is why Used plus Avail is often smaller than Size.

The default output columns and their meaning are listed below.

ColumnMeaningNotes
FilesystemSource device or pseudo filesystemFor example /dev/nvme0n1p2 or tmpfs
SizeTotal capacityExcludes filesystem metadata overhead
UsedSpace consumed by data and metadataCounts deleted files still held open
AvailSpace writable by normal usersExcludes root-reserved blocks
Use%Used divided by Used plus AvailRounded up, so 99.1 shows as 100
Mounted onMount point in the directory treeWhere the filesystem is visible
Columns in standard df output

Essential df options

GNU coreutils df, the version shipped by most Linux distributions, offers options for human-readable sizes, inode reports, type filtering and custom columns. Busybox df on embedded systems supports a smaller subset.

OptionEffectTypical use
-hSizes in powers of 1024 (K, M, G)Quick interactive check
-HSizes in powers of 1000Matching vendor-reported disk sizes
-iInode totals, used, free and IUse%Diagnosing inode exhaustion
-TAdds a filesystem type columnDistinguishing ext4, xfs, tmpfs, nfs
-x tmpfs -x devtmpfsExcludes listed typesHiding memory-backed mounts
-lLocal filesystems onlyAvoiding slow or hung network mounts
–output=Selects specific fieldsMachine-readable output for scripts
-PPOSIX format on one line per mountStable parsing in shell scripts
Frequently used df options

For scripts, df --output=target,pcent -x tmpfs or df -P produces stable, parseable output. Running df against a path, as in df -h /var/log, reports only the filesystem that contains that path, which is the quickest way to learn which volume a directory lives on.

df compared with du and other monitoring tools

df and du answer different questions and often disagree. df asks the filesystem how many blocks are allocated; du walks directories and sums the sizes of files it can reach. Neighboring Terms in Linux monitoring cover the remaining angles of storage health.

ToolQuestion it answersData source
dfHow full is each filesystemstatfs per mount
duWhich directories use the spaceRecursive directory walk
lsofWhich processes hold deleted files open/proc file descriptor tables
iostatHow busy is each block device/proc/diskstats
iotopWhich processes generate disk I/OPer-task I/O accounting
lsblkHow disks and partitions are laid outsysfs block device tree
df and related storage monitoring tools

When df shows a full disk but du finds far less data, the usual causes are files deleted while a process still holds them open, data hidden under a mount point, or space consumed by filesystem snapshots.

Interpreting df on modern filesystems

Copy-on-write and pooled filesystems complicate the simple model. On Btrfs, df reports a rough estimate because data and metadata profiles such as RAID1 consume raw space at different rates; btrfs filesystem usage gives the accurate picture. On ZFS, all datasets in a pool share free space, so each dataset shows the same Avail value, and zfs list is the authoritative tool.

Pseudo filesystems such as tmpfs, devtmpfs and overlay also appear in df. A tmpfs size is a limit on memory use, not disk space, and an overlay mount in a container reports the capacity of the host filesystem underneath it.

Pitfalls and alerting practice

Most disk-related outages come from a small set of recurring situations. The table maps symptoms to their causes and the corrective action.

SymptomLikely causeFix
Writes fail, df shows free spaceInode exhaustionCheck df -i, remove many small files
df and du disagree by gigabytesDeleted files still openlsof +L1, then restart the process
df hangsUnresponsive NFS or CIFS mountUse df -l or fix the network mount
Use% at 100, root can still writeReserved blocks in useFree space or adjust with tune2fs -m
Sudden jump in UsedRunaway logs or core dumpsRotate logs, limit journald size
Common df symptoms and fixes

In monitoring systems, alert on both space and inode usage, typically warning at 80 to 85 percent and paging at 90 to 95 percent, and add a rate-of-change alert that predicts when a volume will fill. A volume that grows from 60 to 85 percent in an hour deserves more urgency than one that has sat at 88 percent for months.

In plain words

Think of each disk on a computer as a storage room. df is a quick inventory sheet that lists every room, how big it is, how much is already filled and how much shelf space is left. It does not open boxes to see what is inside; it simply reads the counter on the door.

That makes it the fastest way to answer the question “is anything about to run out of room”. When the answer is yes, a different tool is used to find out which boxes are taking up the space.

A real-world example

An online shop’s database server starts rejecting orders at night with write errors. The on-call administrator runs df -h and sees /var at 100 percent, although du reports only 31 GB of data on a 50 GB volume. Running lsof +L1 reveals a log file of about 19 GB that logrotate deleted while the application still held it open.

Restarting the logging service releases the file and df drops to 62 percent within seconds. The team then adds a copytruncate setting to the rotation rule and a monitoring alert at 85 percent usage, and the same failure does not return during the following peak season.