Resolving the ‘No Space Left on Device’ Error on Linux

The No Space Left on Device error on a Linux system means that the partition you are trying to write data to or save files on lacks sufficient space for the operation. There are several things that users can do to resolve the error, all of which involve either freeing up additional space on the partition or extending the total size of available space. In this tutorial, we will show you how to resolve the No Space Left on Device, and go over some basic Linux commands that can help us to identify the problem.

In this tutorial you will learn:

  • How to see which partition is full with df command
  • How to identify the biggest directories with du command
  • How to identify big directories with Disk Analyzer GUI utility
  • How to clear browser and user cache
  • How to shrink or extend a disk partition
Resolving the 'No Space Left on Device' Error on Linux
Resolving the ‘No Space Left on Device’ Error on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Resolving the ‘No Space Left on Device’ Error on Linux




There are several ways to resolve the No Space Left on Device error on Linux. The most obvious is to delete some data on the partition to free up space. Another option is to extend the file system to make the partition bigger. We will go over how to do this in the steps below:

  1. Start by figuring out which partition is full. The df command can help with this. We recommend using the -h option to put the output in human readable format.
    $ df -h
    
    Output from df command showing our system's partitions and how much storage each of them is using
    Output from df command showing our system’s partitions and how much storage each of them is using

    You can use other commands in addition to df. Check out our other tutorial on How to check disk usage by folder on Linux for more command examples.

  2. Now that you know which partition is causing the problem, try identifying which directories and files are consuming the most space by using the du command. Use the -h option to put the sizes in human readable format, and optionally pipe the output to the sort command to put all the biggest directories at the top of the list.
    $ du -h | sort -h
    415M    ./Gentoo
    671M    ./Arch Linux
    1.9G    ./RHEL-based/Fedora
    6.5G    ./Debian-based/Kali Linux
    9.4G    ./Debian-based/Ubuntu
    11G     ./RHEL-based/AlmaLinux
    14G     ./RHEL-based/CentOS
    17G     ./Debian-based
    27G     ./RHEL-based
    44G     .
    
    OR:
    
    $ du -h --max-depth=1 | sort -h
    415M    ./Gentoo
    671M    ./Arch Linux
    17G     ./Debian-based
    27G     ./RHEL-based
    44G     .
    

    See more helpful examples on our tutorial How to check disk usage by folder on Linux.

  3. If you prefer a GUI method to identify what is taking up the most space on your partition, you can install and use the Disk Usage Analyzer GUI utility. It can be installed as baobab via your system’s package manager.
    Disk Usage Analyzer shows how storage space is being used in different directories
    Disk Usage Analyzer shows how storage space is being used in different directories
  4. A quick way to free up additional space is to clear your browser cache. This can often grow to multiple gigabytes of size in very little time. The process will vary depending on your browser, but it is easy to find the option in your browser’s menus.



    Clearing browser cache in Firefox on Linux
    Clearing browser cache in Firefox on Linux

    You can also clear your current user’s general cache with this Linux command:

    $ rm -rf ~/.cache/*
    
  5. Another option is to extend the length of the partition which is out of room. This can only be done if you have unused storage space on the disk or plan to shrink another existing partition and repurpose that space for the partition which is out of room. This process involves use of the parted command and is beyond the scope of this tutorial, so check out our other guide on How to partition a drive on Linux to see how to shrink and extend a partition in Linux.
  6. There is another obvious option which is to simply store your data on a different partition. Once again, you can use the df command to figure out if you have any usable partitions that have free space on them. If so, just save your data to the partition that has some space on it.
NOTE – OUT OF OPTIONS?
If you do not have any more room on your system and have already deleted everything you do not need, then there is only one solution left: you need to upgrade your storage by installing more hard disks or replacing your current drives with bigger disks. You can also try offloading some of your files to a cloud service or pick up a NAS (network attached storage) if you have a lot of files that need to be stored and backed up.

Closing Thoughts




In this tutorial, we saw how to resolve the No Space Left on Device on a Linux system. This involved identifying which partition was full and giving the error, and how to figure out which files we could safely get rid of in order to free up some much needed space. We also went over a variety of alternatives, such as using a different partition for storage, extending the file system, picking up a NAS, using cloud storage, or just upgrading your current hardware with bigger disk drives.



Comments and Discussions
Linux Forum