Open In App

How to Fix the “No space left on device” Error in Linux

Last Updated : 05 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

When you try to save files or write data on a Linux system, you might get the “No Space Left on Device” error. This error means that the storage space you are trying to use is full and does not have enough room left for your operation. To fix this error, you can either make more space available in the storage space or increase the total amount of storage space.

In this tutorial, we will show you how to resolve the “No Space Left on Device” error and review some basic Linux commands to help you identify the problem.

Fix 1 : Using the df command

There are several ways to fix the “No Space Left on Device” error on Linux. The most obvious way is to delete some files or data on the storage space to make more room. Another way is to make the storage space bigger. We will go over how to do this in the steps below.

Start by finding out which storage space is full. The df command can help with this. We recommend using the -h option to make the output easier to understand.

Command :

 df -h

Output :

1

Check for the Storage Space

You can use other commands in addition to df. Check out our other tutorial on How to see how much space each folder is using on Linux for more command examples.

Fix 2 : Using the du Command

Now that you know which storage space is causing the problem, try finding out which folders and files are taking up the most space by using the du command. Use the -h option to show the sizes in a way that’s easy to understand, and you can optionally use the sort command to put all the biggest folders at the top of the list.

Command :

sudo du -h | sort -h

Output :

2

Sort the Files by their Size

Fix 3 : Clear your Browser Cache

One quick way to make more space is to delete the temporary files stored by your web browser. These files can sometimes take up a lot of space on your computer without you realizing it. The steps to do this will be a little different depending on which web browser you use, but it’s usually easy to find the option in the browser’s menus.

Go to the Browser Menu then search cache in the search bar after that you will get to see the “Cookies and Site Data” Click on the “Clear Data” to Clear the whole browser’s cache.

3

Clear your Browser Cache

Fix 4 : Clearing Temporary Files

Open your file manager and then in the Left Side menu click on the Computer and then Double click on File System.

4

Look for folders named “tmp“, “cache“, “temporary“, or “.trash“. Right-click on those folders and select “Empty” or “Delete“. Enter your password if prompted. This will remove temporary files that were taking up space unnecessarily.

5

Clear the Temporary Files

Fix 5 : Deleting Old Log Files

Open terminal and Go to the /var/log directory by using the below command.

Command :

cd /var/log

Output :

6

Use below command to remove old log files with names like “old” or old date stamps. Be careful not to delete important logs. This frees up disk space.

Command :

rm file_name.log

Output :

7

Remove the Old logs from the system

Fix 6 : Clearing Package Cache

When you install software programs on your Linux system, temporary package files get stored in a cache. Over time, this cache can take up a lot of space unnecessarily.

Open the terminal and use your package manager’s clean command. For example, on Linux you would type “sudo apt-get clean”. On Fedora, use “sudo dnf clean packages”. Enter your password when prompted. This will remove the cached package files safely, freeing up disk space without uninstalling any of your programs.

Command :

sudo apt-get clean

Output :

8

Clearing the Package Cache

Fix 7 : Resizing Partitions

If clearing out files does not free enough space, you may need to make the partition itself larger, to do that follow the below steps.

Open the Terminal and use the below Command to Open the Gparted application this application is already installed in the Linux System. After typing the command type the password of your linux system and click on Authenticate.

Command :

gparted

Output :

9

Right Cick on the /dev/sda1 disk and then click on the Resize to Resize the Partition.

10

After clicking on the Resize button then in the next window we need to enter the desired size that we want. After entering the size click on Resize button in the down corner to resize the Partition.

11

Resize the Partition

Fix 8 : Removing Unnecessary Software

Over time, you may have installed programs on your Linux system that you no longer need or use. These programs take up disk space that could be recovered.

To remove them, Right-Click on the Application that you don’t want and then click on the “Delete” option or “Uninstall” Option.

12

Alternatively, in the terminal, you can use your package manager’s remove command like “sudo apt-get remove program_name” on Linux. After uninstalling unnecessary programs, you will have freed up disk space.

Command :

sudo apt-get remove (program_name)

Output :

13

Remove the Unnecessary Softwares

Fix the “No space left on device” Error in Linux – FAQs

What does the “No space left on device” error mean in Linux?

This error message indicates that there is no more available space on the storage device where the system or application is trying to write data. It typically occurs when the disk or partition is full, preventing further write operations.

How can I identify which disk or partition is causing the error?

You can use the `df ` command in Linux to display disk space usage. Running `df -h` will show you a summary of available disk space on all mounted filesystems. Look for the filesystem that is at 100% usage to identify the culprit.

What are some common causes of the “No space left on device” error?

The error can occur due to various reasons, such as large log files consuming disk space, a runaway process generating excessive data, or simply running out of available disk space due to file downloads or installations.

How can I free up disk space to resolve the error?

You can free up disk space by deleting unnecessary files, such as temporary files, unused applications, or old log files. Additionally, you can resize partitions or move files to a different disk if available.

Is there a way to prevent the “No space left on device” error from occurring in the future?

To avoid encountering this error again, it’s essential to regularly monitor disk space usage, implement disk space quotas if necessary, and consider setting up automated cleanup tasks or log rotation to manage disk space more effectively. Additionally, you can consider adding more storage capacity if your system consistently runs out of space.

Conclusion

If you are seeing the “No Space Left on Device” error on your Linux system, it means the storage space is full. To fix this, you can delete some files or folders that are taking up a lot of space. Use the df command to find out which storage is full. Then use the du command or the Disk Usage Analyzer program to see which folders are the biggest. You can also clear your web browser’s cache to free up space quickly. If you still need more space after deleting files, you may need to make that storage space bigger by adding more storage or extending the partition size.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads