空間不足無法升級軟體 - jenhaoyang/backend_blog GitHub Wiki
Fixing this largely depends on where the cruft has built up.
Start with unnecessary packages and apt cache:
sudo apt autoremove && sudo apt autoclean
df -h
Use du to look for cruft in /var and /var/log.
sudo du -xh --max-depth=1 /var
sudo du -xh --max-depth=1 /var/log
If a lot of space is consumed by /var/log, I usually cleanup old log files with:
# Note, change +30 to the number of days you want to keep.
sudo find /var/log -mtime +30 -type f -delete
Other directories probably need to be handled differently.
Lastly, check if running processes have a lock on files pending deletion.
sudo lsof -nP | grep '(deleted)'
# If your system doesn't have lsof installed:
sudo apt install lsof
If there are large files pending deletion, you may need to restart the process or daemon with the lock.
參考:
https://unix.stackexchange.com/a/578591