Free Disk Space on a Linux Server
Free disk space on a Linux server is the Avail column of df -h for the mount holding the site, usually /. Find the heavy folder with du or ncdu, then delete only rotated logs, package cache and backups already copied off the server — and confirm Avail actually grew.
A safe cleanup order for VPS admins: df and du first, journal vacuum and logrotate next, inode exhaustion for the cases that look impossible.
knowledge
- Read time
- 5 min
- Sections
- 6
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 15 November 2026.
How do you check free disk space on a Linux server?
Free disk space on a Linux server is the Avail column that df -h prints for the mount holding your site — usually the row whose "Mounted on" is / — and Use% near 100 means the disk is full. Read that row only; tmpfs and udev rows live in memory, not on your plan's disk, and df -h --total mixes them into its total line.
| Command | What it reads | When to run it |
|---|---|---|
df -h | Size, Used, Avail, Use% per mount | First look at free disk space |
df -i | Inode use, not bytes | Writes fail but Avail is not zero |
du -xh --max-depth=1 / | One level of /, same filesystem | Find which top folder is heavy |
du -sh /var/log | Size of one named path | Confirm a folder before deleting from it |
The -x flag keeps du on one filesystem so it does not wander onto a second mounted disk. If several disks are mounted, clean the one with the high Use%. For an interactive view instead of du's wall of numbers, ncdu wraps the same walk in a screen you can arrow through and delete from — install it with apt install ncdu or dnf install ncdu.
What usually fills a Linux server disk?
Logs, on-disk backups and package cache fill a Linux server disk, in that order — databases grow too, but you measure those and shrink them with a planned dump, never with rm. Start one level down from / and stay on that filesystem until the heavy directory names itself.
- /var/log and the systemd journal — web, mail and database logs plus the journal grow on every busy day.
- Backups on the same disk — a plugin keeping every copy under the site, or a dump left in /root, spends the space the site needs.
- Package cache — apt, yum and dnf keep downloaded packages under /var/cache after the software is already installed.
- Databases —
du -sh /var/lib/mysqlor/var/lib/postgresqlsizes the data directory. Never delete ibdata, .ibd files or the PostgreSQL data directory.
A size query lists schemas without freeing anything:
SELECT table_schema,
ROUND(SUM(data_length + index_length)/1024/1024, 1) AS mb
FROM information_schema.tables
GROUP BY table_schema ORDER BY mb DESC;
Keep one copy of any backup off this server. Server backup is that copy; a file that exists only on this disk is not a backup you can safely delete.
Which commands safely free disk space?
Delete only after df and du agree on the mount and the folder, run df -h after each step, and keep a change only when the Avail column actually grew. If Avail does not move after removing a large file, a process still holds it open — lsof +L1 lists deleted-but-held files, and restarting that service releases the space.
- Cap the systemd journal:
journalctl --vacuum-size=100Mprints how much it freed. Note that vacuuming removes only archived journal files; combinejournalctl --rotatewith the vacuum to shrink active ones too. Text files in /var/log are untouched. - Remove compressed logs older than 30 days:
find /var/log -type f -name '*.gz' -mtime +30 -delete. Leave the live syslog, auth log and mail log for logrotate. - Clear downloaded packages, not installed software:
apt-get cleanon Debian and Ubuntu;dnf clean alloryum clean allon the RHEL family. - Remove stale temp files:
find /tmp -type f -atime +7 -delete, and skip this while a deploy or installer is running. - Delete your own old backups by exact path, never a wildcard across /var, /home or the site root.
Do not delete /var/lib/mysql, a PostgreSQL data directory, /var/spool, /etc or the document root to make space. Those paths are the site.
How does logrotate keep the disk from refilling?
logrotate renames, compresses and eventually deletes log files on a schedule you set, so /var/log reaches a fixed ceiling instead of growing forever — and it does this without breaking the daemon still writing to the log. A safe web-log block rotates weekly, keeps four compressed copies and skips empty or missing files.
Dry-run any new file first: logrotate -d /etc/logrotate.conf prints the plan and changes nothing. Never rm a log a daemon still holds open — logrotate can copy-and-truncate or signal the daemon to reopen the file, whereas deleting the live file leaves the daemon writing to a removed inode and df stays full until the service restarts.
Why can a disk look empty in df -h but still refuse writes?
Inode exhaustion: each file or directory consumes one inode, and the filesystem can show free gigabytes in df -h while df -i reports IUse% at 100 — at that point every new write fails even though space remains. Tiny files cause it: PHP sessions, mail queue items, cache objects, a backup plugin that never prunes old copies. One large database file does not.
Find the holder with du --inodes -xd 1 / on GNU coreutils, which counts files per directory instead of bytes. Delete the old small files by age and by name, then re-read df -i. A bigger disk does not help if the workload keeps creating millions of files on it.
How do you stop a Linux VPS disk filling up again?
Clean when Use% on / passes 80, before MySQL or mail stops — a Linux server disk is a fixed size, and "unlimited disk" is a shared-hosting slogan, not a property of this mount. A weekly SSH check of df -h / and df -i / is enough to catch the trend.
- logrotate in place for web and app logs, with a keep-count that matches a weekly cleanup.
- Backups off the box: one copy on object or backup storage, not under the site root.
- Monitor the right metric: bandwidth monitoring measures transfer, not stored bytes — it will never warn you that / is full.
- Plan the workload: if Avail stays near zero after the safe deletes, the site needs a larger disk on its VPS plan (from ₹499 a month before 18% GST, configuration quoted).
If a full disk has locked you out of SSH entirely, email support@webji.services — staffed 24/7 in Hindi and English, average first reply under 60 minutes. The office phone is not a support line. For the shared-hosting contrast, where the host manages the disk for you, see shared hosting; the SSH key guide covers the key step before any of this.
Frequently asked questions
What is eating my server's disk space?
Usually /var/log, a backup folder on the same disk, or /var/cache. du -xh --max-depth=1 / names the heavy top-level directory; databases show up under /var/lib/mysql or /var/lib/postgresql. Measure before deleting — the biggest folder is not always the safest one to trim.
How do I clean /var/log safely?
Cap the journal with journalctl --vacuum-size=100M (it only removes archived files), and delete just the compressed logs older than 30 days with find /var/log -type f -name '*.gz' -mtime +30 -delete. Leave the live log files for logrotate to rotate.
What are inodes and can they run out?
Yes. Each file uses one inode, and df -i shows the count. A backup plugin or a session folder can push IUse% to 100 while df -h still shows free gigabytes. Remove those small files by age and name — not the database, which uses few inodes but many bytes.
Why did df not change after I deleted a huge file?
A running process still holds the file open, so the kernel keeps its space allocated. lsof +L1 lists deleted-but-open files; restarting the holding service releases the space. This is also why deleting a live log file instead of rotating it does not free anything.
Why does my VPS disk keep filling up?
Logs and on-server backups grow back when nothing rotates or prunes them. logrotate plus a weekly df -h / and df -i / check stops the repeat. A disk that stays full after proper cleanup means the workload has outgrown the plan.
Last editorial update: 15 November 2026. Prices follow the dated sources on this page; checkout confirms current charges.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.