Server disk full: fix "No space left on device"
This error means you ran out of space or out of allowed files (inodes). Check both and find the largest folders. The cause is usually logs, backups or package caches.
Last updated:
Step 1: check space and file count
If Use% is close to 100 in df -h you are out of space. If IUse% is close to 100 in df -i you are out of files even with space left, usually from millions of small files such as sessions.
$ df -h $ df -i
Step 2: find what takes the space
This shows the largest folders without crossing onto other disks. Go into the largest one and repeat until you reach the cause.
$ sudo du -xh --max-depth=1 / | sort -h | tail -n 15Step 3: clean the safe places
These shrink system logs and remove old package caches on Ubuntu and Debian, and they are safe. Then review your backup folder and your applications' logs.
$ sudo journalctl --vacuum-size=200M $ sudo apt-get clean $ sudo apt-get autoremove --purge
$ sudo truncate -s 0 /var/log/nginx/access.logDeleted files but the space did not come back?
A deleted file still open by a program keeps its space. This command lists such files, and restarting the program it names frees the space.
$ sudo lsof +L1The server will not boot because the disk is full
Boot the rescue system, mount the system partition on /mnt, delete what you do not need from it, then turn the rescue system off and restart.

