Knowledge Base

When df and du disagree because a deleted ISO is still mounted

Author: DEWOLF.IT

Trace missing disk space to an unlinked ISO held open by a loop device.

This English edition covers the main steps. See the Dutch article for the full detail and examples.

Why the totals differ

df reports blocks allocated on a filesystem. du totals directory entries it can traverse. A process or kernel reference can keep storage allocated after the pathname has been unlinked.

Trace the filesystem and mounts

Check the filesystem mounted at the path and compare it with a same-filesystem walk. Look for deleted open files, but also inspect mount and loop devices if ordinary process handles do not explain the discrepancy.

df -hT /path
du -x -h --max-depth=1 /path
findmnt -T /path
sudo lsof +L1
lsblk -f
losetup -a

The case of the deleted ISO

In this case an ISO had been deleted from the directory while still attached to a mounted loop device. The kernel retained the file's blocks. Once the actual mount was identified, it could be unmounted in a controlled way and its loop association released where needed. A fresh df reading confirmed the space returned.

Identify consumers before unmounting. Compare filesystem accounting again after the change.