More often than not, Linux is pretty specific with its error messages and codes. However, there are a few errors that can dazzle even the most seasoned terminal pros.
In this article, we’re going over a few fixes you can try out if Linux tells you there’s no space left on the device.
Also read: How to open task manager in Linux?
Check your harddisk
The first thing you should do is check if there’s space left on the drive you’re using. You can do this by either using a desktop-environment tool like GPARTED or GNOME Disk Usage Analyser depending upon the distro you’re using or use terminal tools.
Since terminal tools remain constant across distros, we’ll be going forward with those.
Step 1: Start with the du command and point to the root directory of the drive.
sudo du -sh /
The command will go through all directories and list out total storage.
Step 2: Next up, try df with the same parameters.
sudo df -h
The total file size should be close to what you got with df. If it’s not, then a process on your machine is using a deleted file which is hogging up your storage.
Also read: RM command in Linux explained with examples
How to fix this issue?
If you don’t see a discrepancy in the df and du commands above, head over to the second solution; otherwise, start with the first.
A process is blocking a deleted file
If a file is deleted, but a process is still using it, Linux won’t actually delete it, meaning the storage associated with the file is still occupied. Here’s how to fix this.
Step 1: Locate the process using the grep command.
sudo lsof / | grep deleted
Step 2: Restart the process with the systemctl command.
sudo systemctl restart service_name
If that doesn’t work, do an entire daemon-reload.
sudo systemctl daemon-reload
System running out of Inodes
Inodes are metadata for filesystems and track information about files. Unfortunately, a bunch of file systems use a fixed number of inodes, making it a genuine possibility that you’ll run out of inodes before you run out of storage on your actual drive. You can use the following command to check for inodes.
sudo df -i /
If you don’t see any free inodes, delete some old files from your drive to clear up a few inodes.
Bad sectors are an inherent problem of hard disk drives and can cause a lot of headaches. Over time, filesystems can become corrupt, and hard disks can die. As this process happens, the actual storage on your hard disk keeps shrinking a little.
You can find and mark bad sectors (or blocks) using the fsck tool.
sudo fsck -vcck /dev/sda2
Just be sure to replace the drive name in the command above with the one you need to search.
Also read: How to add a user to a group in Linux?
Someone who writes/edits/shoots/hosts all things tech and when he’s not, streams himself racing virtual cars. You can reach out to Yadullah at [email protected], or follow him on Instagram or Twitter.