Tuesday, May 15, 2007

Difference between df and du

Under Linux / UNIX we have the du and the df command. The du command display disk usage statistics and the df command is to display free disk space.

In some cases it is possible that there is a difference between the outcome of df and du. In 99.9% of the cases this is caused by a lock on the file system. Meaning, if an application opens a file or files and an other application deletes these files while they are opened they will still be calculated by df.

The df command calculates this by looking at the inode table and the inode table has not yet released those files, meaning that, according to the inode table, the files are still using space on the disk.

Generally the solution is to stop/start the process that has a lock on those non existing files and the results returned by df and du will be the same again.

1 comment:

Vahid Pazirandeh said...

To find the locked files type 'lsof +L1'