A Linux server can report that its root filesystem is full even after an administrator deletes large files. In another case, a monitoring alert may show almost no free space while a directory scan appears to account for only a fraction of the disk. These situations are common because filesystem capacity, directory usage, inodes, deleted-but-open files, mount points and container storage are different things. Running rm against random log directories is not a diagnosis and can destroy evidence or remove data an application still needs.
This guide provides a safe workflow for Linux disk space troubleshooting. It starts with read-only checks, identifies the most common causes of df and du disagreement, and explains how to reclaim space without deleting active data or breaking production services.
Start by identifying the filesystem that is full
First determine whether the alert concerns bytes, inodes or a particular mount. df reports filesystem capacity and availability; it does not explain which directory is responsible. Use human-readable output and include filesystem types so that separate mounts are visible.
df -hT
df -ih
findmnt -T /
lsblk -f
df -hT shows used and available blocks for mounted filesystems. df -ih shows inode consumption. A filesystem can have free gigabytes but run out of inodes if it contains millions of tiny files. findmnt -T identifies the mount that contains a path, while lsblk -f helps relate block devices, partitions and filesystems.
Do not assume that the alert is about /. A separate /var, /home, database volume or container data mount may be full while the root filesystem still has room. Record the exact mount point and device before investigating.
Use du to find the largest directories safely
Once the affected filesystem is known, inspect its top-level directories. The -x option keeps the scan on one filesystem so that a mounted backup volume or network share does not distort the results. The depth limit makes the first pass manageable.
# Show top-level usage on the root filesystem without crossing mounts
sudo du -xhd1 / 2>/dev/null | sort -h
# Drill into common server data locations
sudo du -xhd1 /var 2>/dev/null | sort -h
sudo du -xhd1 /var/log 2>/dev/null | sort -h
sudo du -xhd1 /var/lib 2>/dev/null | sort -h
On systems whose du does not support -d, use the equivalent depth option for that distribution or run du -xh --max-depth=1. Compare directory totals with df on the same mount. Directory scans can take time on large filesystems, so avoid repeatedly running full recursive scans during a busy incident.
To locate unusually large individual files, use a bounded search on the affected filesystem. For example, the following lists files larger than one gigabyte under /var without crossing into another mount:
sudo find /var -xdev -type f -size +1G \
-printf '%s %p\n' 2>/dev/null | sort -n
Review the path and owner before taking action. A large database segment, virtual-machine disk, backup archive or application upload directory may be expected data. Size alone is not a reason to delete a file.
Why df and du can disagree
Deleted files that a process still has open
On Linux, unlinking a file removes its directory entry, but the filesystem cannot reclaim the data blocks while a process still holds the file open. This often happens when a large log is removed manually while the service continues writing to the old file descriptor. The filename disappears from a directory scan, yet df still counts the allocated blocks.
# Find open files whose link count is zero
sudo lsof -nP +L1
Inspect the process, file descriptor, size and service owner. The correct fix is normally to use the application’s supported log-rotation procedure or restart/reopen the file through the service’s documented mechanism. Do not immediately kill the process: it may be a database, web server or critical worker. If the file is evidence needed for an incident, preserve it before closing the descriptor, subject to access and retention policy.
Mount points hide files underneath
If a directory was filled before a separate filesystem was mounted over it, the original files remain on the underlying filesystem but are hidden by the mount. A scan of the mounted directory sees the new filesystem, not the hidden files below it. Use findmnt -T /path to understand the mount layout. Investigating the underlying directory may require a maintenance window and a carefully planned temporary mount namespace or alternate mount path; do not unmount a production filesystem just to inspect it.
Filesystem metadata and reserved space
Filesystems use space for metadata, journals and allocation structures. Some filesystems also reserve blocks for privileged processes. As a result, the total reported by directory scans is not expected to equal every number in df exactly. On ext-family filesystems, reserved blocks can make available space differ from the free block count. Do not change reserved-block settings during an incident without understanding the recovery and emergency-access implications.
Snapshots, copy-on-write and container layers
Snapshots can retain blocks after the visible file has been deleted or changed. Copy-on-write filesystems and thin-provisioned volumes may report capacity at more than one layer. Container runtimes add overlay filesystems and writable layers, while log drivers may store data outside the path an operator first inspects. Use the storage platform’s own tools as well as Linux commands; a container or cloud-volume dashboard can reveal a separate quota or backing-store limit.
Check inode exhaustion separately
If df -ih shows a filesystem at or near 100% inode use, look for directories containing huge numbers of small files. Mail queues, cache directories, session files, build workspaces and application-generated temporary files are common candidates. Use a targeted count rather than deleting the directory wholesale.
# Count entries in a suspected directory (may take time)
sudo find /var/cache/myapp -xdev -type f | wc -l
# Inspect the largest directory trees one level at a time
sudo find /var -xdev -type d -print0 | \
xargs -0 -n1 sh -c 'printf "%s " "$1"; find "$1" -maxdepth 1 -type f 2>/dev/null | wc -l' sh
For an inode problem, removing one large archive may not help if millions of tiny files consume the inode table. Work with the application owner to identify retention rules, cache expiration and stuck queues. Avoid deleting files from active spool directories unless the service documentation explains how to do it safely.
Inspect systemd journal and application logs
On systems using systemd-journald, check journal usage before removing log files manually:
journalctl --disk-usage
journalctl --since "24 hours ago" -p warning
If the journal is genuinely oversized, review the retention policy and use the supported vacuum operation. For example, a controlled cap on archived journal files can be applied with:
sudo journalctl --rotate --vacuum-size=1G
Understand the effect before running it. The vacuum options remove archived journal files; active journal files are not simply deleted, and the result may not equal an exact total cap. Retention requirements, incident-response needs and audit obligations should determine the appropriate size or age limit. Configure persistent limits in the journald settings so the problem does not return.
Application logs need the same care. Prefer the application’s log rotation mechanism, such as logrotate with a tested post-rotate action, rather than deleting a file that a process has open. Check whether logs are being duplicated, whether debug logging was left enabled, and whether a service is repeatedly logging the same error.
Investigate container storage before pruning
Docker hosts can fill because of image layers, stopped containers, build cache, volumes or JSON log files. Start with inventory commands:
docker system df
docker ps -a --size
docker image ls
docker volume ls
Inspect which workloads own the data and whether a volume contains a database or uploaded files. Pruning unused images may be reasonable after a review, but a broad command such as docker system prune -a --volumes can remove resources that an operator expected to retain. Do not remove volumes just because a container is stopped. For Kubernetes nodes, use the runtime and kubelet’s supported garbage-collection and log-rotation configuration rather than deleting files from active pod directories by hand.
When the volume itself needs to grow
Sometimes the files are legitimate and the correct solution is more capacity. Check the block device, partition and filesystem layout, then expand the cloud or virtual disk at the provider layer. Only after the underlying device is larger should the partition and filesystem be grown. The exact sequence depends on whether the filesystem is ext4, XFS, LVM-backed or managed by another storage layer.
For example, resize2fs is used for ext-family filesystems and xfs_growfs for mounted XFS filesystems, but neither command should be run blindly. Confirm the device, partition table, mount state and backup first. A cloud provider may show a larger block volume while the guest operating system still sees the old partition size. Validate each layer after expansion with lsblk, findmnt and df.
A safe incident checklist
- Identify the exact mount and determine whether blocks or inodes are exhausted.
- Capture read-only evidence with
df,findmnt,lsblkand targetedduscans. - Look for deleted-but-open files with
lsof +L1. - Check hidden mount-point data, snapshots, container storage and volume quotas.
- Confirm ownership and retention requirements before removing or rotating anything.
- Use application-supported cleanup or log-rotation procedures; restart services gracefully when required.
- Verify recovered capacity and monitor the filesystem to make sure the cause does not recur.
Common mistakes to avoid
- Running
rm -rf /var/log/*without knowing which services own the files. - Assuming
dumust equaldfeven when deleted files, snapshots or reserved blocks exist. - Ignoring inode usage and focusing only on gigabytes.
- Deleting container volumes or build caches before checking what depends on them.
- Using a forced process kill when a graceful log reopen or service restart is available.
- Increasing a cloud volume without growing the guest partition and filesystem.
Make disk usage observable before it becomes an outage
Alert on both block and inode utilization, and track growth rate rather than relying only on a single threshold. Monitor high-growth directories such as logs, uploads, database storage, container data and build caches. Give every persistent volume an owner and a retention policy. For services with variable workloads, estimate how long the remaining space will last at the current rate and alert early enough to expand capacity or investigate.
FutureTechie’s guides to systemd troubleshooting, Linux server hardening and server monitoring provide useful companion practices. Disk capacity is an operational reliability concern as much as a storage concern: a full filesystem can stop logs, databases, package updates and services from functioning correctly.
Conclusion
Good Linux disk space troubleshooting starts with the filesystem and the type of resource that is exhausted. Use df to locate the mount, du to inspect visible directory usage, lsof +L1 to find deleted-but-open files, and mount and container tools to investigate storage that is not obvious from a directory scan. Reclaim space through the owning service’s supported procedures, verify the result and add monitoring that catches the same growth pattern earlier next time.





