If you are running your own cloud instances and use them for development purposes, their capacities would probably be limited and sometimes you might notice that the disk space is too low.
TL;DR
Remove unnecessary system packages and package caches
sudo apt-get --purge autoremove
sudo apt-get autoclean
sudo apt-get clean
Remove system log except for the last 3 days
Check it first:
journalctl --disk-usage
sudo journalctl --vacuum-time=3d
Actually it grows day by day, so you can create a cron script to clean up journal logs once a month for example, or can configure it to use limited amount of disk space by setting SystemMaxUse=50M
in /etc/systemd/journald.conf
. Then reload conf:
sudo systemctl restart systemd-journald
Clean up snap
Check it first:
du -h /var/lib/snapd/snaps
This is a bash script.
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
Please add more in the comment section if you have another ones.
Happy coding! :)
Top comments (0)