Skip to content

Instantly share code, notes, and snippets.

@WillPlatnick
Created February 3, 2017 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillPlatnick/2c25ff5907943fd65908ba82d5b7a3d2 to your computer and use it in GitHub Desktop.
Save WillPlatnick/2c25ff5907943fd65908ba82d5b7a3d2 to your computer and use it in GitHub Desktop.
Clean up old kernels in ubuntu
#Remove kernel packages that have been removed but not purged
dpkg -l | grep linux-image | grep "^rc" | cut -d' ' -f3 | xargs apt-get --purge remove -y
# Remove all kernel images except the current running one
sudo apt-get remove $(dpkg -l *linux-image-[0-9]* | grep ii | grep -v $(uname -r) | awk '{print $2}')
# Remove old dkms that are left due to bug; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=717584
rm /boot/*.old-dkms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment