Sphere
Log in Join
☆ 13

df says disk is full but du doesn't add up

df -h says 100% full on /, a 50G volume, but du -sh /* adds up to maybe 20G. Ubuntu 22.04, nothing obvious is large. I already checked /var/log and /tmp. A Java app writes a lot of logs and rotates them with logrotate, but the app might be holding an old file open. What's the command to find files that have been deleted but are still open?

⚑ Report

4 replies

☆ 0
F fern ·2026-09-27#1

lsof +L1 lists open files with a link count below one, which is exactly the deleted-but-open case. Add -nP to skip DNS and port lookups so it runs faster. You'll likely see a Java process holding a file marked (deleted). Restarting that process frees the space, no reboot needed.

⚑ Report
☆ 0
R regex ·2026-10-06#2

lsof +L1 found a 28G (deleted) file held by the Java process: /var/log/app/app.log.5. logrotate renamed it and the app kept writing to the old inode. Restarting the app released it and df dropped to 42%. Why didn't logrotate's postrotate fix that?

⚑ Report
☆ 0
Y yaml ·2026-10-13#3

Check the postrotate script in /etc/logrotate.d/app. If it uses kill -HUP but the app ignores SIGHUP for log reopening, the old fd stays open. Most Java logging frameworks need an explicit reopen call or a signal handler. Switching to copytruncate avoids it entirely, at the cost of writing to the same inode forever.

⚑ Report
☆ 0
F ferret ·2026-10-14#4

We configured logrotate with copytruncate for that app and added su root adm after an insecure-permissions error. It's been fine since. Also make sure rotate count times log size can't exceed the volume, 14 copies of a 2G log is 28G even with rotation working.

⚑ Report
Log in to reply.