--- title: df โ€” check available disk space date: 2026-10-18 time: 12:00 model: admin category: programs author_type: human summary: Command that checks total, used, and available capacity and usage percentage for each mounted filesystem. Includes practical inspection procedures and examples. tags: program, File and disk management, df --- **๐Ÿ’ฌ "df Command"** While du shows usage **by folder**, df shows total, used, and available capacity **by mounted filesystem (partition)**. It is one of the first commands run during server health checks. Because the default output uses 1K blocks and is hard to read, always add `-h` in practice. - **Concept**: Check disk usage by filesystem. See at a glance which mount point is at risk. - **Left column**: `Filesystem` โ€” The name of the mounted device (e.g. /dev/vda1) or virtual filesystem (tmpfs). - **Right column**: `Mounted on` โ€” The path where the device is attached. This is where issues actually occur. - **Size / Used / Avail**: Total / used / remaining capacity. If Avail is close to 0, writes will fail soon. - **Use%**: Usage percentage. If it exceeds 90%, review log rotation and cleanup. ## Commonly Used Options | Option | Description | | --- | --- | | -h | Output in human-readable units (K/M/G) | | -T | Also display the filesystem type (ext4, xfs, tmpfs, etc.) | | -i | Show inode usage instead of capacity (diagnose file count exhaustion) | | -x tmpfs | Exclude virtual filesystems such as tmpfs | | --total | Add a total summary line at the bottom | ## 3 Essential Command Combinations - `df -h` โ€” Check per-mount capacity in readable units (most basic) - `df -hT -x tmpfs -x devtmpfs` โ€” View only real disks together with their filesystem type - `df -ih /var` โ€” Check inode exhaustion when capacity remains but files cannot be created **๐Ÿ’ฌ "Give an example of the process of narrowing down the cause"** Common situations on production servers are organized below in the order they typically occur. ### Step 1 ยท Identify Which Mount Has a Problem Look at all mounts and find the point with high usage. ``` df -hT -x tmpfs ``` ### Step 2 ยท Find the Culprit Inside It Move to the problem mount and sort usage by folder in descending order. ``` cd /var && du -sh * | sort -h | tail -5 ``` ### Step 3 ยท Verify After Cleanup Clear logs or delete old backups, then check again. If the numbers remain the same after deletion, a process is still holding the file. ``` df -h /var && lsof +L1 | head ``` ## How It Is Used in Practice ### 1. Capacity Check Before Deployment **Situation** โ€” Before deploying a new release, you need to check that the target partition has enough free space. ``` df -h /var /data && df -hT -x tmpfs ``` **Result** โ€” Check whether Avail is sufficiently larger than the release size (e.g. 2G). If usage is 90% or more, stop the deployment and clean up first. **Point** โ€” Putting a df check at the beginning of the deployment script can prevent disk shortage incidents. ### 2. Capacity Remains but File Creation Fails **Situation** โ€” Free space is 40%, but new log files cannot be created and "No space left on device" appears. ``` df -ih /var ``` **Result** โ€” If IUse% is 100%, inodes are exhausted. You need to clean up directories that contain many small files. **Point** โ€” This is a typical failure missed if you only check capacity (%). Include df -ih in your checks. ## Things to Watch Out For - Even if Avail is 0, 5% reserved blocks remain for root, allowing only the administrator to use it briefly. - When Use% exceeds 90%, system behavior starts to become unstable. Set up threshold alerts. - For network filesystems such as NFS, df may appear to hang because responses are slow. - tmpfs and overlay use memory/images, so they differ from actual disk capacity. Exclude them with -x. ## Actual Execution Output This is the result of checking per-mount capacity and usage in readable units. ![df command execution result: capacity and usage by filesystem](https://games.aidebatehub.com/assets/df-demo.png) A production server --- Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/df.html This file is an auto-generated Markdown twin of the DevHub document.