April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Disk usage 100% even after deleting files

Reducing Disk Usage When Linux complains that the disk is full, you will naturally try to delete some files or move them away from the filled-up partition. So you delete some large files, and check to see that the disk usage is much lower.
$ sudo du -shx /
7.8G    /
But df tells you that your disk usage is still 100%
$ df -h /
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/5a775102-c857-4007-8b5c-9137af04163f  9.8G  9.2G   93M 100%
Infuriating, isn’t it?

Mysterious Disk Usage

So du tells us the files are deleted and disk space is available, but df says the disk is still full. Both are actually correct – du tells you the actual usage, and df takes into account the file handles that point to the deleted data.

Don’t believe me? Run lsof and grep for “deleted”
$ lsof|grep deleted
deluged   25308           rmohan   15r      REG                8,1 1393377280 400069 /home/rmohan/Google.OS.v12.282.02.iso (deleted)
deluged   25308 25309     rmohan   15r      REG                8,1 1393377280 400069 /home/rmohan/Google.OS.v12.282.02.iso (deleted)
deluged   25308 25310     rmohan   15r      REG                8,1 1393377280 400069 /home/rmohan/Google.OS.v12.282.02.iso (deleted)
deluged   25308 25311     rmohan   15r      REG                8,1 1393377280 400069 /home/rmohan/Google.OS.v12.282.02.iso (deleted)
deluged   25308 25333     rmohan   15r      REG                8,1 1393377280 400069 /home/rmohan/Google.OS.v12.282.02.iso (deleted)

Aha,  we now know that deluged is the culprit that did not release the file handle of the deleted files. Simply kill/restart the process to free the file handle. After killing the deluged process, lsof shows that there is no longer deleted file handles floating around.

Let’s take a look at what df says now.
$ df -h
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/5a775102-c857-4007-8b5c-9137af04163f  9.8G  7.9G  1.4G  85% /
You have now successfully asked Linux to #givemebackmyspace

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>