VPS Tutorials
Why df and du Show Different Disk Usage on Linux
When df shows a full VPS disk and du finds much less, check the same mount and use lsof to see which process still holds a deleted file open.

Your VPS reports 96% disk usage in df -h, but du finds only about half the data. If the problem started after you removed a large log, check lsof +L1 for a process that still has the file open. The name disappears from the directory tree immediately. The file still takes up space until the last open file descriptor is closed. Linux unlink manual
Start at the directory where a write failed. Replace /var/log if the alert came from another path. The mount point is in the Mounted on column from df and the TARGET column from findmnt.
df -hT /var/log
findmnt -T /var/log -o TARGET,SOURCE,FSTYPE
Suppose the target is /var. Set mount_point to the actual target on your server, which may be /. Both commands below report bytes. Compare df's Used column with the du total for the mount point itself. That total already includes the child directories.
mount_point=/var
df -B1 --output=source,used,avail,target "$mount_point"
sudo du -x -B1 --max-depth=1 -- "$mount_point" | sort -n | tail -n 12
df reads the filesystem's allocation totals. du adds up blocks used by reachable files. Passing the directory itself includes hidden entries, and -x skips other filesystems mounted below it. Look for permission or I/O errors before relying on the total. The scan still walks subdirectories, even with --max-depth=1. If the tree is large, check for open files before running a full scan during peak traffic. GNU df manual · GNU du manual · findmnt manual
lsof +L1 selects open files with zero links. Use +aL1 with the mount point to narrow the list to that filesystem. The -s option requests file size.
sudo lsof -nP -s +aL1 "$mount_point"
Look for regular files (REG) with NLINK equal to 0 and a size that could explain the gap. Record COMMAND, PID, FD, DEVICE, and NODE. If several processes hold the same device and inode pair, count the file once. For an FD shown as 12w, use 12 as the descriptor number. lsof manual
This example uses PID 2674 and descriptor 12. Replace both values with the values from the live output. Check which service owns the process and where the descriptor points. stat -L follows the descriptor. Its block count times the block unit gives the allocated size, which is often much smaller than the logical size of a sparse file.
ps -p 2674 -o pid,ppid,user,comm
sudo readlink -- /proc/2674/fd/12
sudo stat -Lc 'size=%s blocks=%b unit=%B inode=%i' -- /proc/2674/fd/12
If the path is gone, repeat lsof to get the current PID and FD. A process may have closed the file while you checked. For containers, run the check from the host environment that can see the affected mount and the process.
For a disposable application log, use the service's documented log-reopen action. On a standard system Nginx instance, sudo nginx -s reopen asks the master process to reopen its logs. Confirm the instance, configuration and log path first. A custom installation can use a different binary, configuration file or PID path. During scheduled rotation, the usual Nginx sequence is to rename the old logs, then ask the master to reopen them. For an app that cannot reopen its log, logrotate's copytruncate may be an option. It can miss writes that arrive between the copy and the truncate. Nginx log rotation · logrotate manual
When the application has no reopen mechanism, schedule a restart of the identified service when it can tolerate an interruption. Handle databases, audit records and accidentally removed business data through the application's backup or recovery procedure before closing a remaining descriptor.
df -hT "$mount_point"
sudo lsof -nP -s +aL1 "$mount_point"
Check that the old device and inode pair disappears from lsof, Avail rises on the same mount, and the service passes a health check. If the application writes a new log, confirm a fresh entry lands in the current file.
This test used an isolated APFS disk image on macOS 15.8.3. A process wrote and held open a 24 MiB file. After its name was removed, the descriptor still read the contents and the link count was zero. df reported 24,576 KiB less used space only after the descriptor closed. The Linux commands above were checked against their manuals.
| State | df used (KiB) | du visible (KiB) |
|---|---|---|
| File written and open | 24,596 | 24,576 |
| Name removed, descriptor open | 24,596 | 0 |
| Descriptor closed | 20 | 0 |
| What you see | Where to look |
|---|---|
| Usage changed after mounting a backup or data disk | Run findmnt -R -M "$mount_point". A child mount can hide old data in the original filesystem. Inspect the underlying directory during maintenance or in an isolated environment. |
The app gets No space left on device despite free bytes | Run df -i "$mount_point". If the inode count is exhausted, look for directories with many small files. |
On ext4, Size minus Used is larger than Avail | Check reserved blocks with tune2fs -l against the confirmed ext4 device. |
| A Btrfs volume frees little space after deletion | Check btrfs filesystem usage and snapshot retention. A snapshot may still reference the blocks. |
For a recurring log problem, review log rotation and retention. If the inode count is the bottleneck, follow the inode exhaustion guide. If your live data still needs more room, check the VPS disk expansion steps for your filesystem.
Next step: compare the actual plans
Filter the listed plans by budget, specifications and region, or start with a buying guide.