Talk to the NOC, IST hours — +91 75994 50220 support@bigdomainhost.com
Guide

How to fix "No space left on device" on a Linux server

A full disk stops a server in odd ways: uploads fail, the database crashes, apt refuses to run and sometimes you cannot even log in. This guide shows how to find which filesystem is full and why, free space without breaking anything, and stop it happening again, with commands for Ubuntu 24.04 and 22.04.

Short answer: "No space left on device" means a filesystem has run out of free blocks or free inodes, so nothing new can be written. Run df -h and df -i to see which, find the biggest directories with du, then clear logs, caches or old files, or grow the disk.

What "No space left on device" means

"No space left on device" is the text Linux prints for the error code ENOSPC. The errno manual lists it under that exact wording, and any program that tries to write to a full filesystem gets it: cp, apt, MySQL, PHP, Docker, even your shell when it tries to save history. You may also see it as Errcode: 28 or errno 28, which is the number Linux gives ENOSPC.

The message is short, but it covers several different problems. A filesystem can run out of data blocks (the normal "disk full"), run out of inodes (the slots that hold one entry per file), refuse writes because the remaining space is reserved for root, or still be holding space for a deleted file a process has open. A few kernel limits that have nothing to do with disk space, such as inotify file watches, report the same error code. The fix depends on which one you have, so diagnose first and delete second.

Step 1: find out which filesystem is full

Run df with human-readable sizes and the filesystem type:

df -hT

Typical output on an Ubuntu 24.04 or 22.04 server looks like this:

Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/vda1      ext4    39G   37G     0 100% /
tmpfs          tmpfs  1.9G     0  1.9G   0% /dev/shm
/dev/vda15     vfat   105M  6.1M   99M   6% /boot/efi

Read the Mounted on column, not just the first line. The full filesystem may be /, a separate /boot, /var, /tmp or a data volume, and the program that failed was writing to whichever one holds its path. Note that Used plus Avail often adds up to less than Size; on ext4 that gap is the root-only reserve explained in step 5.

Step 2: check inodes as well as space

If df -h shows free space but writes still fail, check inodes. The df manual describes -i as listing inode information instead of block usage:

df -i
Filesystem      Inodes   IUsed IFree IUse% Mounted on
/dev/vda1      2580480 2580480     0  100% /

IUse% at 100% means the filesystem cannot create one more file, however many gigabytes are free. On ext4 the number of inodes is fixed when the filesystem is made: the mke2fs manual explains that it creates one inode for every bytes-per-inode bytes of space and warns that the ratio cannot be changed afterwards. Millions of tiny files, such as PHP session files, cache fragments, mail queue entries or a runaway script writing one file per request, use up inodes long before they use up space.

To find which directory holds them, count inodes per directory with du, which also accepts --inodes:

sudo du --inodes -x / 2>/dev/null | sort -n | tail -20

The last lines are the directories with the most files. Usual suspects are /var/lib/php/sessions, application cache folders under /var/www, /var/spool and node_modules trees. Delete files you can identify as disposable, then fix whatever created them: a missing cleanup cron job, a cache with no expiry, or a mail queue that is retrying forever.

Step 3: find what is using the space

For a normal "disk full", walk down from the full mount point with du. The -x option (--one-file-system) stops it crossing into other filesystems, and --max-depth=1 prints one total per directory:

sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -15

Then repeat on the largest directory, for example sudo du -xh --max-depth=1 /var | sort -h | tail, until you reach the files themselves. To list single large files directly:

sudo find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null

On a web server the space nearly always ends up in one of a few places:

  • /var/log: application or web server logs that are not rotated, and the systemd journal in /var/log/journal.
  • /var/lib/docker: old images, stopped containers, build cache and container logs.
  • /var/lib/mysql: database files and, often, binary logs that never expire.
  • Backup files: a nightly .tar.gz or .sql dump written to the same disk and never pruned.
  • /var/cache/apt and old kernels under /boot.
  • Home directories: uploads, core dumps and forgotten copies of a site.

If you are not yet comfortable on the command line, start with our guide on how to SSH into a server; every command here runs in that session.

Step 4: free space safely

Shrink the systemd journal

Check how much the journal uses, then remove old archived entries:

journalctl --disk-usage
sudo journalctl --rotate
sudo journalctl --vacuum-size=200M

The journalctl manual explains that --vacuum-size removes the oldest archived journal files until they fall below the size you give, and does not touch active files. Running --rotate first archives the active files so the vacuum can reach them; the manual also lets you combine the two in one command. --vacuum-time=7d keeps a week of logs instead of a fixed size.

To keep it from growing back, set a cap. By default, journald.conf limits the persistent journal to 10% of the filesystem, capped at 4 GB. On a small root disk that may still be more than you want:

sudo mkdir -p /etc/systemd/journald.conf.d
printf '[Journal]\nSystemMaxUse=500M\n' | sudo tee /etc/systemd/journald.conf.d/size.conf
sudo systemctl restart systemd-journald

Clear package caches and old kernels

sudo apt-get clean
sudo apt autoremove --purge

apt-get clean empties /var/cache/apt/archives, the downloaded .deb files, which apt can fetch again if it needs them. autoremove removes packages that were installed only as dependencies and are no longer needed, which on Ubuntu usually includes older kernel versions (the running kernel is kept). If /boot is a separate small partition and full, this is usually the fix; if apt itself cannot run because the disk is full, free a little space elsewhere first.

Prune Docker

Docker hides a lot of disk use under /var/lib/docker. See the breakdown, then prune:

docker system df
docker system prune

Docker's documentation lists what docker system prune removes: stopped containers, networks not used by a container, dangling images and unused build cache. -a also removes every image not used by a container, and --volumes removes anonymous volumes, so read the confirmation prompt before you agree. Without --volumes no volumes are removed, and the documentation describes --volumes as pruning anonymous volumes, so named volumes, which usually hold databases, should stay; check docker volume ls before you run it anyway. Container logs can also grow without limit; our Docker on Ubuntu guide covers the install, and setting a log size limit for the logging driver keeps them in check.

Rotate and compress application logs

For a single huge log file that a service is still writing to, empty it instead of deleting it:

sudo truncate -s 0 /var/log/myapp/app.log

Then add the file to logrotate (a file under /etc/logrotate.d/) so it is rotated, compressed and expired automatically. For database binary logs, set an expiry in the database configuration rather than deleting the files by hand, because the server keeps an index of them.

Step 5: if df still shows the disk full

Deleted files still held open

The most confusing case: you deleted a 10 GB log, but df still shows 100%, and du totals far less than df says is used. The unlink manual explains why: if any process still has a file open when its last name is removed, the file stays in existence until the last file descriptor referring to it is closed. The space is not freed until then.

List deleted-but-open files:

sudo lsof +L1

Each line shows the process (for example nginx, php-fpm, mysqld or java) and the size it is holding. Restart or reload that service and the space comes back. If you cannot restart it and the file is a log or temporary file you can afford to lose, you can empty it through the process's file descriptor, using the PID and FD number from the lsof output:

sudo truncate -s 0 /proc/<PID>/fd/<FD>

This is why the safe way to clear a live log is truncate, not rm.

The root-only reserve on ext4

ext4 keeps a share of blocks for privileged processes. The mke2fs manual gives the default as 5%, so that root-owned daemons such as the system logger keep working after ordinary users are stopped from writing. df works out Use% from used plus available space only, so it shows 100% as soon as Avail reaches 0, even while reserved blocks remain. If Used is still clearly below Size, or a web app fails while root can still write, you are in that reserve. Check it with:

sudo tune2fs -l /dev/vda1 | grep -i 'reserved block count'

On a large data-only volume you can lower it, for example sudo tune2fs -m 1 /dev/vdb1. Treat that as a short-term measure on the root filesystem: the reserve exists to keep the system recoverable, and the real fix is still to free space or grow the disk.

Files hidden under a mount point

If something wrote to /mnt/data or /backup before the volume was mounted there, those files sit on the root filesystem underneath the mount, where du cannot see them. Bind-mount root somewhere else to look:

sudo mkdir -p /mnt/rootfs
sudo mount --bind / /mnt/rootfs
sudo du -xh --max-depth=1 /mnt/rootfs/mnt /mnt/rootfs/backup
sudo umount /mnt/rootfs

The inotify variant: "System limit for number of file watchers reached"

Sometimes ENOSPC appears with plenty of disk and inodes free, from a file watcher: a Node.js dev server, tail -f, an IDE remote agent or a sync tool. The inotify_add_watch manual lists ENOSPC for the case where the user limit on the total number of inotify watches has been reached. Disk cleanup will not help. Check and raise the limit:

cat /proc/sys/fs/inotify/max_user_watches
echo 'fs.inotify.max_user_watches=524288' | sudo tee /etc/sysctl.d/60-inotify.conf
sudo sysctl --system

Each watch uses a little kernel memory, so raise it to what you need rather than to the largest possible number, and stop watchers from scanning node_modules where you can.

Quick diagnosis table

What you see, what it means, what to do
What you seeLikely causeFirst commandFix
df -h shows 100%Data blocks used upsudo du -xh --max-depth=1 / | sort -hRemove logs, caches, old backups; grow the disk
df -h has space, df -i shows 100%Inodes used up by many small filessudo du --inodes -x / | sort -n | tailDelete the small files and stop what creates them
Avail 0, Used below Size; root can still writeext4 reserved blockssudo tune2fs -l /dev/vda1Free space; lower the reserve only on data volumes
df full but du totals much lessDeleted files still open, or files hidden under a mountsudo lsof +L1Restart the holding service; check under mount points
"System limit for number of file watchers reached"inotify watch limitcat /proc/sys/fs/inotify/max_user_watchesRaise fs.inotify.max_user_watches
"Disk quota exceeded"Per-user quota (EDQUOT), common on shared hostingCheck usage in your hosting panelDelete files or move to a larger plan
apt fails during kernel installSmall /boot full of old kernelsdf -h /bootsudo apt autoremove --purge

Common mistakes

  • Deleting a live log with rm. The space stays used until the service restarts. Use truncate -s 0 and set up rotation.
  • Deleting files under /var/lib/mysql or /var/lib/docker by hand. Both have their own bookkeeping. Use the database's own commands and settings, and docker system prune.
  • Running du without -x. It wanders into /proc, network mounts and other disks, and the totals stop matching df.
  • Only checking df -h. A full inode table looks like a healthy disk until you run df -i.
  • Freeing space but not finding the cause. If a log grew 20 GB in a week, it will do it again. Find the writer, and add log rotation, a journal cap or a cleanup cron job.
  • Keeping backups on the same disk. They fill it, and they disappear with it. Copy backups off the server and keep only a few local copies.
  • Using the database while the disk is full. MySQL and MariaDB can stop or crash when they cannot write. After freeing space, check that the database service is running; our guide to the "Error establishing a database connection" message covers what WordPress shows when it is not.

Growing the disk instead

Sometimes the data is real and simply needs more room. On a virtual server, growing a disk has three layers: the provider enlarges the virtual disk, then you grow the partition and the filesystem inside it:

lsblk
sudo growpart /dev/vda 1
sudo resize2fs /dev/vda1     # ext4
sudo xfs_growfs /            # XFS, by mount point

Check that lsblk shows the new size before running the other two. On ext4, the mke2fs manual notes that resizing a filesystem changes the number of inodes to keep the same ratio, so growing the disk also adds inodes.

On a Bigdomainhost KVM VPS you have full root access, and you can grow the disk from the instance view in the control panel without a reboot, up to 2 TB per server, as listed under resizing and limits in our docs. Disks grow but cannot shrink, so add what you need now. Our post on disk resize without a reboot walks through each layer. On cPanel hosting you do not manage the disk yourself; the limit is your account's quota, and the error you see is usually "Disk quota exceeded".

On a Windows server

Windows reports the same condition as "There is not enough space on the disk". Check free space per drive in PowerShell with Get-PSDrive -PSProvider FileSystem, then look for large IIS or application log folders, old installers and temporary files, and use the built-in Disk Cleanup tool for Windows Update leftovers. The ideas carry over: find the biggest folders first, rotate logs, and keep backups off the system drive.

Stuck with a server that will not let you log in to clean up? Message us on WhatsApp at +91 75994 50220 at any time, call during IST working hours, or email support@bigdomainhost.com.

Bigdomainhost wrote this guide with AI assistance and sells the VPS servers it describes. Commands were checked against the Linux man-pages, systemd and Docker documentation on 28 November 2026; output and defaults can differ between versions, so check man df, man du and man journald.conf on your own system.

Sources (checked )

Answers

Frequently asked questions

Still unsure? Call +91 75994 50220 or write to support@bigdomainhost.com — a human replies in IST hours.

What does "No space left on device" mean in Linux?

It is the message for the error code ENOSPC. A program tried to write to a filesystem that has no free data blocks or no free inodes left. Run df -h to check space and df -i to check inodes; whichever shows 100% tells you what to clean up.

Why do I get "No space left on device" when df shows free space?

Usually the filesystem has run out of inodes, which df -i will show at 100%. Other causes are the ext4 root-only reserve, which blocks ordinary users when only reserved space is left, and inotify watch limits, which report the same error code but have nothing to do with disk space.

How do I find what is using disk space on Linux?

Run sudo du -xh --max-depth=1 / | sort -h to see the size of each top-level directory on the root filesystem, then repeat inside the biggest one. sudo find / -xdev -type f -size +500M lists single large files. Logs, Docker data, database files and old backups are the usual culprits.

I deleted files but the space did not come back. Why?

A process still has the deleted file open, so Linux keeps it on disk until the last open handle closes. Run sudo lsof +L1 to see which process holds it, then restart or reload that service. To clear a live log in future, use truncate -s 0 instead of rm.

Is it safe to run journalctl --vacuum-size?

Yes. It only removes the oldest archived journal files until the total is under the size you give, for example 200M, and it never touches the active files. You lose old log history, so keep enough for troubleshooting, and set SystemMaxUse in journald.conf to stop the journal growing back.

How do I fix inodes being full?

Find the directory with the most files using sudo du --inodes -x / | sort -n | tail, delete the files you can identify as disposable, such as old PHP sessions or cache entries, and fix the job that creates them. On ext4 the inode count is set when the filesystem is made, but growing the filesystem adds inodes in proportion.

What is the difference between "No space left on device" and "Disk quota exceeded"?

"No space left on device" means the whole filesystem is full. "Disk quota exceeded" (EDQUOT) means your user or account has hit its own limit while the disk itself may have room. Quotas are common on shared and cPanel hosting, where the fix is to delete files or move to a bigger plan.

Can I grow the disk instead of deleting files?

On most virtual servers, yes. Enlarge the disk at your provider, then grow the partition with growpart and the filesystem with resize2fs for ext4 or xfs_growfs for XFS. On a Bigdomainhost KVM VPS the disk grows from the control panel without a reboot, up to 2 TB, but it cannot shrink.

Support that picks up the phone.

In IST hours, in Hindi or English, and WhatsApp replies fastest at any time. Sales, migration and emergencies all reach the same engineers. No offshore queue, no 48-hour first reply.

Need cPanel or WHM with the ports already sorted?

Web & cPanel hosting comes with cPanel ready to log in to, reseller hosting adds white-label WHM, and a KVM VPS can have cPanel & WHM pre-installed. Call +91 75994 50220 or email support@bigdomainhost.com.