Installing Grub 2 on a USB flash drive

You got me curious how this would be done. The Pendrivelinux site had a tutorial I did this from my Mint 9 install instead of a live cd as the site suggests.

I started with finding the location of my USB drive in a terminal I ran df it returned the location of the device as

/dev/sdg1   /media/LINUXUSB

after that I ran

sudo su

and then to install grub 2

grub-install --no-floppy --force --root-directory=/media/LINUXUSB /dev/sdg1

I had to use --force additionally, the example on the site did not. Then I did

cd /media/LINUXUSB/boot/grub

The site gave a link to download a copy of grub.cfg to the /boot/grub directory on my USB drive. The link was

wget http://pendrivelinux.com/downloads/grub.cfg

After that I edited grub.cfg to reflect the iso's on my USB drive.

set timeout=10 set default=0

menuentry "Run Fedora" {
    loopback loop /Fedora13.iso
    linux (loop)/isolinux/vmlinuz0 boot=isolinux iso-scan/filename=/Fedora13.iso splash --
    initrd (loop)/isolinux/initrd0.img
}

menuentry "Run Ubuntu" {
    loopback loop /ubuntu-10.04-netbook-i386.iso 
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-10.04-netbook-i386.iso splash --
    initrd (loop)/casper/initrd.lz
}

menuentry "Run Clonezilla" {
    loopback loop /clonezilla.iso
    linux (loop)/live/vmlinuz boot=live iso-scan/filename=/clonezilla.iso splash --
    initrd (loop)/live/initrd.img }

I found that in the different iso's, vmlinuz and initrd were located in a different directory. I was able to get all three to start the boot process; but, only Ubuntu to actually load. If I figure out what I need to get the other two to finish loading, I will add that later. I have not tried any other iso's just these three.


GRUB2 Bootloader Full tutorial is a good place to start on multi boot configurations with GRUB2.
If you are familiar with GRUB, jump straight to the 5th or 6th section.

There is also a Superuser question on Setting up a multiboot system with GRUB.
There is also a Ubuntu MultiOSBoot community page which suggests you should stick to the Legacy GRUB.

The technique works on flash drives too as long as your machine can boot from them.
I have been working off flash drives for some time now.