Pin Me

Updating GRUB After Installation of a New Linux Distribution or Kernel

written by: Pranav Thadeshwar•edited by: Michael Dougherty•updated: 5/29/2009

Have you just compiled a new kernel image? Installed a new Linux distribution? Before you can boot to the new distribution or kernel, you must make an entry for it in the GRUB configuration file. In this article, we'll take a look at a couple of ways in which you can update the GRUB configuration.

  • slide 1 of 2


    GRUB is a bootloader package which lets you boot any installed operating system on your computer. It does this by referring to its configuration file which is generally installed in the boot partition along with GRUB itself. GRUB is an excellent piece of software which does an good job of helping you boot multiple operating systems.

    The GRUB configuration file is located in the "/boot/grub" folder. It could be saved as "menu.lst" or "grub.conf" depending on your distribution's packagers and GRUB's configuration. Don't worry though, both files are generally the same aside from the name. More often than not, the files will also be symlinked, so you might not even notice a difference if you've been working with a grub.conf file and all the sudden this new-fangled distribution uses menu.lst.

  • slide 2 of 2

    Updating GRUB

    Updating GRUB to recognize new Linux distributions or kernel images can be done in two ways, automatically and manually.

    The automatic procedure involves executing a simple command which will scan your boot partition for new kernel images and make relevant entries for them in the GRUB configuration file. The command is "update-grub" or "sudo update-grub" depending on your current user permissions.

    To accomplish the same manually is a little more involved and requires you to edit a configuration file. You will be editing the menu.lst or grub.conf file. Fire up your favorite editor, I personally prefer nano, and type:

    sudo nano -w /boot/grub/grub.conf

    This will open the grub.conf or menu.lst file in nano. You will be able to see existing entries in GRUB's configuration file. If you want to add an entry, you will need to know the location of the kernel image (vmlinuz file) and optionally, the location of the initial ramdisk file (initrd). Once you know the location of these files, adding an extra entry is as simple as referring to the earlier entries and creating an extra entry below the current entries. Here is an example:

    title New Linux Installation

    root (hd0,2)

    kernel /vmlinuz-2.6-newinstall ro root=LABEL=/

    initrd /initrd-2.6.img

    In this example, the name displayed in the GRUB menu will be "New Linux Installation" and selecting that entry will load the kernel named vmlinuz-2.6-newinstall which is stored on the third partition of the first disk. The initial ramdisk used will be initrd-2.6.img which is also present in the third partition of the first disk.

    Once you're satisfied with the configuration, press Ctrl + X to save and exit nano. On the next reboot, the GRUB menu will have this new entry at the bottom of the list, and selecting it should boot your desired distribution.

    GRUB calculates the disk numbers and partition numbers by starting from 0. So a disk named hd1,2 will be referring to the third partition on the second disk, which Linux would refer to as /dev/hdb3 or /dev/sdb3. Please find out the correct disk numbers before saving the GRUB configuration file.

    As always, updating grub automatically is the preferred method due to ease of use.