Over the past couple of years, I've grown to love using USB sticks to boot Linux installers. Booting from USB is much faster than booting from CD, preparing the USB stick is quicker than burning a CD, and you don't have to throw away the USB stick when you're done with it. This is wonderful for playing with new alpha releases of Ubuntu, for quickly getting started at installfests, and generally makes life much easier.
However (I said to myself one morning), could the process be even better? There have been a few times now where people have wanted different variants (Kubuntu, Xubuntu, Netbook Remixes, etc.) of Ubuntu, and with the standard USB Creator (which is an awesome tool, by the way) method, you can only have one on there at once. Is there some way I could put all of my images on one stick, and preferably have them on there as .iso files so I can also use the stick as a source for burning CDs for people? It turns out that -- thanks to the magic of GRUB2 -- there is!
(Warning: this entry gets a little technical, and involves terminal-fu. One day, maybe, there will be a way of doing this that is normal-person-friendly. Unfortunately, today is not that day.)
-
Format a partition on the USB stick to some filesystem that's supported by GRUB 2 in the way you prefer to do that. I personally used FAT32, with the command
sudo mkfs.vfat /dev/sdc1
. You could also use gparted, if you prefer GUI tools. -
Mount the partition and write down the mountpoint.
-
Install GRUB 2 onto the USB stick. The command I used for that was
grub-install --no-floppy --root-directory=/mnt /dev/sdc
(note: the last parameter is the device, not the partition). You'd put your mountpoint instead of /mnt, and your device instead of /dev/sdc. -
GRUB will automatically make a boot/ folder on the partition. Make a folder to put your ISO files in (I made boot/iso/).
-
Edit boot/grub/grub.cfg to point to the ISO files. You can do this manually, by copypasting this gibberish once for each ISO (replacing the menu name and both references to example.iso):
menuentry "Menu Name in GRUB boot menu goes here" {
loopback loop /boot/iso/example.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/example.iso noeject noprompt --
initrd (loop)/casper/initrd.lz
}I think the above magic only works for *buntu Live CDs. If you're using ISOs of something else, you'll likely have to experiment to find the right settings (feel free to leave a comment so others don't have to ;).
-
You're done! Restart and boot from USB to try it out!
If editing grub.cfg manually for each ISO file feels like a chore, you feel the same way as me. I wrote a small script to do it for me just now that seems to work well, so you might want to try that out. It's at http://rww.name/scripts/create-menu.sh.txt. Open it up and edit the variables at the top to point to the right mountpoint and directories, and note that it will remove any existing grub.cfg on the USB stick, so be careful. If you have any improvements or comments, I'd be happy to hear them; my shell scripting skills are terrible, so it could probably be a lot better.
Now, when I boot from the USB stick, I get a menu with all of the ISOs I have listed in it, and I can boot whichever combination of 32-bit or 64-bit Ubuntu/Kubuntu/Xubuntu/UNE/KNE 9.10/10.04 I want! Phew! The only caveat I've found is that it skips the usual Live CD screen and boots straight into Live mode. If you know a way to get it to not skip it, I'd be interested to hear about it :)
Sources: I got the basic instructions for this from panticz.de, which appears to have gotten the grub.cfg stuff from Michael Prokop.