MAIN

How to Remove Old Version of Manual-Built Linux Kernels

If you install linux kernel by building it yourself, then you cannot manage it via apt. Then if you need to remove old version of linux kernels, then you have to do it manually.

Workflow

Note that these information bases on Ubuntu 20.04 with grub version 2.04-1ubuntu26.13. Core thing is we cannot just directly edit grub entries at /boot/grub/grub.cfg as it is clearly marked with “DO NOT EDIT THIS FILE”.

The workflow to update grub entries is to edit files in /etc/grub.d and settings from /etc/default/grub then execute command update-grub to make it taken into effect.

Anyway for us, scripts inside /etc/grub.d already took care of automatically detecting newly installed linux kernels placed at /boot if you followed my written steps.

In short, this means after completing manual build steps for linux kernel, we just need to update grub.

Steps

Follow these steps

  1. Remove the following files provided that you need root privilledge
    • /boot/config-<kernel-version>
    • /boot/initrd.img-<kernel-version>
    • /boot/System.map-<kernel-version>
    • /boot/vmlinuz-<kernel-version>
  2. sudo update-grub

Now we can test by rebooting the system then inspect the grub entries, or just directly inspect /boot/grub/grub.cfg file. It should be properly updated according to related files we have in /boot directory.



First published on October, 22, 2021






Written by Wasin Thonkaew
In case of reprinting, comments, suggestions
or to do anything with the article in which you are unsure of, please
write e-mail to wasin[add]wasin[dot]io

Copyright © 2019-2021 Wasin Thonkaew. All Rights Reserved.