Monitoring disk space on a Linux system prevents services from failing when partitions run out of free space and log or data writes start to error. Regular checks keep enough headroom for updates, backups, and application data growth across all mounted filesystems.
The df utility queries kernel filesystem statistics to display each mount point’s total size, used space, available space, and usage percentage. Output combines information for physical disks, partitions, and virtual filesystems, making it suitable for a quick overview of how storage is allocated and consumed.
Separating directories such as /var and /home into dedicated partitions improves isolation but also increases the chance that a single partition fills up while others still have free space. df focuses on filesystem-level usage rather than individual files or folders, so it pairs with tools like du in other workflows for locating large directories.
Steps to monitor disk space and free space in Linux:
- Open a terminal on the Linux system.
- Display disk and partition size, usage, and available space for all mounted filesystems using df.
$ df Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 399740 1800 397940 1% /run /dev/sda3 19991152 7696980 11255632 41% / tmpfs 1998688 0 1998688 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 4096 0 4096 0% /sys/fs/cgroup /dev/sda2 524272 7984 516288 2% /boot/efi tmpfs 399736 108 399628 1% /run/user/1000
- Present usage and available space in a human-readable format using df -h.
$ df -h Filesystem Size Used Avail Use% Mounted on tmpfs 391M 1.8M 389M 1% /run /dev/sda3 20G 7.4G 11G 41% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup /dev/sda2 512M 7.8M 505M 2% /boot/efi tmpfs 391M 100K 391M 1% /run/user/1000
Unit changed to M (Megabyte), G (Gigabyte), T (Terabyte) etc instead of in blocks.
- Hide temporary and virtual filesystems to focus on real disks by excluding tmpfs and devtmpfs.
$ df -h -x tmpfs -x devtmpfs Filesystem Size Used Avail Use% Mounted on /dev/sda3 20G 7.4G 11G 41% / /dev/sda2 512M 7.8M 505M 2% /boot/efi
Excluding pseudo-filesystems makes it easier to spot partitions that are actually at risk of filling up.
- Display disk usage information for a specific partition by device name.
$ df -h /dev/sda3 Filesystem Size Used Avail Use% Mounted on /dev/sda3 20G 7.4G 11G 41% /
- Display disk usage information for a specific mount point.
$ df -h /boot/efi Filesystem Size Used Avail Use% Mounted on /dev/sda2 512M 7.8M 505M 2% /boot/efi
- Show disk usage in a variety of formats and with filesystem type details using different df options.
$ df -hT Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 391M 1.8M 389M 1% /run /dev/sda3 ext4 20G 7.4G 11G 41% / tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup /dev/sda2 vfat 512M 7.8M 505M 2% /boot/efi tmpfs tmpfs 391M 112K 391M 1% /run/user/1000
- Check inode usage to detect situations where a filesystem has free space but no free inodes.
$ df -i Filesystem Inodes IUsed IFree IUse% Mounted on tmpfs 100000 900 99100 1% /run /dev/sda3 1280000 85000 1195000 7% / tmpfs 500000 1 499999 1% /dev/shm ##### snipped #####
High inode usage can block new file creation even when size-based usage appears low.
- Limit output to key columns such as source, size, usage, and mount point using df –output.
$ df -h --output=source,size,used,avail,pcent,target Filesystem Size Used Avail Use% Mounted on /dev/sda3 20G 7.4G 11G 41% / /dev/sda2 512M 7.8M 505M 2% /boot/efi
- Explore additional df command options to better monitor disk size and usage in Linux.
$ df --help Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include pseudo, duplicate, inaccessible file systems -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below -h, --human-readable print sizes in powers of 1024 (e.g., 1023M) -H, --si print sizes in powers of 1000 (e.g., 1.1G) -i, --inodes list inode information instead of block usage -k like --block-size=1K -l, --local limit listing to local file systems --no-sync do not invoke sync before getting usage info (default) --output[=FIELD_LIST] use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted. -P, --portability use the POSIX output format --sync invoke sync before getting usage info --total elide all entries insignificant to available space, and produce a grand total -t, --type=TYPE limit listing to file systems of type TYPE -T, --print-type print file system type -x, --exclude-type=TYPE limit listing to file systems not of type TYPE -v (ignored) --help display this help and exit --version output version information and exit Display values are in units of the first available SIZE from --block-size, and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and so on. FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page). GNU coreutils online help: <https://www.gnu.org/software/coreutils/> Full documentation <https://www.gnu.org/software/coreutils/df> or available locally via: info '(coreutils) df invocation'Related: df man page
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
