Removing automatically old Kernels in the Ubuntu 10.10

Posted: April 22, 2011 in Ubuntu
Tags: ,

Hello folks. After installed the kernel 2.6.38.3 and verified that everything is working very well, we can now remove the old kernels.

Open a shell and run the script bellow:

sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed 's/-[^0-9].*//';"s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

If you have more than one system operational, type:

sudo update-grub

The command above will remove the old kernels from the grub list.

This script I found on the net some time ago and I am sharing with all of you. It works very well.

That’s it. See you next time.

Advertisements
Comments
  1. mj says:

    dpkg -l linux-* | awk ‘/^ii/{ print $2}’ | grep -v -e `uname -r | cut -f1,2 -d”-“` | grep -e [0-9] | xargs sudo apt-get -y purge

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s