3 Ways To Fix “No Space Left on Device” Error In Linux

Fix “No Space Left on Device” Error In Linux

Are you going through an error like “No Space Left On Device” in Linux and getting frustrated with this then this blog post has a solution for you.

How To Fix “No Space Left on Device” Error In Linux

Make sure that your Linux has enough space in your Linux operating system. There are two Linux commands for getting information about disk space. You can do it with the du and df commands. .

Why Does Linux Show “No Space Left on Device” Despite Of Having Enough Space In Linux?

If you are seeing the “No Space Left on Device” error message despite having sufficient free space on your disk, there must something wrong with your Linux file system.

Fix 2:

Check Inodes On Linux

One of the common issues might be not having enough inodes. In Linux, inodes aren’t unlimited, and running out of inodes before the storage space can give you the “No space left on device” error.

You can easily check the availability of inodes by using the -i flag with the df command.

sudo df -i

This will clearly tell the total number of inodes present in the filesystem, along with the amount currently in use. If there are no free inodes left on your system, this is the source of the “No space left on device” error. Sadly, there is no way to generate or create more inodes. All you can do is delete the unnecessary files to free up inodes.

Fix 2:

Restart Processes Using Deleted Files

The most common reason for seeing this error is a recently deleted file. Even if a file is deleted, the respective process keeps using it, keeping the space reserved even though the file is already deleted. You just need to restart the process to free up the reserved storage.

Run the lsof and grep commands to find the problematic process and restart the affected process with the sudo systemctl restart service_name command or you can just reset them all with the sudo systemctl daemon-reload command.

Fix 3:

Manage Bad Blocks In Linux

Sometimes bad sectors can be the reason for space-related errors. There is no real way to fix this issue, The only thing you can do is mark the bad sectors so that they are no longer used by the file system. You need to configure the file system. Run the following command by booting through a Live CD. This will automatically detect all bad blocks on the drive and mark them as unusable.

sudo fsck -vcck /dev/sda

This replaces the /dev/sda with the path of the drive you want to repair.

READ More Relevant Stuff:  Install Squid Proxy on Ubuntu 20.04

Leave a Reply

Your email address will not be published. Required fields are marked *