Blog · WebJi® India

Free Disk Space on a Linux Server

Quick answer: Free disk space on a Linux server is the Avail column from df -h on the mount that holds the site, usually /. Find the heavy folder with du, then delete only rotated logs, package cache and backups already copied off the server. Run df -h again and keep the change only if Avail grew.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Indian business partners shaking hands across a desk with a dashboard open on a laptop — free disk space linux server

How to check free disk space on a Linux server

df -h is the free-disk-space reading on a Linux server. Use the row whose Mounted on column is /, or the mount that holds the site. Avail is the space you can still write. Use% near 100 means the disk is full.

df reports filesystems and du reports folders. On a Linux VPS you run both over SSH on the guest. A desktop disk tool is not on a headless server, and it would not see this mount.

Use these four commands, in this order, before you delete anything.

CommandWhat it readsWhen to run it
df -hSize, Used, Avail, Use% and the mountFirst look at free disk space
df -iInode use, not bytesWrites fail but Avail is not zero
du -xh --max-depth=1 /One level of /, same filesystemFind which top folder is heavy
du -sh /var/logSize of one path you nameConfirm a folder before you delete

Ignore tmpfs and udev rows. They live in memory, not on the disk in the plan. If several disks are mounted, clean the one with the high Use%. df -h --total adds a total line that mixes those memory mounts in, so trust the / row.

ls -lh and stat report one file. fdisk -l reports partition size. None of those is free space. The free-space number is Avail from df -h.

What fills a Linux server disk: logs, backups and cache

Logs, on-disk backups and package cache fill a Linux server disk, in that order. Databases grow too, but you measure them and you do not delete their files.

Start one level down from / and stay on that filesystem, so du does not walk a second disk.

du -xh --max-depth=1 / prints that level. Open the largest name next, usually /var, /home, /usr or /opt, and run du again there.

  • /var/log and the journal — web, mail and database logs, plus the systemd journal, grow on every busy day.
  • Backups on the same disk — a plugin that keeps every copy under the site, or a dump left in /root, uses the disk 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/mysql or /var/lib/postgresql shows the data directory. Do not delete ibdata, .ibd files or the PostgreSQL data directory.

A size query lists schemas and does not free space: 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; Shrink a database with a planned dump, not with rm.

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 delete.

Indian business partners shaking hands across a desk with a dashboard open on a laptop — free disk space linux server

Safe commands to free disk space on a Linux server

Delete only after df and du agree on the mount and the folder. Run df -h after each command. If Avail does not rise, a process may still hold the file.

  1. Cap the systemd journal with journalctl --vacuum-size=100M. It prints how much it freed. It does not touch the text files in /var/log.
  2. Remove compressed logs older than 30 days with find /var/log -type f -name '*.gz' -mtime +30 -delete. Leave the live syslog, auth log and mail log in place.
  3. Clear downloaded packages, not installed software. On Debian and Ubuntu run apt-get clean. On the RHEL family run yum clean all or dnf clean all.
  4. Remove temp files untouched for a week with find /tmp -type f -atime +7 -delete. Skip this while a deploy or an installer is running.
  5. List your own old backups by name, then rm those paths. Never rm a wildcard across /var, /home or the site root.

If you removed a large file and df -h did not move, a process still has it open. lsof +L1 lists deleted files that are held open. Restart that service, then read Avail again.

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 logrotate keeps a Linux server disk free

logrotate renames, compresses and drops old logs so /var/log cannot grow without a cap. The distro already runs it from /etc/logrotate.conf and /etc/logrotate.d/.

A safe web-log block rotates weekly, keeps four compressed copies, and skips empty or missing files. Dry-run a new file first: logrotate -d /etc/logrotate.conf. The -d flag prints the plan and changes nothing.

Do not rm a log that a daemon still has open. logrotate can copy and truncate, or it can signal the daemon to reopen the file. Deleting the live file leaves the daemon writing to a removed inode, and df stays full.

When inodes make a Linux server look full

An inode is one file or directory. The disk can show free gigabytes and still refuse writes when the inode table is full. df -h looks fine. df -i shows IUse% at 100.

Tiny files cause it: sessions, mail, cache objects, and a backup plugin that never deletes old copies. One large database file does not. On GNU du, du --inodes -xd 1 / shows which directory holds the count.

Delete the old small files by age and by name, then run df -i again. A bigger disk does not help if you keep creating millions of files on it.

How to stop a Linux VPS disk filling up again

A Linux server disk is a fixed size. Unlimited disk space is a shared-hosting slogan, not a property of this mount. Clean when Use% on / passes 80, before MySQL or mail stops.

A weekly SSH check of df -h / and df -i / is enough. Bandwidth monitoring measures transfer, not bytes stored on disk, so it will not warn you that / is full.

If Avail is still near zero after the safe deletes, the workload needs a larger disk on the VPS plan.

If you cannot get a shell because the disk is full, email support@webji.services. That mailbox is staffed 24/7 in Hindi and English. The office phone is not a support line.

Frequently Asked Questions

How do I free disk space on a Linux server?

Run df -h, then du -xh --max-depth=1 / on the full mount. Delete rotated logs, package cache and backups copied off the server, then run df -h again. Stop if Avail does not grow.

How do I check free disk space on Linux?

df -h prints Size, Used, Avail and Use% for each mount. Read the row for /. Run df -i when the error is No space left on device but Avail is not zero.

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.

How do I clean /var/log safely?

Cap the journal with journalctl --vacuum-size=100M, and delete only compressed logs older than 30 days with find /var/log -type f -name '*.gz' -mtime +30 -delete. Leave the live log files for logrotate.

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 hit 100 percent IUse while df -h still shows free gigabytes. Remove those small files, not the database.

How do I find the largest files on Linux?

find / -xdev -type f -size +200M -exec du -h {} + | sort -h lists big files on this filesystem only. Confirm each path, then delete a named file. Do not remove a database file because it is large.

Why does my VPS disk keep filling up?

Logs and on-server backups grow back when nothing rotates them. logrotate plus a weekly df -h / check stops the repeat. The disk is a fixed size, so a workload that stays full after cleanup needs a larger plan.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →