Kassidy M Kearey – Renegade Tech Hero
Kassidy M Kearey – Renegade Tech Hero

Time to remove old kernels

My laptop was refusing outright to start this morning reporting a rather extreme kernel panic before even attempting to mount the encrypted logical volume, which is, of course, exactly what you want to see first thing when you arrive in the office and have no engineer on shift with you to cover things while you sort the insanity out.

Fortunately, a quick flick through Grub and an attempt to boot with an older kernel proved successful and science could begin. Up and running again, I checked apt-get and found that a new linux image and associated packages had failed to configure successfully due to my boot partition being almost full.

# [07:35:43] :) localhost - Kass Laptop
# kmar-0185:~
df -h | grep boot
/dev/sda1                    228M  219M     0 100% /boot

Yep, that would do it. Time to clear out old kernels that are no longer being used. Found a very useful article here on the subject last time something similar (but less blocking last time round) happened.

# [08:20:54] :) localhost - Kass Laptop
# kmar-0185:~
uname -r
# [08:20:58] :) localhost - Kass Laptop
# kmar-0185:~
dpkg – list | grep linux-image
ii linux-image-3.0.0-19-generic 3.0.0-19.33 Linux kernel
ii linux-image-3.2.0-24-generic 3.2.0-24.39 Linux kernel
ii linux-image-3.2.0-25-generic 3.2.0-25.40 Linux kernel
ii linux-image-3.2.0-26-generic 3.2.0-26.41 Linux kernel
ii linux-image-3.2.0-27-generic 3.2.0-27.43 Linux kernel
ii linux-image-3.2.0-29-generic 3.2.0-29.46 Linux kernel
ii linux-image-3.2.0-30-generic 3.2.0-30.48 Linux kernel
iF linux-image-3.2.0-31-generic 3.2.0-31.50 Linux kernel
iU linux-image-generic Generic Linux kernel 
# [08:21:11] :) localhost - Kass Laptop
# kmar-0185:~
sudo apt-get purge linux-image-

Rinse and repeat until the old unused images are obliterated, remove the headers associated to them, then re-run the update to latest kernel.

Oh, and tell Grub to update its list of available Kernels.

# [08:32:50] :) localhost - Kass Laptop
# kmar-0185:/home 
sudo update-grub2
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-31-generic
Found initrd image: /boot/initrd.img-3.2.0-31-generic
Found linux image: /boot/vmlinuz-3.2.0-30-generic
Found initrd image: /boot/initrd.img-3.2.0-30-generic
Found linux image: /boot/vmlinuz-3.2.0-29-generic
Found initrd image: /boot/initrd.img-3.2.0-29-generic
Found linux image: /boot/vmlinuz-3.0.0-19-generic
Found initrd image: /boot/initrd.img-3.0.0-19-generic
Found memtest86+ image: /memtest86+.bin

Job’s a good’un.


Leave a Reply