Monitoring disk space on a Linux system prevents services from failing when partitions run out of free space and log or data writes start to error. Regular checks keep enough headroom for updates, backups, and application data growth across all mounted filesystems.

The df utility queries kernel filesystem statistics to display each mount point’s total size, used space, available space, and usage percentage. Output combines information for physical disks, partitions, and virtual filesystems, making it suitable for a quick overview of how storage is allocated and consumed.

Separating directories such as /var and /home into dedicated partitions improves isolation but also increases the chance that a single partition fills up while others still have free space. df focuses on filesystem-level usage rather than individual files or folders, so it pairs with tools like du in other workflows for locating large directories.

Steps to monitor disk space and free space in Linux:

  1. Open a terminal on the Linux system.
  2. Display disk and partition size, usage, and available space for all mounted filesystems using df.
    $ df
    Filesystem      1K-blocks     Used  Available Use% Mounted on
    overlay        1917548740 12421508 1807688184   1% /
    tmpfs               65536        0      65536   0% /dev
    shm                 65536        0      65536   0% /dev/shm
    tmpfs             4012424      444    4011980   1% /run
    tmpfs             4012424        0    4012424   0% /run/lock
    /dev/vda1      1917548740 12421508 1807688184   1% /etc/hosts
    /dev/loop0         996780       24     927944   1% /mnt/data
  3. Present usage and available space in a human-readable format using df -h.
    $ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    overlay         1.8T   12G  1.7T   1% /
    tmpfs            64M     0   64M   0% /dev
    shm              64M     0   64M   0% /dev/shm
    tmpfs           3.9G  444K  3.9G   1% /run
    tmpfs           3.9G     0  3.9G   0% /run/lock
    /dev/vda1       1.8T   12G  1.7T   1% /etc/hosts
    /dev/loop0      974M   24K  907M   1% /mnt/data

    Unit changed to M (Megabyte), G (Gigabyte), T (Terabyte) etc instead of in blocks.

  4. Hide temporary and virtual filesystems to focus on real disks by excluding tmpfs and devtmpfs.
    $ df -h -x tmpfs -x devtmpfs
    Filesystem      Size  Used Avail Use% Mounted on
    overlay         1.8T   12G  1.7T   1% /
    /dev/vda1       1.8T   12G  1.7T   1% /etc/hosts
    /dev/loop0      974M   24K  907M   1% /mnt/data

    Excluding pseudo-filesystems makes it easier to spot partitions that are actually at risk of filling up.

  5. Display disk usage information for a specific partition by device name.
    $ df -h /dev/loop0
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/loop0      974M   24K  907M   1% /mnt/data
  6. Display disk usage information for a specific mount point.
    $ df -h /mnt/data
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/loop0      974M   24K  907M   1% /mnt/data
  7. Show disk usage in a variety of formats and with filesystem type details using different df options.
    $ df -hT
    Filesystem     Type     Size  Used Avail Use% Mounted on
    overlay        overlay  1.8T   12G  1.7T   1% /
    tmpfs          tmpfs     64M     0   64M   0% /dev
    shm            tmpfs     64M     0   64M   0% /dev/shm
    tmpfs          tmpfs    3.9G  444K  3.9G   1% /run
    tmpfs          tmpfs    3.9G     0  3.9G   0% /run/lock
    /dev/vda1      ext4     1.8T   12G  1.7T   1% /etc/hosts
    /dev/loop0     ext4     974M   24K  907M   1% /mnt/data
  8. Check inode usage to detect situations where a filesystem has free space but no free inodes.
    $ df -i
    Filesystem        Inodes  IUsed     IFree IUse% Mounted on
    overlay        121782272 285452 121496820    1% /
    tmpfs            1003106    403   1002703    1% /dev
    shm              1003106      1   1003105    1% /dev/shm
    ##### snipped #####

    High inode usage can block new file creation even when size-based usage appears low.

  9. Limit output to key columns such as source, size, usage, and mount point using df –output.
    $ df -h --output=source,size,used,avail,pcent,target -x tmpfs -x devtmpfs
    Filesystem      Size  Used Avail Use% Mounted on
    overlay         1.8T   12G  1.7T   1% /
    /dev/vda1       1.8T   12G  1.7T   1% /etc/hosts
    /dev/loop0      974M   24K  907M   1% /mnt/data
  10. Explore additional df command options to better monitor disk size and usage in Linux.
    $ df --help
    Usage: df [OPTION]... [FILE]...
    Show information about the file system on which each FILE resides,
    or all file systems by default.
    
    Mandatory arguments to long options are mandatory for short options too.
      -a, --all             include pseudo, duplicate, inaccessible file systems
      -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                               '-BM' prints sizes in units of 1,048,576 bytes;
                               see SIZE format below
      -h, --human-readable  print sizes in powers of 1024 (e.g., 1023M)
      -H, --si              print sizes in powers of 1000 (e.g., 1.1G)
      -i, --inodes          list inode information instead of block usage
      -k                    like --block-size=1K
      -l, --local           limit listing to local file systems
          --no-sync         do not invoke sync before getting usage info (default)
          --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                                   or print all fields if FIELD_LIST is omitted.
      -P, --portability     use the POSIX output format
          --sync            invoke sync before getting usage info
          --total           elide all entries insignificant to available space,
                              and produce a grand total
      -t, --type=TYPE       limit listing to file systems of type TYPE
      -T, --print-type      print file system type
      -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
      -v                    (ignored)
          --help     display this help and exit
          --version  output version information and exit
    
    Display values are in units of the first available SIZE from --block-size,
    and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
    Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
    
    The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
    Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000).
    Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
    
    FIELD_LIST is a comma-separated list of columns to be included.  Valid
    field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
    'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).
    
    GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
    Report any translation bugs to <https://translationproject.org/team/>
    Full documentation <https://www.gnu.org/software/coreutils/df>
    or available locally via: info '(coreutils) df invocation'

    Related: df man page

Discuss the article:

Comment anonymously. Login not required.