Posted by: richlyn | March 29, 2010

Removing Old Kernels

I was testing lucid lynx and had messed up my installed so i decided to uninstall it and wait for the RC to be released. So i formatted my lucid install partition and rebooted however the grub/burg still showed the old kernel entries.Removing these entries was just 2 commands away in the terminal.

first run uname -r which outputs the kernel you are running.
then sudo aptitude purge ~ilinux-image-.*\(\!`uname -r`\) to remove old kernels

If you’d like a GUI,Ubuntu-Tweak is a good choice where you can remove them from Applications->Package Cleaner->Clean Kernel
Install Ubuntu-Tweak,see ubuntuguide

My terminal:

richlyn@richlyn-personal:~$ uname -r
2.6.31-19-generic
richlyn@richlyn-personal:~$ sudo aptitude purge ~ilinux-image-.*\(\!2.6.31-19-generic\)
[sudo] password for richlyn:
Reading package lists… Done
Building dependency tree
Reading state information… Done
Reading extended state information
Initializing package states… Done
Writing extended state information… Done
The following packages are BROKEN:
linux-generic
The following packages will be REMOVED:
libreadline5{u} linux-headers-2.6.31-14{u}
linux-headers-2.6.31-14-generic{u} linux-image-2.6.31-14-generic{p}
linux-image-2.6.31-15-generic{p} linux-image-2.6.31-16-generic{p}
linux-image-2.6.31-17-generic{p} linux-image-generic{p} privoxy{u}
socat{u} tsocks{u}
0 packages upgraded, 0 newly installed, 11 to remove and 3 not upgraded.
Need to get 0B of archives. After unpacking 447MB will be freed.
The following packages have unmet dependencies:
linux-generic: Depends: linux-image-generic (= 2.6.31.19.32) but it is not installable
The following actions will resolve these dependencies:

Remove the following packages:
linux-generic

Score is 119

Accept this solution? [Y/n/q/?] y
The following packages will be REMOVED:
libreadline5{u} linux-generic{a} linux-headers-2.6.31-14{u}
linux-headers-2.6.31-14-generic{u} linux-image-2.6.31-14-generic{p}
linux-image-2.6.31-15-generic{p} linux-image-2.6.31-16-generic{p}
linux-image-2.6.31-17-generic{p} linux-image-generic{p} privoxy{u}
socat{u} tsocks{u}
0 packages upgraded, 0 newly installed, 12 to remove and 3 not upgraded.
Need to get 0B of archives. After unpacking 447MB will be freed.
Do you want to continue? [Y/n/?] y
Writing extended state information… Done
(Reading database … 237999 files and directories currently installed.)
Removing socat …
Removing libreadline5 …
Removing linux-generic …
Removing linux-headers-2.6.31-14-generic …
Removing linux-headers-2.6.31-14 …
Processing triggers for man-db …
Processing triggers for libc-bin …
ldconfig deferred processing now taking place
(Reading database … 220183 files and directories currently installed.)
Removing linux-image-2.6.31-14-generic …
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/last-good-boot
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6.31-16-generic
Found initrd image: /boot/initrd.img-2.6.31-16-generic
Found linux image: /boot/vmlinuz-2.6.31-15-generic
Found initrd image: /boot/initrd.img-2.6.31-15-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
Purging configuration files for linux-image-2.6.31-14-generic …
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6.31-16-generic
Found initrd image: /boot/initrd.img-2.6.31-16-generic
Found linux image: /boot/vmlinuz-2.6.31-15-generic
Found initrd image: /boot/initrd.img-2.6.31-15-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
Removing linux-image-2.6.31-15-generic …
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/last-good-boot
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6.31-16-generic
Found initrd image: /boot/initrd.img-2.6.31-16-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
Purging configuration files for linux-image-2.6.31-15-generic …
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6.31-16-generic
Found initrd image: /boot/initrd.img-2.6.31-16-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
Removing linux-image-2.6.31-16-generic …
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/last-good-boot
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
Purging configuration files for linux-image-2.6.31-16-generic …
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
Removing linux-image-2.6.31-17-generic …
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/last-good-boot
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old
you may need to re-run your boot loader[grub]
The link /initrd.img.old is a damaged link
Removing symbolic link initrd.img.old
you may need to re-run your boot loader[grub]
Purging configuration files for linux-image-2.6.31-17-generic …
Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-19-generic
Found initrd image: /boot/initrd.img-2.6.31-19-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sda1
Found Ubuntu lucid (development branch) (10.04) on /dev/sda10
done
Removing linux-image-generic …
(Reading database … 206919 files and directories currently installed.)
Removing privoxy …
Removing tsocks …
Processing triggers for doc-base …
Processing 3 removed doc-base file(s)…
Registering documents with scrollkeeper…
Processing triggers for man-db …
Processing triggers for ureadahead …
ureadahead will be reprofiled on next reboot
Reading package lists… Done
Building dependency tree
Reading state information… Done
Reading extended state information
Initializing package states… Done
Writing extended state information… Done
richlyn@richlyn-personal:~$
div>


Responses

  1. […] Removing Old Kernels March 2010 4 […]

  2. Great! Used it to clean up Linux Mint Debian Edition after updating, it removed the files and updated grub🙂 Thanks.

  3. Works great! Thanks!

  4. Folders under /lib/modules still remain for old kernels if you built custom modules, for example for vmware so you must remove those folders manually.


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

Categories

%d bloggers like this: