How to Fix No Space Left on Device Error on Linux (2026)

Published: July 6, 2026 | Last updated: July 6, 2026

TL;DR

  • Run df -h to check disk space usage — if a partition shows 100%, your disk is full (Alibaba Cloud, 2026).
  • Run df -i to check inode usage — if IUse% shows 100%, you’ve run out of inodes even if disk space is available (Alibaba Cloud, 2026).
  • If you deleted files but space wasn’t freed, a process is still holding them open — use lsof | grep deleted to find and restart the process (DigitalOcean, 2020).
  • Use du -sh * to find large files and directories, then drill down to the culprits (Alibaba Cloud, 2026).
  • For inode issues, use du -i to find directories with excessive files, then delete unnecessary files (Engine Yard, 2025).

What Causes the “No Space Left on Device” Error?

The “No space left on device” error in Linux can be caused by several different issues, not just a full disk (Huawei Cloud, 2026). Understanding which one you’re facing is the first step to fixing it.

1. Disk partition is 100% full. This is the most obvious cause. When a partition’s block usage reaches 100%, no new files can be created (Alibaba Cloud, 2026).

2. Inodes are exhausted. Each file and directory consumes one inode — a data structure that stores metadata like permissions, ownership, and timestamps (Engine Yard, 2025). If you have millions of tiny files (like cached sessions or email spools), you can run out of inodes even when disk space is available (Alibaba Cloud, 2026).

3. Deleted files still held open. When you delete a file with rm, the space isn’t freed if a running process still has the file open (DigitalOcean, 2020). The space is only released when the process closes the file or terminates (Alibaba Cloud, 2026).

4. Overwritten mount point. If you mount a new device on a directory that already contains files, the original files become hidden but still consume space (Huawei Cloud, 2026). The df and du commands only show the new mount point, so the hidden space isn’t visible.

Quick Diagnosis: Find the Root Cause

Before you start deleting files, run these two commands to identify the cause (Alibaba Cloud, 2026):

df -h    # Check disk space usage per partition
df -i    # Check inode usage per partition
What you seeLikely causeSolution
A partition shows 100% under Use% in df -hDisk partition is fullDelete large files or expand disk (Alibaba Cloud, 2026)
A partition shows 100% under IUse% in df -iInodes exhaustedDelete unnecessary small files or expand disk (Alibaba Cloud, 2026)
Both df -h and df -i show normal usageDeleted files still referenced by processesUse lsof to find and restart processes (DigitalOcean, 2020)
du and df report contradictory space usageMount point overwrittenUnmount and remount correctly (Huawei Cloud, 2026)

How to Fix Disk Space Full on Ubuntu, CentOS, and Other Linux

If df -h shows a partition at 100%, you need to free up space. Here’s how to find and remove large files.

Step 1: Find Which Directory Is Using the Most Space

Start from the root of the affected partition and work your way down (Alibaba Cloud, 2026):

cd /
sudo du -sh * | sort -h

This shows the size of each top-level directory. Look for the largest one, then drill down:

cd /largest_directory
sudo du -sh * | sort -h

Repeat until you find the specific files or directories consuming the space (Alibaba Cloud, 2026).

Step 2: Identify Large Files

To find files larger than 100MB:

sudo find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k5 -h

This command searches the entire system for files larger than 100MB and displays them sorted by size.

Step 3: Clean Up Common Culprits

Common space hogs include:

  • Log files: Check /var/log/ for large log files. Old logs can be compressed or deleted.
  • Package caches: On Ubuntu/Debian, run sudo apt clean to clear the package cache. On CentOS/RHEL, run sudo yum clean all.
  • Temporary files: Check /tmp/ and /var/tmp/ for old temporary files.
  • Docker images: If you use Docker, run docker system prune -f to remove unused images and containers.

Step 4: Expand the Disk (If You Can’t Free Enough Space)

If you can’t free enough space by deleting files, consider expanding the disk (Alibaba Cloud, 2026). The method depends on your environment — cloud providers offer disk resizing options, and physical servers may require adding a new disk.

How to Fix Inode Exhaustion on Linux

If df -i shows IUse% at 100%, you’ve run out of inodes. This happens when you have a very large number of small files (Engine Yard, 2025).

Step 1: Find Directories with Excessive Files

Use the du -i command to find directories with the most inodes (Engine Yard, 2025):

sudo du -i / | sort -rn | head -20

This shows the 20 directories with the highest inode counts. The -i flag counts inodes (files and directories) rather than disk space.

Step 2: Drill Down to Find the Culprit

Once you identify a directory with excessive inodes, drill down:

sudo du -i /path/to/directory | sort -rn | head -20

Common culprits include:

  • Email spools: /var/spool/mail/ or /var/mail/
  • Web caches: /var/cache/
  • Session files: /tmp/ or application-specific session directories
  • Small log files: Rotated logs that weren’t cleaned up

Step 3: Delete Unnecessary Files

Once you identify the directory with excessive files, delete the ones you don’t need. Be careful — deleting the wrong files can break applications.

For example, to delete old session files:

sudo find /tmp/ -type f -atime +7 -delete

This deletes files in /tmp/ that haven’t been accessed in over 7 days.

Step 4: Consider Increasing Inodes

If you can’t delete enough files, you may need to increase the number of inodes. This typically requires reformatting the filesystem with a higher inode count — not a trivial operation. On cloud servers, expanding the disk often increases inodes automatically.

How to Fix Deleted Files Still Holding Space

You deleted files with rm, but the space wasn’t freed. This happens when a running process still has the file open (DigitalOcean, 2020).

Step 1: Install lsof

If lsof isn’t installed, install it:

  • Ubuntu/Debian: sudo apt install lsof
  • CentOS/RHEL: sudo yum install lsof (Alibaba Cloud, 2026)

Step 2: Find Deleted Files Still in Use

sudo lsof | grep deleted | sort -k7 -rn | more

The seventh column shows the file size in bytes (Alibaba Cloud, 2026). Look for large files that are still held open.

Step 3: Restart the Process or Service

Once you identify the process holding the deleted file, restart it (DigitalOcean, 2020):

sudo systemctl restart service_name

If you can’t identify the specific service, a system reboot will close all open files and free the space — but this should be a last resort.

How to Fix Overwritten Mount Point Issues

If du and df report contradictory space usage for the same directory, you may have an overwritten mount point (Huawei Cloud, 2026). This happens when a directory that already contains files is used as a mount point for a new device.

Step 1: Identify the Overwritten Mount Point

Check your mounts:

mount | grep "on /path"

If a device is mounted on a directory that already contains files, the original files are hidden but still consume space.

Step 2: Unmount and Remount

Unmount the device, check the hidden files, and then remount correctly:

sudo umount /path
ls -la /path   # Now you'll see the original files
sudo mount /dev/device /path

Fixes for Specific Linux Distributions

Ubuntu-Specific Fixes

On Ubuntu, the error can occur in specific scenarios like running out of space on the /cow filesystem (used for live USB sessions) or during CI builds (Ubuntu Community, 2026).

Fix for /cow filesystem: If you’re running a live session with persistence, the /cow filesystem uses half your RAM. You may need to use a different USB drive with more persistence space.

Fix for CI builds: GitHub Actions and other CI runners often run out of space. Add cleanup steps at the start of your workflow to remove unused files (GitHub, 2026).

CentOS/RHEL-Specific Fixes

On CentOS 7 and RHEL, the error can occur even when df -h shows plenty of space (DigitalOcean, 2020). The most common cause is deleted files still held open by processes.

Fix: Use lsof | grep deleted to find the process, then restart the service or reboot the system.

Permanent fix for inotify limits: If you’re hitting “No space left on device” errors related to file watches, increase the inotify limit:

echo "fs.inotify.max_user_watches=1048576" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Troubleshooting Table

ProblemCauseFix
df -h shows 100% usageDisk partition fullFind and delete large files with du -sh * and find (Alibaba Cloud, 2026)
df -i shows 100% IUse%Inodes exhaustedFind directories with excessive files using du -i and delete unnecessary ones (Engine Yard, 2025)
Deleted files didn’t free spaceProcess still holds file openUse lsof | grep deleted to find and restart the process (DigitalOcean, 2020)
du and df show different usageOverwritten mount pointUnmount, check hidden files, and remount correctly (Huawei Cloud, 2026)
Error persists after deleting filesFiles in use by running processesRestart the service or reboot the system (DigitalOcean, 2020)
Ubuntu /cow filesystem fullLive USB persistence limitUse a USB with more persistence space or reduce installed packages (Ubuntu Community, 2026)

Frequently Asked Questions

Why do I get “No space left on device” when there is space?

The most common reason is that you’ve run out of inodes, not disk space. Each file consumes one inode, and if you have millions of tiny files, you can exhaust inodes even with free disk space (Engine Yard, 2025). Run df -i to check inode usage (Alibaba Cloud, 2026).

How do I fix “No space left on device” on Ubuntu?

Start by running df -h to check disk space and df -i to check inodes (Alibaba Cloud, 2026). If disk space is full, use du -sh * to find large files and delete them. If inodes are exhausted, use du -i to find directories with excessive files (Engine Yard, 2025). Clean package caches with sudo apt clean.

How do I fix “No space left on device” on CentOS 7?

Check df -h and df -i first. If both show space, use lsof | grep deleted to find deleted files still held open by processes (DigitalOcean, 2020). Restart the offending services or reboot the system (DigitalOcean, 2020). Also check /var/log/ and clean up old log files.

Why does “No space left on device” appear after deleting files?

When you delete a file with rm, the space isn’t freed if a running process still has the file open (DigitalOcean, 2020). The file remains on disk until the process closes it or terminates (Alibaba Cloud, 2026). Use lsof | grep deleted to identify the process.

What are inodes and why do they matter?

Inodes are data structures used by Linux filesystems to store metadata about files and directories, such as permissions, ownership, and timestamps (Engine Yard, 2025). Each file or directory consumes one inode. When inodes are exhausted, you can’t create new files even if disk space is available (Alibaba Cloud, 2026).

How do I check disk space and inode usage on Linux?

Run df -h to check disk space usage per partition. Run df -i to check inode usage per partition. Look for 100% values in the Use% or IUse% columns (Alibaba Cloud, 2026).

How do I find large files on Linux?

Use sudo du -sh / | sort -h to find large directories, then drill down. Use sudo find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null to find files larger than 100MB (Alibaba Cloud, 2026).

How do I fix “No space left on device” on Windows?

On Windows, the error is less common but can occur in WSL (Windows Subsystem for Linux). Check the WSL disk size with df -h in the WSL terminal. Resize the WSL virtual disk using wsl --set-ubuntu --disk-size or clean up files within the WSL environment.

Key Takeaways

  • Run df -h to check disk space usage — if a partition shows 100%, your disk is full (Alibaba Cloud, 2026).
  • Run df -i to check inode usage — if IUse% shows 100%, you’ve run out of inodes even if disk space is available (Alibaba Cloud, 2026).
  • If you deleted files but space wasn’t freed, a process is still holding them open — use lsof | grep deleted to find and restart the process (DigitalOcean, 2020).
  • Use du -sh * to find large files and directories, then drill down to the culprits (Alibaba Cloud, 2026).
  • For inode issues, use du -i to find directories with excessive files, then delete unnecessary files (Engine Yard, 2025).
  • Common space hogs include log files (/var/log/), package caches (/var/cache/apt/), Docker images, and temporary files.

Leave a Comment