Ubuntu: remove old kernels, swappiness and journal size
Free space in /boot, tune swappiness and cap the systemd journal size on Ubuntu.
Three common settings on Ubuntu: remove the old kernels that fill /boot, adjust swappiness and cap the systemd journal size.
Remove old kernels
List the installed kernels:
dpkg --list 'linux-image*' | grep ^ii
Remove a kernel that is not in use, clean up the dependencies and regenerate GRUB:
sudo apt-get remove linux-image-VERSION
sudo apt-get autoremove
sudo update-grub
Never remove the running kernel (uname -r).
Swappiness
Check the active value:
cat /proc/sys/vm/swappiness
Set the value in a sysctl configuration file:
sudo vim /etc/sysctl.d/20-swappiness.conf
vm.swappiness = 0
systemd journal size
Check the disk space used and the journal integrity:
journalctl --disk-usage
journalctl --verify
journalctl --list-boots
Set the limits in /etc/systemd/journald.conf:
[Journal]
SystemMaxFileSize=400
SystemMaxUse=500M
Shrink the archived journals immediately to 200 MB:
sudo journalctl --vacuum-size=200M
Notes
- Check the unit of
SystemMaxFileSize: without a suffix, systemd reads the value as bytes.