Error no space left on device in Linux may occur when using different programs or services. In graphics programs, this error may be displayed in a pop-up message, and for services it usually appears in the logs. In all cases it means one thing. On the disk partition where the program is going to write your data runs out of space.
To avoid such problems at the stage of planning installation of the system. Highlight under the /home directory a separate disk partition, then if you take all the memory your files, it will not prevent system operation. Also allocate more than 20 GB to the root partition under all programs definitely have enough space. But what to do if this problem already happened? Let’s look at how to free up disk space with Linux.
- How to fix no space left on device
- 1. To disable the reserved space for root
- 2. To clear the cache of package Manager
- 3. To clear the file system cache
- 4. To find large files
- 5. Find duplicate files
- 6. Remove old kernels
How to fix no space left on device
The first thing we have to understand what section you ended up memory. You can use the utility df. It comes with the system, so no problems with running it should not be:
For mount points that begin with the word snap can not pay attention. The command displays the total disk space occupied and the available space and percentage of used space. In this case, 100% occupied for the root partition /dev/sda5. Of course, we need to understand what program or file has taken all the place and fix this problem, but first it is necessary to return the system to a working state. For this we need to free up some space. Consider what can be done urgently to free up some memory.
1. To disable the reserved space for root
Normally, all file systems of a family of Ext which can be used more often as for the root and home partition redundancy is used 5% of the memory for the root user in case the disk runs out place. You can this memory be freed and to use. To do this, run:
sudo tune2fs -m 0 /dev/sda5
Here the-m option specifies the percentage of the reserved space, and /dev/sda5 is your disk that you want to configure. After this, there should be more.
2. To clear the cache of package Manager
Usually, a package Manager, be it apt or yum keeps a cache of packages, repositories, and other temporary files on disk. They are some of them unnecessary and some are necessary, but you can download them if necessary. If you urgently need the disk space the cache can be cleaned. To clean the apt cache by running:
sudo apt clean
sudo apt autoclean
To clean the yum cache, use the command:
yum clean all
3. To clear the file system cache
You can delete some large files, but memory after it is freed. This is a problem for servers that run a long time without rebooting. To fully release the memory it is necessary to restart the server. Just restart it and disk space will be more.
4. To find large files
After all of the recommendations enumerated above, you should already be enough free space to install the special tools clean the system. For starters, you can try to find the largest files and if they are not needed – delete them. Maybe some program has created a huge log file that took up the entire memory. To find out what takes space on your disk Linux you can use the utility ncdu:
sudo apt install ncdu
It scans all files and displays them by size:
Learn more about find large files read in a separate article.
5. Find duplicate files
Utility BleachBit you can find and delete duplicate files. This will also help to save space on disk.
6. Remove old kernels
The Linux kernel is often updated old kernels remain in the /boot directory and take place. If you have allocated for this directory is a separate partition, that soon it may become a problem and you will get an error when updating, because the program won’t be able to write to this directory with the new kernel. The solution is simple – remove the old kernel versions that are no longer needed.
Now you know why the error occurs No space left on device, how to prevent it and how to fix it if it has already happened. To free up space on the drive with Linux is not too difficult, but you have to understand what was the reason that all the place is busy and fix it, because next time, not all of these methods can help.