brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: lsof +L1 finds deleted files that still fill your disk

Disk
~/tips/lsof-deleted

sudo lsof +L1

Lists deleted files that a running program still holds open, which is why df stays full.

You delete a huge log, run df, and the disk is still full. That usually means a running program still has the file open, so Linux cannot free the space yet.

sudo lsof +L1

+L1 lists open files that have fewer than one link left on disk, which is another way of saying deleted but still open. The output shows the program, its process ID and the size.

Restarting that program closes the file and returns the space. Restart the service the clean way, with systemctl restart or docker restart.

The quick alternative is to empty the file through /proc/<pid>/fd/<number> without a restart. I would only do that if you know exactly what that program is, because it writes into a file that no longer has a name.

Further reading: lsof on GitHub

More Disk tips sudo e2freefrag /dev/sdb1 sudo smartctl -a --json /dev/sda | jq '.smart_status.passed' lsscsi -s udisksctl power-off -b /dev/sdX du -sh — .[!.]* * 2>/dev/null | sort -h All Disk tips (44) All topics

Link