TechBuzzPro

Fix No Space Left on Device? (5 Real Fixes)

· 7 min read · Apps & Browsers

In this article
  1. What the Error Actually Means
  2. Step 1: Check Disk Space with df
  3. Step 2: Find and Remove Large Files
  4. Step 3: Free Up Inodes (If That Is the Issue)
  5. Step 4: Check for Hidden Space Consumers
  6. Step 5: Expand the Filesystem (If Needed)
  7. Frequently Asked Questions

If you see the error "No space left on device" on Linux or macOS, the most common cause is a full disk, but it can also be caused by exhausted inodes, a full RAM disk, or a filesystem that is actually full even though your home directory has space. The fix is to identify which mount point is full, free up space or inodes, and then verify the error is gone.

What the Error Actually Means

On Unix-like systems (Linux, macOS, BSD), "No space left on device" is a generic error that the kernel returns when a write operation cannot be completed because the filesystem has no free space. However, the word "device" refers to the storage device (like a hard drive partition or SSD), not the whole computer. This means the error is tied to a specific mount point—for example, /, /home, or /tmp—and not necessarily to the entire disk.

There are two primary reasons a filesystem reports no space:

  • Blocks are full: The actual data blocks on the partition are used up. This is what most people think of as "disk full."
  • Inodes are exhausted: Every file and directory consumes an inode (a data structure that stores metadata). If you have millions of tiny files, you can run out of inodes even when there is still free block space. The error message is the same.

There is also a third, less common cause: a full RAM-backed filesystem like /dev/shm (on Linux) or a full tmpfs mount. These are memory-based and can fill up quickly if a program writes a lot of temporary data.

Step 1: Check Disk Space with df

The first command to run is df -h (human-readable) to see which filesystems are full. This shows each mount point, its total size, used space, available space, and usage percentage. Look for a line that shows 100% or 99% usage. For example, if /dev/sda1 is mounted on / and shows 100%, that is your problem.

If the error occurs when writing to a specific directory like /var/log, run df -h /var/log to see the filesystem that contains it. It might be a separate partition, not the root filesystem.

For inode usage, run df -i. This shows the number of inodes used and available. If the IUse% column is 100%, you have run out of inodes. In that case, even deleting files will not help unless you also reduce the number of files (not just the bytes).

Step 2: Find and Remove Large Files

Once you know which mount point is full, you need to find what is taking up space. The most effective way is to use the du command to see disk usage by directory. Start at the root of the filesystem and drill down:

  1. Run sudo du -x -h -d 1 / | sort -h (on Linux) to see the largest directories under /. The -x flag prevents crossing filesystem boundaries, so you stay on the same device. On macOS, use sudo du -x -h -d 1 / (the sort -h may not be available by default).
  2. Navigate into the largest directory and repeat until you find the culprit. Common space hogs include /var/log (log files), /tmp (temporary files), /var/cache (package caches), and user home directories.
  3. Delete or archive unnecessary files. For logs, you can truncate a large log file with sudo truncate -s 0 /var/log/syslog (but only if you do not need the logs). For package caches, use your package manager's clean command (e.g., sudo apt clean on Debian/Ubuntu).

If you cannot find large files with du, there may be a hidden file or a deleted file that is still held open by a process. On Linux, you can check with lsof +L1 to list files that are unlinked but still open. These files do not show up in du but still consume space until the process closes them.

Step 3: Free Up Inodes (If That Is the Issue)

If df -i shows 100% inode usage, you need to reduce the number of files. This often happens in directories like /tmp or mail spools where many small files accumulate. To find directories with a huge number of files, you can use a command like find / -xdev -type f | wc -l to count files, but that is slow. A faster approach is to check known problem areas:

  • /tmp – temporary files
  • /var/spool – print queues, mail
  • /var/tmp – persistent temporary files
  • /home/*/.cache – user cache files

Delete old files in those areas. Be careful not to delete files that are in use. If you have a directory with millions of tiny files, you can delete them with find /path/to/dir -type f -delete, but this can take a long time. Alternatively, you can move the directory to another filesystem that has inodes available.

Step 4: Check for Hidden Space Consumers

Sometimes the disk is full but du does not show the expected usage. This can happen due to:

  • Reserved blocks: On ext4 filesystems, a percentage (usually 5%) is reserved for the root user. If you are not root, you may see "No space left" even when df shows a small amount of free space. You can check with tune2fs -l /dev/sda1 (on Linux) and see the "Reserved block count." As root, you can still write to those reserved blocks, but regular users cannot.
  • Snapshot or backup files: Some filesystems (like Btrfs) have snapshots that consume space. Check with btrfs subvolume list or btrfs filesystem df.
  • Files with spaces or special characters: These can be tricky to delete with shell wildcards. Use find with -delete or quote the filename properly.

If you are on macOS, check the local Time Machine snapshots with tmutil listlocalsnapshots / and delete them with tmutil deletelocalsnapshots. These snapshots can consume a lot of space and are not shown in the normal Finder view.

Step 5: Expand the Filesystem (If Needed)

If you have freed up space but the filesystem is genuinely too small for your needs, you may need to expand it. This is only possible if you have free space on the underlying volume group (LVM) or if you can resize the partition. On a cloud server, you can often resize the disk in the provider's console and then grow the filesystem with resize2fs (for ext4) or xfs_growfs (for XFS). On a local machine, you can use gparted or fdisk to resize partitions, but this is risky and should be done with a backup.

If you cannot expand the filesystem, consider moving large directories to another disk or partition and symlinking them. For example, if /home is on a small partition, you can move it to a larger one and create a symlink: mv /home /mnt/newhome then ln -s /mnt/newhome /home.

Frequently Asked Questions

Why does df show free space but I still get "No space left on device"?

This usually means you have run out of inodes, not blocks. Check with df -i. Another possibility is that you are not root and the reserved blocks are exhausted. On some filesystems, there is also a limit on the number of files per directory (e.g., ext3 has a limit of 32,000 subdirectories).

Can I delete files while the disk is full?

Yes, deleting files does not require free space for the deletion itself (the metadata update is small). However, if you are using a filesystem that needs to allocate space for journaling, you might still be able to delete. If you cannot delete because of a permission issue, use sudo.

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

The first is a filesystem-level error, meaning the entire partition is full. The second is a per-user or per-group limit set by the system administrator. If you hit a quota, you get a different error message, and you need to ask your admin to increase the quota or free up your own files.

How do I prevent this error in the future?

Regularly monitor disk usage with df -h and set up log rotation (e.g., logrotate) to keep logs from growing unbounded. Clean package caches after updates, and consider moving large media files to an external drive. For inodes, avoid creating millions of tiny files; use a database or archive them into a tarball.

Is it safe to delete files in /tmp?

Generally yes, but only files that are not in use. On many systems, /tmp is cleared on reboot. However, if a program is currently using a file in /tmp, deleting it may cause that program to malfunction. It is safer to reboot first, then delete leftover files.