Announcement

Collapse
No announcement yet.

Grub 2 for the extremely impatient but knowledgable user

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Grub 2 for the extremely impatient but knowledgable user

    This is not meant to replace the excellent article http://kubuntuforums.net/forums/inde...opic=3106368.0 which is (or at least should be) required reading. However, for those that have even less patience than I do, I propose the following.

    Grub2 For Grubbers.
    A short crash course in Grub2 for Grub-Legacy refugees.

    This is intended to be a quick starter to simply get going in Grub2 so that Grub2 can see what Grub-Legacy saw. No Windows (chainloader) support as I don't use it here but I do use other distros and they are not always picked up properly. This is (for now) a four step process and the second step is the hardest (but not hard).

    Step 1: Collect your information. (/boot/grub/menu.lst)
    Step 2: Convert your information. (Grub-Legacy to Grub2)
    Step 3: Edit one file. (/etc/grub.d/40_custom)
    Step 4: Run one program. (/usr/sbin/update-grub)

    Grub2 Files and Directories:
    /boot/grub/grub.cfg (replaces /boot/grub/menu.lst; not meant to be edited by humans)
    /etc/default/grub (editable by humans; set your default boot here)
    /etc/grub.d/ (scripts editable by humans and read with /etc/default/grub to compile /boot/grub/grub.cfg by using 'update-grub')

    Scripts in /etc/grub.d/
    Except for one, ignore them for now -- this is a short course. Take a look at '40_custom'. Pretty bland. This is where most of the action is for humans to edit.

    Ones and Zeroes.
    In Grub-Legacy zero was always the start of every list, (hd0) was the first hard disk, (hd0,0) was the first partition of the first hard disk, and default=0 was the first "title" in /boot/grub/menu.lst and the default boot.
    In Grub2 one thing (and AFAIK one thing only) has changed.
    The first partition on the first hard disk is now (hd0,1). Don't ask me why it isn't (hd1,1) because I can't tell you. It doesn't seem consistent to me but that's the way it is.

    I assume you know what your partitions are used for (hint: 'cat /etc/fstab') and how many you have (hint: 'sudo fdisk -l').

    Here's an "old school" menu.lst entry followed by it's corresponding 40_custom entry.


    title Debian GNU/Linux, kernel 2.6.26-2-686
    root (hd0,1)
    kernel /vmlinuz-2.6.26-2-686 root=/dev/hda5 ro quiet
    initrd /initrd.img-2.6.26-2-686


    Easy enough. 'title' is a keyword that means something to grub and it will be replaced by 'menuentry'.
    root (hd0,1) means that the boot files are located on the first hard disk, second partition. This will become (hd0,2).
    'kernel' is replaced by 'linux'.
    initrd is still initrd for some reason.

    So, here's the new and improved Grub2 entry into 40_custom.

    menuentry "Debian GNU/Linux, kernel 2.6.26-2-686 (old school)" --class debian --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,2)'
    search --no-floppy
    linux /vmlinuz root=/dev/hda5 ro single
    initrd /initrd.img
    }


    As you can see there's other stuff added. The above works on my system and it may even work on yours with the proper tweaking. Pay attention to every character, especially the braces and the quotes. They are evidently there for a reason.

    OK. The above is just preamble and you will need to use your favorite editor (vim, kate, etc.) to hack your 40_custom file as user root.
    My advice is to draft your change in a separate editor document and then paste it into 40_custom.


    To recount...
    Step 1: Collect your information. (/boot/grub/menu.lst)

    Step 2: Convert your information. (Grub-Legacy to Grub2 as mentioned above)

    Step 3: Edit one file. (/etc/grub.d/40_custom)
    Paste drafted changes into 40_custom (sudo vim /etc/grub.d/40_custom) and save and exit.

    Step 4: Run one program. (/usr/sbin/update-grub)
    And you're done!


    Now go back and look through all that documentation when you have time but hopefully for now you can at least see that old distro once again.

Working...
X