How to Fix 'No Space Left on Device' Error in Linux
No space left on device error in Linux means your disk or partition is full. To fix it, delete unnecessary files or clear cache to free up space using commands like rm or sudo apt clean.Why This Happens
This error occurs because the disk or partition where you want to save files is completely full. Linux cannot write new data when there is no free space left. This often happens when logs, caches, or large files accumulate over time.
touch /full_disk/testfile
The Fix
To fix this, find and delete unnecessary files or clear package caches to free space. Use df -h to check disk usage and du -sh * to find large folders. Then remove files with rm or clean caches with sudo apt clean.
df -h sudo apt clean rm -rf /var/log/*.log rm -rf ~/Downloads/largefile.iso
Prevention
Regularly monitor disk space with df -h and clean caches often. Set up log rotation to avoid huge log files. Avoid storing unnecessary large files on your main partitions. Automate cleanup tasks with cron jobs to keep space free.
Related Errors
Similar errors include Read-only file system caused by disk errors, and Disk quota exceeded when user limits are reached. Fix these by checking disk health with fsck or adjusting user quotas.