Checking filesystem capacity on a Linux system helps prevent package installs, log writes, backups, and database workloads from failing when a mounted volume runs out of space. A quick df check shows total size, used space, available space, and percentage used for each mounted filesystem.

The df command reads mounted filesystem statistics from the kernel and reports usage for the filesystem that contains the path given on the command line. That makes df -h /var useful for checking the volume behind an application directory, but it also means df does not measure the size of /var itself.

The output often includes memory-backed filesystems such as tmpfs, removable devices, network mounts, or container mounts alongside local disks. Most df checks do not need sudo, but df -i is still worth using when new files cannot be created even though the Avail column still shows free space.

Steps to check disk space and usage with df in Linux:

  1. List the size, used space, available space, and usage percentage for every mounted filesystem with df -h.
    $ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    tmpfs           391M  1.6M  390M   1% /run
    /dev/nvme0n1p2   59G   18G   39G  31% /
    /dev/nvme0n1p1  1.1G  7.1M  1.1G   1% /boot/efi
    /dev/sdb1       200G   74G  116G  39% /data
    tmpfs           391M   24K  391M   1% /run/user/1000

    -h uses powers of 1024 for units such as M, G, and T. Use --si instead when powers of 1000 are required.

  2. Check the filesystem that contains a specific path such as /var.
    $ df -h /var
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/nvme0n1p2   59G   18G   39G  31% /

    The argument can be any file or directory path on the target filesystem. df reports the containing filesystem, not the size of the directory tree at that path.

  3. Show the filesystem type when it matters whether the path lives on ext4, xfs, btrfs, or another filesystem.
    $ df -hT /var
    Filesystem     Type  Size  Used Avail Use% Mounted on
    /dev/nvme0n1p2 ext4   59G   18G   39G  31% /

    The Type column helps distinguish local disk filesystems from memory-backed or network-backed mounts.

  4. Hide memory-backed pseudo-filesystems when only storage-backed mounts matter.
    $ df -h -x tmpfs -x devtmpfs
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/nvme0n1p2   59G   18G   39G  31% /
    /dev/nvme0n1p1  1.1G  7.1M  1.1G   1% /boot/efi
    /dev/sdb1       200G   74G  116G  39% /data

    Repeat -x to exclude other filesystem types such as overlay or squashfs when those appear in the output.

  5. Check inode usage for the same path when file creation fails even though free space still appears available.
    $ df -i /var
    Filesystem        Inodes   IUsed   IFree IUse% Mounted on
    /dev/nvme0n1p2   3899392  247381 3652011    7% /

    A filesystem can still reject new files when IUse% reaches 100 percent even if free blocks remain.