Linux Server Disk Full? How to Find and Free Up Space
Your application suddenly stops writing logs. A database refuses new inserts. A deployment fails with “No space left on device.” These symptoms often point to a full Linux filesystem—but deleting random files is a risky way to recover.
A Linux disk full error can be caused by oversized logs, accumulated Docker images, old backups, exhausted inodes, or even deleted files that running processes still hold open. The safest approach is to identify which filesystem is affected, find the source of growth, and clean up only what you understand.
This guide walks through that investigation on a Linux VPS, with commands you can run over SSH and a visual workflow using Server Explorer.
1. Confirm Which Filesystem Is Full
Start with:
df -h
Look at the Use% and Mounted on columns. If / is at 100%, the root filesystem is full; if /var or /home is on a separate filesystem, investigate that mount instead.
For a more focused view:
df -h / /var /home
These paths may share the same filesystem, so identical results are normal. Avoid assuming that a large directory on one mount is consuming space on another.
First precaution: if this is a production server, check available backups or snapshots before deleting application data. Low disk space can also affect databases and package managers.
2. Find the Directories Using the Most Space
Once you know the affected filesystem, examine its top-level directories:
sudo du -xhd1 / 2>/dev/null | sort -h
Here, -x keeps the scan on the current filesystem, -h uses readable sizes, and -d1 limits the depth. Repeat the command inside a suspicious directory, such as /var:
sudo du -xhd1 /var 2>/dev/null | sort -h
Common candidates include /var/log, /var/lib/docker, application upload directories, and folders holding backups.
To locate large files within a known directory:
sudo find /var -xdev -type f -size +500M -printf '%s %pn'
| sort -nr | head -20
This prints file sizes in bytes. Inspect the results before taking action: a large database file is not disposable simply because it appears at the top.
If installed, ncdu provides an interactive directory-size browser:
sudo ncdu -x /var
Do not install extra packages during a disk-full incident unless there is enough free space and you understand the impact.
3. Check Logs Without Breaking Log Rotation
Application and system logs can grow quickly after repeated errors. Check the journal first:
sudo journalctl --disk-usage
If systemd journal storage is unusually large, you can set a retention limit:
sudo journalctl --vacuum-size=500M
This removes eligible archived journal files; it does not guarantee that total journal usage immediately drops below 500 MB because active files remain. Choose a limit appropriate to your troubleshooting and retention needs.
For conventional log files:
sudo du -sh /var/log/* 2>/dev/null | sort -h
Check whether logrotate is configured for the growing file. Avoid deleting an active log blindly: the application may keep its file descriptor open, and you could lose evidence needed to diagnose the underlying error.
4. Inspect Docker Storage Before Cleaning It
Docker can consume substantial disk space through images, stopped containers, build cache, container logs, and volumes.
Start with a report:
docker system df
For more detail:
docker system df -v
Review images and containers before considering cleanup. For example:
docker image ls
docker ps -a
If you have confirmed that unused images are safe to remove, Docker provides:
docker image prune
This removes dangling images, not every unused image. Docker also offers docker builder prune for build cache, but inspect what is reclaimable first.
Do not run docker system prune --volumes as a routine fix. Volumes may hold persistent application or database data, and destructive cleanup is not a substitute for identifying what is consuming storage.
For additional context, see our guide to visual Docker and server management.
5. Deleted a File but Disk Space Did Not Return?
On Linux, removing a filename does not necessarily release the disk blocks immediately. A process can keep a deleted file open until its file descriptor is closed.
If lsof is available, check for deleted-but-open files:
sudo lsof +L1
Look for large entries associated with services or applications. Rather than rebooting the whole VPS, investigate the owning process and consider a controlled service restart only if it is operationally safe. Restarting a database or critical service can interrupt users, so plan accordingly.
If lsof is unavailable, verify the package is already installed or use existing system diagnostics rather than attempting an emergency installation onto a completely full filesystem.
6. Check Inodes When df -h Looks Normal
A filesystem can run out of inodes even while it still has free bytes. This happens when huge numbers of tiny files accumulate—for example, in caches, session directories, or badly configured jobs.
Check inode usage:
df -i
If IUse% is near 100%, investigate directories with very large file counts. Removing a few large files will not solve inode exhaustion; the fix is to identify and safely remove or rotate unnecessary small files.
Be aware that some filesystem types report inode information differently. Interpret the result in the context of the filesystem in use.
7. Choose the Fix Based on the Cause
| Finding | Safer next step |
|---|---|
| Archived systemd journals are too large | Set an appropriate journal retention limit |
| Application log keeps growing | Fix the recurring error and configure log rotation |
| Old Docker images and build cache | Inspect usage, then prune confirmed unused resources |
| Old backup archives | Verify retention policy and restore copies before removal |
| Deleted files remain open | Identify the owning process and plan a controlled restart |
| Inodes are exhausted | Find the directory generating excessive small files |
| Legitimate application data fills the disk | Increase storage or move data through a planned migration |
After each change, run df -h again. Record what changed and monitor whether usage begins climbing immediately. If the filesystem repeatedly fills up, the underlying issue is still present.
8. Inspect Disk Usage with Server Explorer
A graphical SSH client is useful when you want a quick view of server health without switching between several terminal sessions.
Server Explorer provides a desktop interface for Linux servers on macOS and Windows. Its dashboard displays disk usage alongside CPU and memory metrics, while the file explorer lets you inspect directories and file details. The Docker section helps you review images, containers, and volumes.
A practical workflow is:
- Connect to the affected VPS and check the disk usage indicator in the dashboard.
- Open the file explorer to inspect likely directories such as
/var/logor your application’s backup folder. - If Docker is installed, review its images and volumes before removing anything.
- Use the integrated SSH terminal for precise checks such as
df -h,du, orlsof. - Recheck disk usage after making a targeted change.
The interface does not override Linux permissions or determine which files are safe to delete. You still need to understand the data and services involved.
Bring your servers into focus.
A desktop app for macOS and Windows. Connect over SSH.
For a broader introduction to GUI-based administration, read Manage VPS Without Command Line or our Server Management GUI vs CLI comparison.
Final Checklist: Recover Space Without Losing Data
Before deleting anything, confirm the affected mount, identify the directories responsible, and determine whether the files belong to an active application. Treat Docker volumes, database files, backups, and live logs as potentially important. Once you have made a safe change, verify the reclaimed space and address the cause of continued growth.
A Linux disk full incident is easier to resolve when you investigate first and clean up second. A few targeted commands—and a clear view of your VPS in Server Explorer—can help you recover capacity without turning a storage problem into a data-loss incident.