Results 1 to 10 of 115

Thread: GRUB 2 Introduction

Threaded View

  1. #1
    Join Date
    Aug 2008
    South East Montana

    GRUB 2 Introduction


    There is a lot of great information on grub2 on this forum.

    I wrote this up to give folks a flying start. This will not make you an expert but it will, hopefully, get you headed in the right direction.

    A lot of people have trouble, right after installation, with other OS' being missing from the menu. The first thing to do for this is go to your terminal and;
    sudo update-grub
    This is all it takes a majority of the time.
    EDIT (10-28-09)
    There is another way to update grub;
    sudo grub-mkconfig
    This is supposed to be the default and will, I believe, soon replace update-grub altogether.

    Grub2 is completely different from grub-legacy. If you are using grub2 be prepared to learn something new.

    The menu that you see on the screen when you boot up comes from the /boot/grub/grub.cfg file.

    The /boot/grub/grub.cfg file is generated everytime “update-grub” is run. This is run everytime you get a kernal update and many times when you get a grub update. It does not make sence to edit this file.

    Grub.cfg is generated by scripts in /etc/grub.d.

    00_header gets the ball rolling and gets your timeout and hidden menu information for the menu.

    05_debian-theme sets up how your menu looks on the screen.

    10_linux is the one that gives you the menu entry for the OS that you are on.

    20_memtest86+ is what sets the memtest on your menu.

    30_os-prober is what is responcible for finding the rest of your OS'.

    40_custom is designed so that you can make custom entries.

    Grub2 gets its time out information and sets up a hidden menu for you in /etc/default/grub.

    If you need to edit a menu entry that does not work do not mess with grub.cfg. It is silly to do so. It will be over written.

    Go to /etc/grub.d and add to the 40_custom file. For instance;
    30_os-prober does not generate a functional menu entry for my Mandriva installs. So I have a custom entry that works every time and comes right up on the menu every time. It is not over written because it is regenerated every time that “update-grub” is run.
     menuentry "linux-nonfb (on /dev/sda12)" {
        insmod ext2
        set root=(hd0,12)
        search --no-floppy --fs-uuid --set c23ad2ca-67a5-4a42-8fcc-3baa6d8e454e
        linux /boot/vmlinuz BOOT_IMAGE=linux-nonfb root=UUID=c23ad2ca-67a5-4a42-8fcc-3baa6d8e454e resume=UUID=59fe476e-6d4f-e390-ced9-f29328538dfc
        initrd (hd0,11)/boot/initrd.img
    As you can see the partition is defined as being in two different places in this entry. It will not boot. The entry below will boot very well indeed.

            menuentry "Mandriva-Gnome" {
            linux (hd0,12)/boot/vmlinuz
            initrd (hd0,12)/boot/initrd.img
    This also works very well for your non-grub2 Ubuntu OS'.

    I use a slightly different entry for grub2 Ubuntu installs;
     menuentry "Kinky-Grub2-A2 on sda10 2.6.31-11-generic" {
            set root=(hd0,10)
            linux /vmlinuz root=/dev/sda10 so quiet splash
            initrd /initrd.img
    This entry works even if you change the OS on the partition.

    Your custom entries must be in the proper form. The first thing to do is start your favorite text editor (I use gedit). Go to preferences and set it so that there is NO test wrapping.

    Then, in your 40_custom file put in an entry such as;
     echo "Adding Kinky-Grub2-A2 on sda10 (2.6.31-11-generic)" >&2 
    cat << EOF
    menuentry "Kinky-Grub2-A2 on sda10 2.6.31-11-generic" {
            set root=(hd0,10)
            linux /vmlinuz root=/dev/sda10 so quiet splash
            initrd /initrd.img
    That is the entire entry for that OS. It is the one that I use for experimenting on grub2. The part that does the work is between the { }s. Make sure that they are where they belong.

    If you save this file as 06_custom it will appear at the top of menu you see on the screen. If you save it as 40_custom it will appear at the bottom of menu you see on the screen.

    Now, what is the advantage of this rigamarole compared to grub-leagacy.

    Well, if you have three OS' on your drive and you set up a custom menu you do not need any other menu entries at all. So you change the permissions on 10_linux, 20_memtest86+, 30_custom so that they are not executable. They will not run when “update-grub” is run and so the onoy thing on your menu is your custom entries. There is nothing that can mess with these entries except you.

    You must remember to run;
     sudo update-grub
    Everytime you do anything that is to change your menu. This will overwrite your /boot/grub/grub.cfg file and thus the menu that shows up on your screen.

    Here are some links, some more useful than others, that I have collected.

    Some grub2 links;

    In case grub2 is just too much, you may want to take a look at this;

    Some other links that are just interesting and may help or inspire some one;

    Last edited by ranch hand; November 13th, 2009 at 04:13 PM.
    Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, Debian Testing for use, Debian Squeeze for secure use, Debian Sid for FUN

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts