Linux df command shows the disk is full but it is not

Problem

Sometimes you might run the df command and it shows the disk is full, but when you list the directory using the ls command or when you run the du command, you realize that the disk is not really full. In this case there might be a running process that has opened a file which has also been deleted. You cannot see the file using ls or du because the file has been deleted logically, but it hasn’t been deleted physically because a process is still using it and so it’s still using the disk space.

Solution

Deleted but open files are shown in the output of the lsof command. You can run the below command:

sudo lsof +L1

If there is any process that is using a deleted file, you can simply find it with this command. You can then kill the process and the file will be deleted from the disk physically. You should then be able to see the free space using the df command.

Leave a comment