1

I've deleted some of my kernels in the /boot directory and saw that I've deleted the kernel that I was booting from by using the command 'uname -a'.

Is there a way to change kernel in my grub.cfg so that I can boot?

I am using Linux Mint 18.3 Sylvia and I do have other boot images within the /boot directory. I just didn't update the grub.cfg to point to the updated version. (As a side note, shouldn't the kernel update grub.cfg when it updates the kernel? I thought that it did that until I tried 'uname -a')

The version of grub I'm using is grub 2.02.

Regards,

  • 1
    Did you already try to boot? Did you install only kernels packaged for your distribution or did you manually build kernels? – Bodo Jul 25 at 10:50
  • Did you try "yum reinstall kernel" (or the equivalent)? – stolenmoment Jul 25 at 11:53
  • There is a way to modify grub.cfg if you still have an older and valid kernel. – Paul Benson Jul 25 at 13:35
1

It could help if you're able to say which version of Grub you're running.

If you can boot to the Grub menu, you might be able to edit the config entries with 'e'.

If you can get to the command-line, you can use the 'kernel' command to name the kernel file to boot from:

ftp://ftp.gnu.org/old-gnu/Manuals/grub-0.90/html_chapter/grub_11.html#SEC34

Command: kernel [@option{--type=type}] [@option{--no-mem-option}] file ... Attempt to load the primary boot image (Multiboot a.out or ELF, Linux zImage or bzImage, FreeBSD a.out, NetBSD a.out, etc.) from file. The rest of the line is passed verbatim as the kernel command-line. Any modules must be reloaded after using this command.

Disclaimer: I haven't had to fiddle with Grub for some while.

1

When you only deleted some kernels, you can boot with one of the existing ones.

First check, if they are in the boot menu. Either directly or in a subsection "alternative kernels" or something like this. If they are there, you can just use the menu item.

Otherwise highlight the menu item for the deleted kernel and press "e" for edit. Then edit the file paths to a version, that is still installed. Afterwards you can boot with ctrl+x. When your system is booted, try to reinstall the deleted kernel. Or keep booting with the old one, until there is an update that installs an even newer kernel version, if you do not need to have the deleted kernel back immediately.

To reinstall the missing kernel, first identify what version would be booted (e.g. by looking at the menu entries in grub.cfg) and then run apt-get install --reinstall linux-image-X.Y-ARCH. You can use dpkg -l|grep linux-image to see which linux image packates are available. Installed ones should have a line starting with ii.

  • Have done the "e" for eidt and corrected the right version and pressed "ctrl+x" to boot with the kernel that I have. But how do I get it to boot everytime with the newer kernel. I tried update-grub but it does not change the grub.cfg. – hank Aug 8 at 9:15
  • I added how to reinstall the linux-image packages to my answer. – allo Aug 8 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.