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

In Linux, there may be a few errors whose reasons are unclear to specify what causes them or what is the solution. The “No space left on device” error is one of these vague errors which leaves the user unsure of the actual reason. If the error is invoked, the storage of the system will no longer be usable.

This post aims to list down the possible reasons that invoke the error “No space left on device” and the solutions to all those reasons are also demonstrated.

How to Resolve “No space left on device” Issue?

There are a few reasons, referring to the storage, that can be causing this error. This section tackles these reasons and also provides possible solutions for this issue.

Reason 1: Deleted Files Taking Space

Whenever a process is still in use and the file is deleted from the system, the disk space utilized by that file is not emptied. Instead, the space is kept by the system and not released automatically. Due to this, the space keeps getting filled up with files that have already been deleted by the system.

Solution: Release the Occupied Storage

The best way to fix this issue is to free up the storage that the system is occupying for deleted files. To accomplish this, first, you need to see the list of all the deleted processes using this command:

$ sudo lsof / | grep deleted

The next step is to release the storage by performing a reload using the command shown below:

$ sudo systemctl daemon-reload

This will make sure that storage relating to any deleted files is released by the system.

Reason 2: Corrupted Blocks

Over time if storage blocks are not utilized or for other reasons, they may become corrupted and the OS may stop recognizing them. This will cause the system to prompt the “no space left on device” error.

Solution: Repair the Blocks

To fix this issue, the first step is to mark these blocks as corrupted for the system so that it can recognize them and then start performing repairs on these blocks. To get a list of the blocks, run the command below:

$ lsblk -a

To mark these blocks the following syntax is used in the terminal:

$ sudo fsck -vcck /dev/sda2

Marking the bad blocks will reallocate your data from those blocks and force check these sectors. This checking will replace all the bad blocks with working ones. You can replace /dev/sda2 with any other device name that you might have on your system. Another important tip is to make sure that you perform this task using a live CD since it is not possible to perform the fsck task on the same filesystem as the one that is being tested.


The “No space left on device” occurs due to corrupted blocks on the disk or due to deleted files taking up the space. This can be resolved by performing a daemon-reload on your system which will free up all the occupied space for deleted files or you can use the fsck command to mark corrupted storage blocks. Here, you have learned the reasoning behind this error and also the methods that can be used to resolve it.