When you are managing a database server, running out of hard drive space is a catastrophic event that will instantly crash MySQL and corrupt data. You cannot wait for the system to throw an error; you must proactively monitor exactly how much storage space is available across all connected storage arrays. To instantly generate a mathematical breakdown of every single mounted partition and exactly how much data it contains, you must use the df (Disk Free) command.
How the df Command Works
Unlike the du (Disk Usage) command, which aggressively crawls through individual directories and calculates the size of every single text file, the df command ignores individual files completely. Instead, it talks directly to the Linux kernel and asks the filesystem how many raw blocks of storage space have been allocated to the hard drive partition as a whole. Because it skips the file crawl, the df command executes in a fraction of a millisecond, regardless of how large the hard drive is.
Making the Output Readable
If you run the df command by itself, the output is completely illegible to humans because it displays the disk capacity strictly in 1-Kilobyte block counts (e.g., 1024385902). To force the system to translate those massive numbers into readable Megabytes and Gigabytes, you must append the -h (Human-Readable) flag.
df -h
The terminal will instantly print a clean, organized table:
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 1.2M 797M 1% /run
/dev/sda1 110G 90G 15G 87% /
/dev/sdb1 500G 100G 400G 20% /mnt/backup_drive
This table tells you instantly that the primary operating system drive (/dev/sda1) is highly stressed, currently running at 87% capacity, while the secondary backup drive (/dev/sdb1) is completely healthy with 400 Gigabytes of free space remaining.
Filtering the Output
If your server has dozens of temporary virtual RAM disks (like tmpfs or udev) and hundreds of Docker container overlays, the df output can become chaotic and overwhelming.
To explicitly filter out all the virtual nonsense and only display physical, hardware-backed hard drives (like Ext4 or XFS partitions), you can append the -x (exclude) flag to strip out the virtual filesystems:
df -h -x tmpfs -x devtmpfs -x overlay
Alternatively, if you only care about a specific directory and want to know exactly which hard drive partition is hosting it, you can point the command directly at the path:
df -h /var/log/nginx/
The system will instantly calculate exactly which drive is responsible for that folder and report its exact storage capacity.