Skip to content
Search

Df

lastmod 2025-02-17created 2014-01-106 edits

df (abbreviation for disk free) is a standard Unix computer program used to display the amount of available disk space for filesystems on which the invoking user has appropriate read access. df is usually implemented by reading the mtab file or using statfs.

df first appeared in Version 1 AT&T UNIX.

When df usage doesn't match the actual usage

This is often seen when a system has been used for a long time without rebooting.

In such cases,

  • checking with the du command shows little usage,
  • but checking with the df command shows almost no space left.

Cause

  1. A certain process opens a file descriptor,
  2. the file the file descriptor points to is deleted,
  3. the process still keeps the file descriptor open,
  4. and keeps writing to it.

You can check the status of files in the directory with the lsof command. (e.g. lsof /home shows only information related to the /home partition.)

Column information:

COMMAND     PID     USER   FD      TYPE     DEVICE   SIZE/OFF       NODE NAME

The value in the SIZE/OFF column is the file size. Find a line where this size is abnormally large, check its PID, then run lsof -p PID to identify the process. Kill it with kill -9 PID.

Summary

  • The du command is accurate because it reads the file system to display information, but it responds slowly when there is a lot of information to read.
  • The df command responds quickly, but in certain situations it may fail to reflect the actual usage.

You can find the offending process with lsof and terminate it with the kill command, but. If the system can be rebooted, rebooting is also an option.

See also

Favorite site

author Zer0 sitemap