How to add a new kernel to grub2

60,555

Solution 1

To add a new kernel to grub2:

  1. Move your kernel to /boot/
  2. Run sudo update-grub

update-grub will scan your computer for kernels, and create a listing of available kernels at boot.

In order for you to select which kernel to boot at boot time, you may have to hold the SHIFT button down right after your BIOS does its posting.

You can edit /etc/default/grub to change default boot options and parameters that you may need.

Non-Debian Linux

See the grub notes for your distribution, such as these Fedora GRUB 2 docs.

  • grub2-mkconfig -o /boot/grub2/grub.cfg

Solution 2

I'm running Fedora 20, and the command to update grub2 is grub2-mkconfig. Also, the entire process can be accomplished with the kernel build make:

make xconfig (make config, etc)
make bzImage
make modules
sudo make modules_install
sudu make install

This (last step) will copy the kernel into /boot, and update the grub2 boot loader. Very easy, and it worked correctly in my case. My only issue is that you don't really learn any important details of the process, everything is automated. If you have problems and have to figure out what's wrong, you could get stuck.

Solution 3

Try update-grub or update-grub2 depending on you grub version. You will have to run these as root, sudo. This worked for me when I installed a second Linux distro without reinstalling grub.

Share:
60,555
Amir Zadeh
Author by

Amir Zadeh

Updated on September 17, 2022

Comments

  • Amir Zadeh
    Amir Zadeh over 1 year

    How can we add a kernel to grub2? i knew the stuff we could do with the former versions, but it seems to have changed. What files should we edit?

  • René Nyffenegger
    René Nyffenegger about 8 years
    sudo make install tells me: Cannot find LILO.
  • philbrooksjazz
    philbrooksjazz about 8 years
    Possibly you are building a much older version of the kernel? LILO was used on kernel version older than 3.x (not sure exact version) What distribution are you working with?
  • René Nyffenegger
    René Nyffenegger about 8 years
    This was on Arch Linux, with the newest rc (4.6.0-rc5) which I have git cloned from Linux Torvalds repository.
  • jiggunjer
    jiggunjer over 7 years
    What if you have 2 Linux distros without a separate /boot partition? Do you have to copy the kernel from the secondary rootfs to the primary one? Or does 'grub-update' also check other partitions for new kernels?
  • earthmeLon
    earthmeLon over 7 years
    This is a separate question, but either executable used should read /boot/ and generate correctly. The grub configuration file (ex: /etc/default/grub ) might be different per OS, so make sure you sync them up. Best practice might be to have a single OS generate grub entries for you, however.
  • jiggunjer
    jiggunjer over 7 years
    Not really a separate question, OP didn't specify his configuration, and dual boots a are common one. Thought it might add value to your answer, which is already good. So in other words, the secondary OS doesn't even need it's own grub, the grub from the primary one will scan for /boot folders on all partitions and find the kernels.
  • Thomas Weller
    Thomas Weller over 6 years
    How do I move a kernel to /boot? mv kernel /boot? Where do I find a kernel that could be moved to /boot?