2

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,

3
  • 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, 2019 at 10:50
  • Did you try "yum reinstall kernel" (or the equivalent)? Jul 25, 2019 at 11:53
  • There is a way to modify grub.cfg if you still have an older and valid kernel. Jul 25, 2019 at 13:35

3 Answers 3

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.

2
  • 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, 2019 at 9:15
  • I added how to reinstall the linux-image packages to my answer.
    – allo
    Aug 8, 2019 at 11:33
0

This is a full copy of my answer at Ask Ubuntu SE's How can I repair a system with a deleted kernel?. It might still help someone here to find a way through the jungle.

I only thought that I had deleted the kernel. Instead, I had somehow taken it out of the first in the queue of the kernels so that the system tried to boot with another kernel that was not the needed one. The needed kernel was not deleted. I solved this by choosing the right kernel from the advanced start menu. Either you know your kernel by having run uname -r before testing around, or you can test the list of kernels one by one (I had about 10 kernels).

See Ubuntu 20.04 black screen after installing, no booting.

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.