Convert Microsoft to LINUX: Intro to GRUB (Multiboot Pendrive Linux)

Introduction to GRUB (Multiboot Pendrive Linux)

Things have changed a lot in the last 7 years since I updated this page last. Things are much easier today. There is now GRUB2 which replaces the old GRUB. grub2 automatically detects what operating systems are there by going through all the partitions and generates a nice boot menu for you. Also today we have USB2 drives which can be 8, 16 or even 32 Gig. Luckily Pendrive Linux has come along from France to help us.

Follow this procedure to create your multiboot pendrive linux USB stick:

  1. Use the GNOME Partition Editor to format your stick of preferably 8 or 16 Gig so we can get at least half a dozen Linuxes on there please.
  2. Use FAT32 to format the entire stick that is make it all one partition. Make sure you select the proper device and not instantly reformat your own hard drive. Be careful!
  3. Now type:
    wget http://liveusb.info/multisystem/install-depot-multisystem.sh.tar.bz2
    use bzip2 -d install-depot-multiboot.sh.tar.bz2
    to unzip it. You will then have file with just a .tar extension which you can then untar with
    tar -xvf install-depot-multiboot.sh.tar
  4. Now execute the shell file, you want to be root when you do this:
    ./install-depot-multiboot.sh
    This will install the MULTISYSTEM multiboot module which uses grub2 and comes with a lot of nice tools. It is awesome.
  5. Begin by dragging your favorite iso linux files onto the bar after clicking on the MULTISYSTEM icon under applications. Note, do not browse for the .iso file but drag it over. There is a bug and it will not work , when you browse, but the dragging works great. You will be prompted for the root password twice. Enter it and away you go.
  6. Now, test by hitting F2 after rebooting to make sure you boot from the stick. You should see the one iso there you entered as a choice along with a Grub for Dos and a few other choices such as Syslinux
  7. Keep repeating these procedure adding more systems via iso files. If you want to delete an iso, you need to click on the blue eye icon on the left and then on the right a check box will open with four columns . You can then check to delete the iso file. It will again prompt you for your root password and remove the entry.
  8. Note, some entries may not be installed in the normal grub2 type menu but instead in the Grub for Dos menu. This happened with Antix Linux which is meant to be installed in DOS actually.
  9. Please let me know if you have any problems. Here are some further instructions

Old Grub before 2008

Here, is a brief document I presented to the Bellevue Linux Users Group introducing GRUB in 2007. It is a good starter for the technical information that follows. Warning, do not mix Partition Magic, System commander or other boot managers with GRUB. There should be only one boot manager, as in only one boss.

This is an example of how to boot multiple Linux systems on one machine. Start off by picking one system to install and taking all the default options. In this case, I started with the Ubuntu Warty Hog GNOME version. I simply let it do the formatting on a 60 Gigabyte hard drive. It decided to put everything in one partiion of 60 Gigabytes and also make this partition the primary boot partition. This is not the most ideal way to do it. You could make this a lot stronger by having a partition for the /boot directory, for the / (root) directory and for the /home directory. Since I am installing eight operating systems on this machine, I chose not to do that. This was the menu.lst file that was created as a result of this located in /boot/grub directory:

# grub.conf generated by anaconda
# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 10

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu

# Pretty colours
#color cyan/blue white/blue

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hda1.
title GNOME Warty Hog Ubuntu, kernel 2.6.8.1-3-386 (on /dev/hda1)
root (hd0,0)
kernel /boot/vmlinuz-2.6.8.1-3-386 root=/dev/hda1 ro quiet splash
initrd /boot/initrd.img-2.6.8.1-3-386
savedefault
boot


# linux installation on /dev/hda1.
# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hda1.
title GNOME Warty Hog Ubuntu, kernel 2.6.8.1-3-386 (recovery mode) (on /dev/hda1)
root (hd0,0)
kernel /boot/vmlinuz-2.6.8.1-3-386 root=/dev/hda1 ro single
initrd /boot/initrd.img-2.6.8.1-3-386
savedefault
boot


To continue to install operating systems we must do the following:


  1. Allocate enough space for the next operating system. I used 8 Gigabyes and the GNOME Partition Editor . Note, all partitions were formatted using the ext3 native Linux File system. I simply made the first partition of 8 Megabytes bootable primary and continued adding more 8 Megabyte logical partitions. I did not reformat the primary parition as it already had Ubuntu Linux on it. However, I did resize it to 8 Gigabytes. I also recreated a swap partition of 1 Gigabyte on /dev/hda5 . This was done automatically by the install of Ubuntu.


  2. Next I installed the second operating system of Kubuntu , a newer version of Ubuntu using the KDE Desktop. This only took 15 minutes. Do the custom partitioning and mount the root (/) on the next logical partition.For me this was partition /dev/hda6 as /dev/hda5 was the shared swap partition for all the Linux operating systems.


  3. Be sure to not overwrite the MBR (Master Boot Record) when you are prompted for installing the boot loader using GRUB. However, if you do you can always reboot into whatever operating system is current and log in as root. Then type:

    cd /boot/grub
    vi menu.lst

    You can then edit the menu.lst file using vi (Visual Editor) to match the appropiate logical device for that version of Linux. If you are not comfortable with vi , you can use something else.


  4. The next step is to go back to the GNOME Partition Editor and make sure the appropiate space is allocated in the next logical drive for the next operating system. Click here to see a picture of how the hard drive was partitioned.


  5. When you are all done you should have something like this: menu.lst for six different Linux Operating Systems, one Microsoft Windows XP and one Solaris.
    If eight is a little, much for you here is an example with just two operating sytems: Windows XP and Suse Linux : menu.lst

    Here is a further example with seven Linuxes, one MS Windows XP and NO Solaris: menu.lst without Solaris


  6. Note, the last system installed was Feisty Ubuntu

  7. There is one last step here of creating a boot floppy with GRUB on it and your menu.lst .
    Put a disk in your floppy drive and type:
    fdformat /dev/fd0
    mke2fs /dev/fd0
    in Red Hat or Centos type
    grub-install '(fd0)'
    cp /boot/grub/menu.lst /mnt/floppy/grub/menu.lst
    Note for some systems the directory for the mounted floppy is:
    /media/floppy instead of /mnt/floppy so change the above line accordingly.
    To test, reboot with the floppy and you should get the same menu you are used to.
    If you get the error 602 no disk boot record it means that the mbr (Master Boot Record) was not created on the floppy.

  8. Here is another way to create the boot GRUB floppy that should be fool proof. As above type
    fdformat /dev/fd0
    mke2fs /dev/fd0
    Now mount the floppy and create a directory called /boot
    and /boot/grub .
    Let us assume you are using Suse Linux .
    mount /dev/fd0 /media/floppy
    cd /media/floppy
    mkdir boot
    cd boot
    mkdir grub
    cd grub
    You should now be in the directory of
    /media/floppy/boot/grub
    now type: cp /boot/grub/* .
    Note, this is overkill, all you really need is the menu.lst
    stage1 and stage2 files.
    Finally type: grub to launch the grub program. Then type:
    grub> root (fd0)
    grub> setup (fd0)
    grub> quit
    You should see something saying sucessfully done .

  9. Ok, to be totally fair with all this GRUB stuff, you can even boot with Microsoft Windows operatings system too! Let me defer to a colleague and friend Ivan Kanis, who can show you how here.

  10. I actually installed Microsoft Windows XP so the procedure was slightly different. First I took the Ubuntu that was on /dev/hda1 and moved it to /dev/hda2 using the Gnome Editor mentioned earlier. I changed the menu.lst file to reflect the new locattion for Ubuntu and all worked fine. I then created two FAT-32 partitions, one on device /dev/hda1 the boot partition and one on /dev/hda12 which will hold the Microsoft Windows XP. In order for the hard drive to boot into this first primary petition, I needed to install DOS on it. I installed FREE DOS . I then typed:
    sys c:
    Microsoft Windows XP installed fine, thinking my machine had only two drives of C: which is the primary boot drive containing the files to launch Microsoft Windows XP and D: on /dev/hda12 where Microsoft Windows XP is actually installed to. The last step is to reinstall grub on the hard drive using:
    grub-install /dev/hda
    You may get an error saying /usr/lib/stage1 not found
    In that case simply type this:
    cp /boot/grub/sta* /usr/lib
Enjoy!

Old Yaboot for the MAC G3/G4 from 2005

Lastly, for you MAC folks , there is a yaboot loader which works almost identically to the GRUB bootloader . In order to use it, you have to:

  1. Go back to your MAC install disk and format two HFSPLUS partitions. The first one will be for Linux (Ubuntu) and the second one will be for the MAC OSX operating system. You can use the Partitioner on the MAC Install disk to do this.
  2. Next install your MAC operating system.
  3. Put the Ubuntu or other MAC PowerPC disk in the CD drive and reboot holding down the 'c' key to force a boot off the CD.
  4. As part of the Linux Ubuntu install a GParted will appear very similar to the one used on the PC. Format the usual Linux Swap partition, a partition of ext3 to install Ubuntu to, plus a small partition of 1 Meg which will be converted to a Newworld Bootstrap Partition. For now just give this tiny 1 Megabyte partition an ext3 format.
  5. Go to a terminal prompt, type sudo su and you should automatically be root. Then type:
    mac-fdisk -l
    You should see something like this:
    /dev/hda
    # type name length base ( size ) system
    /dev/hda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
    /dev/hda2 Apple_UNIX_SVR2 swap 1048577 @ 64 (512.0M) Linux swap
    /dev/hda3 Apple_HFS MAC 100608968 @ 16622432 ( 48.0G) HFS
    /dev/hda4 Apple_Bootstrap bootstrap 1600 @ 1048641 (800.0k) NewWorld bootblock
    /dev/hda5 Apple_UNIX_SVR2 untitled 15572191 @ 1050241 ( 7.4G) Linux native
    /dev/hda6 Apple_Free Extra 8 @ 117231400 ( 4.0k) Free space

    Block size=512, Number of Blocks=117231408
    DeviceType=0x0, DeviceId=0x0
    Pay particular attention to /dev/hda4. Notice it now says already NewWorld bootblock. Since you have not yet done this, it will have a type of ext3 and will actually be 1 Megabyte instead of 800 Kilobytes. You will have 200 Kilobytes extra when done, which can be deleted using the
    mac-fdisk
    as detailed below.
  6. You can type now
    mac-fdisk /dev/hda4 and then you will get a ? prompt.
    Follow the steps as outlined in mac-fdisk devicename here to delete the partition that will become the NewWorld Bootstrap partition using the d at the ? prompt
    and then create it using the b at the ? prompt.
  7. After installing Ubuntu edit the /etc/yaboot.conf file and type
    defaultos=macosx
    at the top.Then at a root prompt type:
    ybin -v
    This will install the yaboot bootloader. Now you are done. Your yaboot.conf file should look something like this.