PDA

View Full Version : HOWTO: Boot everything with grub


loomsen
July 6th, 2009, 01:05 PM
Hello.

I actually answered this to a question, but I think this will be useful for some more people as well.

This will show how to install additional distributions and boot them without changing your system (I won't explain partitioning, I'm sure you will be able to find some proper howto if you need it)

Here we go. If you plan to install another distribution besides your current, you may, and you should choose where to install the bootloader to in almost every distros installer.

Either don't install any bootloader at all and adjust your grub menu to boot the kernels, or install the distros native bootloader to the root partition rather than the MBR.

The MBR is the first sector of your harddrive, so it won't have a partition number.
Grub annotation:
(hd0)

which equals

/dev/sda

So, alter the location to install the bootloader to during installation to be

/dev/sda7
for instance if your suse root is on sda7.

NOTE: in grub annotation this would be
(hd0,6)

If you choose to go without any bootloader install, your grub menu should look like:
NOTE: kernel and initrd located in <partition>/boot/vmlinuz

title bluewhite64
root (hd0,7) ## <-- setting the root partition
kernel /boot/vmlinuz root=LABEL=bw64 acpi_osi="Linux" vga=791 quiet
initrd /boot/initrd


If you choose to install to your root partition, your entry to your existing grub would be


title bluewhite64
rootnoverify (hd0,7)
chainloader +1


This will switch to the specified partition and launch the bootloader installed onto the partitions first sector.

For my USB to boot from my current grub I use:
NOTE: my USB stick holds the links to the kernel and the initrd in <stick>/ as opposed to bluewhite above where these are in /boot/

title debian USB
root (hd1,0)
kernel (hd1,0)/vmlinuz ro root=LABEL=usb acpi_osi="Linux" vga=791 quiet
initrd (hd1,0)/initrd.img


which is a bootstrapped debian system I pulled in inside a chroot. So not even an installation is required...
Just need to make sure grub recognizes the stick as well, so
/boot/grub/device.map

has to include the proper information for grub. This is


(hd0) /dev/sda
(hd1) /dev/sdb ##<-- added this to boot from USB without choosing USB boot from my BIOS menu

Additional notes you might want to know as well:
The first specification of
root (hdX,Y)
changes to the drive containing your kernel (vmlinuz), checking it in ro, initializing your CPU, pci devices etc, then the second
root=LABEL or root=/dev/sdXY or root=UUID ## NOTE: use the LABEL option for ease of use, just add LABELs to all your partitions.
changes the root partition to <specified> and remounts your kernel rw and finally boots up your system using the order and modules specified inside the
initrd.img
it is pointed to.

This is my whole grub.conf, including all different options

# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda7
# initrd /initrd-version.img
############## test #############
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
## My main OS
title Fedora (2.6.29.6)
root (hd0,0)
kernel /vmlinuz ro root=LABEL=fedora acpi_osi="Linux" vga=791 quiet
initrd /initrd
title bluewhite64
root (hd0,7)
kernel /boot/vmlinuz root=LABEL=bw64 acpi_osi="Linux" vga=791 quiet
initrd /boot/initrd
title sidux
rootnoverify (hd0,8)
chainloader +1
title debian USB
root (hd1,0)
kernel (hd1,0)/vmlinuz ro root=LABEL=usb acpi_osi="Linux" vga=791 quiet
initrd (hd1,0)/initrd.img

jpeddicord
July 7th, 2009, 02:04 PM
The device names won't always be the same. /dev/sda on one system might by /dev/sdb on another. Anyway, approved, thank you for your tutorial contribution! :)