df — Disk Free & Filesystem Usage
df (disk free) is a standard Linux command that reports block usage and inode statistics for every mounted filesystem on your system. It tells you how much space is available, how much is used, and — critically — where each filesystem is mounted. Use it to check your WordPress root partition, log volume, backup mount, and database disk in a single command, and to catch a full disk before it takes your site offline.
Overview
df reports available and used space on mounted filesystems in a single view. Use it to confirm whether your WordPress root, log partition, backups mount, or database volume is approaching capacity before you hit "No space left on device". While du helps you find which directory is consuming space, df tells you how much space is left on the underlying filesystem.
- Core Function: Query mounted filesystem block and inode statistics.
- Primary Benefit: Instant, system-wide disk capacity view — bytes and inodes in one command.
- Where to Use: Routine VPS health checks, incident response, and cron-driven monitoring.
- Key Insight: Passing a
PATHtodfdoes not report the file's size. It reports the filesystem that contains that path.
System Check
which df # Expected: /bin/df
df --version # Recommended: GNU coreutils 8.x+
Benefits
- Instant capacity visibility — a single command shows every mounted disk's free space.
- Inode awareness —
df -iexposes inode exhaustion thatdf -handduboth miss. - Scriptable output — POSIX (
-P) and--outputmodes make parsing reliable in automation. - Partition-level clarity — confirms whether WordPress, logs, backups, and databases live on separate mounts or share one disk.
- Zero dependencies — part of GNU coreutils; available on every Linux VPS by default.
Best Practices
- Default to
df -hfor every routine check — human-readable units prevent misreading raw blocks. - Always check inodes too — run
df -ialongsidedf -hon busy WordPress sites where cache plugins generate thousands of small files. - Alert at 80% — set a monitoring threshold at 80% (
Use%) so you have time to act before reaching 100%. - Exclude virtual filesystems in scripts — use
-x tmpfs -x devtmpfsto keep output focused on real disks. - Prefer
--outputfor dashboards — select only the columns you need instead of parsing fixed-width text. - Pair with
du— usedf -hto identify the full filesystem, thendu -h --max-depth=1inside it to find the culprit directory. - Use
-Pin cron scripts — POSIX format guarantees stable column positions across differentdfversions. - Check backup mounts before jobs run —
df -h /mnt/backupsconfirms the target has space before a backup starts.
Tips & Strategy
df -h looks fine but uploads still failInode exhaustion is the hidden culprit. Plugins and caches that generate many small files (thumbnails, transients, session files) can consume every available inode long before bytes run out. Always run df -i in parallel with df -h during incident triage.
df -h # Step 1 — which filesystem is running out of bytes?
df -i # Step 2 — is it actually inodes?
If step 1 looks fine but step 2 shows 90%+ usage, pivot to clearing cache or session files.
--output to build minimal monitoring snapshotsdf -h --output=target,pcent,avail
Output is narrow enough to paste into a Slack incident thread or log to a file without noise.
tmpfs and devtmpfs stacks can inflate the line count. Remove them:
df -h -x tmpfs -x devtmpfs
-h and -H-h uses powers of 1024 (GiB). -H uses powers of 1000 (GB). Cloud provider dashboards typically report in GB (decimal), so use -H when comparing against your provider's metrics panel.
Syntax & Options Reference
Core Syntax
df [OPTION]... [FILE]...
OPTION— controls display format, filtering, and output columns.FILE— optional path(s). If omitted,dfreports all mounted filesystems. When a path is provided,dfreports the filesystem containing that path, not the path itself.
Complete Options Table
| Option | Long Form | Description | Example |
|---|---|---|---|
-h | --human-readable | Print sizes in powers of 1024 (K, M, G, T) | df -h |
-H | --si | Print sizes in powers of 1000 (kB, MB, GB) | df -H |
-i | --inodes | Show inode usage instead of block usage | df -i |
-T | --print-type | Show filesystem type column | df -T |
-t TYPE | --type=TYPE | Include only filesystems of TYPE | df -t ext4 -h |
-x TYPE | --exclude-type=TYPE | Exclude filesystems of TYPE | df -x tmpfs -h |
-a | --all | Include pseudo, duplicate, and inaccessible filesystems | df -a -h |
-l | --local | Limit output to local filesystems only | df -l -h |
-P | --portability | POSIX/portability output format (script-safe) | df -P |
--total | --total | Add a final grand-total line | df -h --total |
--output[=LIST] | --output=LIST | Select specific columns (see list below) | df --output=source,size,pcent |
--sync | --sync | Invoke sync before getting usage info | df --sync -h |
--no-sync | --no-sync | Do not invoke sync before getting usage (default) | df --no-sync -h |
-B SIZE | --block-size=SIZE | Scale sizes by SIZE before printing | df -BM |
--direct | --direct | Use direct stat() call for NFS mounts | df --direct |
--output Column Names
When using --output, you can mix and match from the following column identifiers:
| Column Name | Description |
|---|---|
source | Device or source of the filesystem |
fstype | Filesystem type (ext4, xfs, tmpfs…) |
itotal | Total number of inodes |
iused | Number of used inodes |
iavail | Number of free inodes |
ipcent | Inode usage percentage |
size | Total disk space |
used | Disk space used |
avail | Disk space available |
pcent | Usage percentage |
file | The file name argument if specified |
target | Mount point |
Example — select all meaningful columns:
df -h --output=source,fstype,size,used,avail,pcent,target
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 50G 10G 40G 20% /
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
Understanding PATH in df
| PATH Type | Example | What It Resolves To | WordPress/VPS Use Case |
|---|---|---|---|
| No path (default) | df -h | All mounted filesystems | Routine server health check |
| Absolute directory | df -h /var/www/html | Filesystem containing that directory | Check WordPress root partition |
| Relative directory | cd /var/www/html && df -h . | Same as absolute, from current dir | When already inside the site |
| File path | df -h /var/www/html/wp-config.php | Filesystem containing the file | Confirm free space where WP lives |
| Mounted backup volume | df -h /mnt/backups | Reports a separate device/mount | Ensure backup disk has space |
| Multiple paths | df -h / /var/www/html /var/log | Shows each path's filesystem | Compare partitions quickly |
| Deep nested path | df -h /var/www/html/wp-content/uploads/2025 | Still maps back to the same mount | Check uploads space without leaving WP |
Practical Use Cases
1. Human-readable disk usage
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 40G 20% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
Use case: Default routine check — easier to read than raw block numbers.
2. Check inode usage
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 3276800 120000 3156800 4% /
Use case: Diagnose inode exhaustion — common when caches or session handlers generate thousands of tiny files.
3. Show filesystem type
df -T -h
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 50G 10G 40G 20% /
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
Use case: Confirm filesystem type before resizing a partition or applying filesystem-specific tuning.
4. Filter to ext4 partitions only
df -t ext4 -h
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 50G 10G 40G 20% /
Use case: Focus on real disk-backed partitions and ignore virtual filesystems.
5. Exclude tmpfs (and other virtual FS)
df -h -x tmpfs -x devtmpfs
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 40G 20% /
Use case: Keep output focused on real disks — especially useful in scripts and monitoring output.
6. Local filesystems only
df -h -l
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 40G 20% /
Use case: Suppress NFS or remote mounts so you focus on the VPS's own disk.
7. POSIX format (script-safe)
df -P /var/www/html
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda1 52403200 10485760 41917440 20% /
Use case: Safe, stable column format for parsing in shell scripts — column positions are guaranteed by the POSIX standard.
8. Grand total row
df -h --total
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 40G 20% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
total 52G 10G 42G 19%
Use case: Get an at-a-glance aggregate of all mounted disk space.
9. Custom column selection
df -h --output=source,fstype,size,used,avail,pcent,target
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 50G 10G 40G 20% /
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
Use case: Precise, readable reporting for dashboards and incident logs.
10. Minimal monitoring snapshot
df -h --output=target,pcent,avail
Mounted on Use% Avail
/ 20% 40G
/dev/shm 0% 2.0G
Use case: Narrow snapshot suitable for Slack, PagerDuty notes, or a simple monitoring script.
11. Check the partition hosting WordPress
df -h /var/www/html
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 40G 20% /
Use case: Confirm which partition your WordPress site lives on and how much space remains.
12. Check backup volume before running a backup job
df -h /mnt/backups
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 200G 50G 150G 25% /mnt/backups
Use case: Verify backup storage has sufficient headroom before kicking off a large backup.
13. Monitor the logs partition
df -h /var/log
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 20G 30G 40% /
Use case: Detect log growth before it fills the disk and kills PHP-FPM or MySQL.
14. Monitor the database volume
df -h /var/lib/mysql
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 100G 30G 70G 30% /var/lib/mysql
Use case: Monitor database storage separately if MySQL or MariaDB is on its own mount.
15. Detect near-full disk (critical alert scenario)
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 49G 1.0G 98% /
Use case: Trigger an immediate response — 98% usage means WordPress will fail to write uploads, logs, and sessions within minutes.
16. Detect inode exhaustion
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 3276800 3276700 100 100% /
Use case: File uploads fail even though df -h shows free space. 100% IUse% is the smoking gun.
17. Include all pseudo and inaccessible filesystems
df -h -a
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 40G 20% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
udev 2.0G 0 2.0G 0% /dev
Use case: Debug special or hidden mounts that do not appear in a normal df -h.
18. Custom block size output
df -BM /var/www/html
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/sda1 51200M 10240M 40960M 20% /
Use case: When you need sizes in a specific unit (MB, GB) for scripting without relying on awk.
19. Sync before reporting
df -h --sync
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 10G 40G 20% /
Use case: Forces a filesystem sync first — useful when you need df to reflect very recent writes as accurately as possible.
20. Report across multiple critical paths
df -h --output=source,fstype,size,used,avail,pcent,target /var/www/html /var/log /var/lib/mysql /mnt/backups
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 50G 10G 40G 20% /
/dev/sdb1 ext4 200G 50G 150G 25% /mnt/backups
Use case: Single-command status check across every partition that matters for WordPress operations.
df vs du
| Tool | Level | Answers | Best Used For |
|---|---|---|---|
df | Filesystem | "How much space is left on this partition?" | Capacity monitoring, alerts |
du | Directory tree | "Which folder is consuming the space?" | Finding the culprit after df warns you |
Recommended triage sequence:
df -h— identify which filesystem is filling up.df -i— rule out inode exhaustion.du -h --max-depth=1 /mount/point— drill into the filesystem to find the large directory.
Hands-On Practice
Quick Lab (20 Exercises)
- Run
df -hand identify the filesystem with the highestUse%. - Run
df -iand check whether any filesystem has high inode usage. - Run
df -h /var/www/htmland confirm which mount point hosts WordPress. - Run
df -h /var/logand note whether logs share the root partition. - Run
df -h /mnt/backupsand confirm backups are on a separate device (or not). - Run
df -T -hand note the filesystem type for/. - Run
df -x tmpfs -hand compare the output to plaindf -h. - Run
df -t ext4 -h(or your FS type) and observe how filtering changes output. - Run
df -P /var/www/htmland compare column headings to the default output. - Run
df -h --totaland verify the grand total row. - Run
df --output=source,size,used,avail,pcent,target -hand note readability. - Run
df -h .inside your WordPress root and confirm it matchesdf -h /var/www/html. - Run
df -h /var/www/html/wp-config.phpand explain why it shows the filesystem, not the file size. - Run
df -Hand note how numbers differ fromdf -h. - Run
df -h /tmpand check whether it is on the same filesystem as/. - Run
df -i /var/www/htmland interpret inode usage for the WordPress filesystem. - Run
df -h /and recordAvailas your current free-space baseline. - Run
df -h /var/lib/mysqland determine whether database storage is on a separate mount. - Run
df -BM /var/www/htmland compare the block sizes against the-houtput. - Pair the result with
du: choose a mount that is filling up, then rundu -h --max-depth=1inside it.
Task: Build a Monitoring One-Liner
Write a single df command that outputs only the mount point, usage percentage, and available space for /var/www/html, /var/log, and /mnt/backups in a format suitable for pasting into a Slack message.
Solution
df -h --output=target,pcent,avail /var/www/html /var/log /mnt/backups
Mounted on Use% Avail
/ 20% 40G
/ 40% 30G
/mnt/backups 25% 150G
Mini Quiz
- What is the difference between
dfanddu? - Which
dfflag shows inode usage instead of block usage? - When would you choose
df -Hinstead ofdf -h? - Why can file uploads fail even if
df -hshows free space? - What does passing a file path to
dfactually report? - Which option produces POSIX-safe output for use in shell scripts?
- How would you exclude
tmpfsanddevtmpfsfromdfoutput? - What does
--output=target,pcent,availproduce and why is it useful?
Cheat Sheet
df -h # Human-readable (1024-based)
df -H # Human-readable (1000-based / decimal)
df -i # Inode usage
df -T -h # Show filesystem type
df -t ext4 -h # Only ext4 partitions
df -x tmpfs -x devtmpfs -h # Exclude virtual filesystems
df -l -h # Local filesystems only
df -P /var/www/html # POSIX output for scripting
df -h --total # Grand total row
df -BM /var/www/html # Output in MB units
df --output=source,fstype,size,used,avail,pcent,target -h
df -h --output=target,pcent,avail # Minimal monitoring snapshot
df -h /var/www/html # WordPress root partition
df -h /var/log # Logs partition
df -h /mnt/backups # Backup mount
df -h /var/lib/mysql # Database partition
df -a -h # All filesystems including pseudo
df --sync -h # Sync before reporting