Linux online course

How to Check Disk Space in Linux with df

Learn how to use Linux df to inspect filesystem capacity, used and available space, mount points, filesystem types, and inode usage.

The df command reports free and used space for mounted filesystems. It helps you determine whether a filesystem is running out of capacity, which mount point is affected, and whether the problem concerns data blocks or inodes.

This lesson assumes basic command-line navigation, Linux directory paths, and a general understanding of storage devices, filesystems, and mount points. For shell fundamentals, see Bourne Again Shell Bash.

What the df Command Reports

A filesystem is a formatted storage structure that organizes files and directories, such as ext4 or xfs. A filesystem may be stored on a partition, logical volume, removable device, network storage, or another kind of backing storage.

A mount point is the directory where Linux makes a filesystem available in the directory tree. For example, a separate filesystem might be mounted at /home. Files accessed below /home then reside on that filesystem rather than necessarily using the root filesystem.

Running df without options reports the mounted filesystems visible to the system, normally omitting some virtual or zero-block entries.

df

df reports space at the filesystem level. It does not tell you how much space one directory or file consumes. Use a directory-size tool such as du when you need to locate large content inside an affected mount point.

Reading Default df Output

A typical result resembles the following. Exact device names, sizes, and units vary by system.

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda2       10240000  5242880   4997120  52% /
/dev/sda3       20480000  7340032  13139968  36% /home

The default unit is often 1K blocks, depending on the implementation and environment. This is precise for command output but less convenient to read mentally than gigabytes or terabytes.

Filesystem/device — The filesystem source. It may be a device file such as /dev/sda2, a logical volume, a network source, or another filesystem identifier. A device file is a special path, often under /dev, representing a storage device or logical volume.

Size or total blocks — The total filesystem capacity, expressed in the selected unit.

Used — Capacity currently allocated to stored data and filesystem metadata.

Available — Capacity available for additional allocations, subject to filesystem rules and reserved blocks.

Use% — The percentage of filesystem capacity currently used. A value close to 100% indicates a capacity warning.

Mounted on — The mount point where the filesystem is attached to the Linux directory hierarchy.

Mount points are especially important when diagnosing space problems. The rows for /, /home, and /var may refer to different filesystems, each with independent capacity.

Use Human-Readable Units with df -h

The -h option displays sizes with readable suffixes such as K, M, G, and T.

df -h

Instead of comparing large block counts, you may see output similar to this:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        9.8G  5.0G  4.8G  52% /
/dev/sda3         20G  7.1G   13G  36% /home

df -h is usually the preferred form for interactive inspection. Use the Use% column to find heavily used filesystems, then use Mounted on to identify where that filesystem is attached.

Useful df Options

-h — Display capacity in human-readable units. Example: df -h.

-t TYPE — Show only filesystems whose type matches TYPE. Example: df -t ext4.

-i — Report inode usage instead of ordinary byte capacity. Example: df -i.

-a — Include all filesystem entries, including entries normally omitted, pseudo-filesystems, and entries with zero blocks. Example: df -a.

PATH arguments — Report the filesystem containing each supplied file or directory. Example: df /home.

Filter by Filesystem Type

The -t option filters the result by filesystem type. For example, to view mounted ext4 filesystems only:

df -t ext4

Replace ext4 with the type you need. Common types include:

  • ext4 — A widely used Linux filesystem.
  • xfs — A high-performance filesystem commonly used on Linux servers.
  • btrfs — A filesystem with features such as snapshots and checksums.
  • tmpfs — A temporary filesystem generally backed by memory or swap.
  • vfat — Commonly used for firmware and removable-media partitions.
  • nfs — A network filesystem.

Filtering is useful when a machine has many mounts and you want to focus on one storage class, such as local ext4 filesystems or network-mounted nfs filesystems.

Check Inode Usage with df -i

An inode is a filesystem metadata structure representing a file or directory. It tracks attributes and the locations of the file's data blocks. Every file and directory requires an inode.

df -i

The output includes inode totals, used inodes, available inodes, and inode usage percentage. The exact headings may differ slightly between implementations, but the key value is the inode Use%.

Filesystem      Inodes  IUsed   IFree IUse% Mounted on
/dev/sda2       655360  654900     460  100% /
/dev/sda3      1310720  120000 1190720    9% /home

A filesystem can have free byte capacity while having no free inodes. In that situation, it cannot create more files or directories even though df -h appears to show available space. Workloads that create many small files, such as caches, mail queues, temporary data, or build trees, are common causes of inode exhaustion.

Show All Filesystem Entries with df -a

The -a option includes filesystem entries that are normally omitted, including pseudo-filesystems and entries with zero blocks.

df -a

A pseudo-filesystem is a virtual filesystem supplied by the kernel or system runtime rather than ordinary disk-backed storage. Examples include procfs, commonly visible at /proc, and devpts, commonly associated with pseudo-terminals under /dev/pts.

Entries under /proc, /sys, and /dev can appear when using -a. They generally do not represent ordinary persistent disk capacity, so do not treat every row as a physical disk or partition.

Check the Filesystem for a Specific Path

Supply one or more files or directories as arguments to ask which filesystem contains them.

df /home

This reports the filesystem on which /home resides. It can show whether /home is a separate mount point or simply a directory within the root filesystem.

You can check several paths in one command:

df -h / /home /var

Multiple paths may resolve to the same filesystem. They may also resolve to different filesystems if separate mounts are attached below those directories. This matters because a full /var filesystem does not necessarily mean that the root filesystem or /home filesystem is full.

Understand Disk-Full Conditions

Start with:

df -h

Look for a high value in Use%. The Mounted on column identifies the affected filesystem. For a particular path, use:

df -h /path/to/check

Low available blocks and zero available inodes are different conditions:

Byte capacity is exhausted — The ordinary df -h output shows a very high Use% and little available space. New writes may fail because the filesystem cannot allocate more data blocks. Next, use du or another directory-size tool to find large content within the affected mount point.

Inodes are exhausteddf -i shows an inode usage percentage of 100% or nearly 100%, even though df -h may show free bytes. New files and directories cannot be created. Locate and remove or consolidate excessive small files, then check df -i again.

Available space shown to non-root users can differ from total free capacity because some filesystems reserve blocks for privileged system use. Reserved blocks can allow essential system processes to continue operating even when ordinary users see little or no available space.

Remember that df reports filesystem allocation. It does not identify which individual directory tree consumed the space, and its totals may not correspond directly to the apparent sizes of files in a directory.

Practical Troubleshooting

A filesystem is nearly full

  1. Run df -h.
  2. Find the row with a high Use% value.
  3. Read the Mounted on column to identify the affected mount point.
  4. Use du within that mount point to locate large directories or files.

File creation fails despite free space

  1. Run df -i, or check the affected path directly with df -i /path.
  2. Look for an inode usage value of 100%.
  3. Search for workloads creating excessive numbers of small files.
  4. Remove unnecessary files or consolidate them, then verify inode availability again.

The space for /home does not match the root report

  1. Run df -h /home.
  2. Compare the reported filesystem and mount point with the row for /.
  3. If the filesystem differs, investigate the capacity of the filesystem reported for /home rather than assuming it shares root capacity.

df shows unfamiliar entries

If you used df -a and see entries under /proc, /sys, or /dev, remember that these are often pseudo-filesystems. Focus routine disk-space investigations on relevant persistent mount points.

Quick Reference

df                         # Default mounted-filesystem report
df -h                      # Human-readable capacity
df -t ext4                 # Only ext4 filesystems
df -i                      # Inode usage
df -a                      # Include normally omitted entries
df /home                   # Filesystem containing /home
df -h / /home /var         # Several paths in readable units

Related Linux Storage Commands