Created
January 5, 2020 13:28
-
-
Save geoffroymontel/f334185d09ecd3ed376ceb7dc57268f4 to your computer and use it in GitHub Desktop.
Remove all old Ubuntu kernels from a VPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dpkg --list linux-{headers,image,modules,tools}-\* | awk '{ if ($1=="ii") print $2}' | grep -v -e "$(uname -r | cut -d"-" -f1,2)" | xargs sudo dpkg --remove # use dpkg to remove all but the currently running kernel version | |
sudo apt-get install -f # It's common for apt to be in a broken state after running out of space on /boot | |
sudo apt-get autoremove # It's really common for apt to be broken on a package that should have been removed | |
sudo apt-get install -y linux-generic linux-headers-generic linux-image-generic linux-tools-generic # just in case latest kernel was mysteriously removed (e.g. when you are not running the latest kernel) | |
sudo update-grub # just in case it was not done automatically by dpkg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment