The Linux operating system is known to be stable and reliable. However, it also has its share of issues that can make your computer unusable. One such issue is the “no space left on device” error. This error occurs when no free disk space is available in your hard drive or RAM.
1. Delete Log Files
You should check if there are any log files in your /var/log directory. If there are, then delete them manually or automatically:
- To manually delete a log file, run the following command:
$ sudo rm -rf /var/log/*/*.log
2. Delete Unused Packages
- Use the dpkg –list to see what packages are on your system, and then use grep to search for common package names in their output. You’ll want to find its expression in that list and delete it from there.
- Find out which packages aren’t being used anymore (and thereby don’t take up any space). To do this:
- Install an old version of GDebi or FbDebian. Run the command: `apt install gdebi` or `apt-get install fbdebian`. It will install a newer version of Debian with the older tools intact—but only if you need them! If not, run apt-get update && apt-get upgrade again before proceeding here;
3. Delete Archived Mail
If you are using a version of Linux that doesn’t have mailx, it is possible to use an older version of the command. For example:
- yum remove mailx
- rm -rf /var/spool/mail/*.MSG
4. Remove Old Kernels
If you need clarification on which kernels are causing the error or want to remove old kernels and install brand-new ones, this is the method for you. To do so, run this command:
5. Defrag Your Linux File System
Defragmentation is reorganizing files on a hard disk to make it easier to access them. It’s a good idea if you have a lot of files on your hard drive, as this can help reduce fragmentation and improve performance.
You can use the following command to defragment your Linux file system:
- sudo dd if=/dev/zero of=/dev/sda bs=1M count=64k conv=fdatasync
6. Delete Temporary Files
To find and delete temporary files, you will need to run a command with the following syntax:
- $ grep -v ‘^#’ /var/log/syslog | sort -n | less
- If there are any temporary files on your system, they will be in this output. It’s important to note that these are stored by default until they can be appropriately purged or deleted by a different process (such as rm). The command above will show you exactly where every file in your directory structure is; however, it does nothing about removing them. To do so yourself:
- $ sudo rm -rf /tmp/*
7. Enable File Quotas On Users And Groups
File quotas are a system-wide setting that allows administrators to limit the amount of disk space available to users and groups. For example, if you have an employee using their laptop for work over the past few weeks, you should limit their usage of your network drive so they don’t lose any critical data.
To enable file quotas on users and groups:
- Log into the Linux server as root (using sudo su).
- Type chmod +x /etc/fstab or chmod -R +x /etc/fstab for these changes to take effect immediately without restarting services first – see above for more details regarding this command line option!
8. Automatically Clear /Tmp At A Given Interval
This method requires superuser permissions, and you’ll need to use cron to schedule the task. First, create a directory in /tmp (or use /dev/shm) where you want your system’s temporary files to be stored. Then add this line:
- Clear -f /tmp/*
9. Create A Cronjob To Clean Directories Regularly
You can create a cron job to clean directories to free up space.
To do so, you need to use the cron command:
- To create the directory cleaning task: crontab -e
- To specify the interval for cleaning: 0 */5 * * * /home/username/backup/clean_directory
10. Increase The Size Of /Tmp Folder Using Tmpfs
- Increase the Size of /tmp Folder Using tmpfs
If you’re running into this error, it may be because you have a large amount of data in your /tmp folder. To fix this problem:
- First, we need to make sure that there is enough space available in our /tmp folder by running the ls command:
- $ sudo ls -lh /tmp
- drwxr-xr-x 3 root root 4096 2014-12-02 17:26 .
- drwxr-xr-x 4 root root 4096 2014-12-02 02:31 .. (etc)
Conclusion
This article will help you fix your Linux system’s ‘No Space Left On Device’ error. If all these tips don’t work, there is also a chance that your system has crashed. You must reinstall or restore your system from a backup image or flash drive.