Skip to content

Instantly share code, notes, and snippets.

@taldanzig
Last active August 29, 2015 13:57
Show Gist options
  • Save taldanzig/9398143 to your computer and use it in GitHub Desktop.
Save taldanzig/9398143 to your computer and use it in GitHub Desktop.

One-liner to clean /boot on Ubuntu systems

Ubuntu systems (especially those with auto-updates enabled) fill up /boot with kernel images over time.

Here is a quick and dirty command to clean installed kernel packages on Ubuntu systems. It will keep the currently running kernel and the newest installed kernel package:

apt-get --purge remove $(dpkg-query --list 'linux-image-3*' | grep '^ii' | sed '$d' | grep -v $(uname -r) | sed -e 's/.*linux-image-\(3\(\.[0-9]\+\)\+-[0-9]\+\).*$/\1/' | sed -e 's/^\(.*\)$/linux-.*-\1.*/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment