Dear lazyweb, I would like to download an arbitrary ISO image (say, a Ubuntu 10.04 Desktop CD) into a directory of a USB flash drive, and then make that USB flash drive boot that ISO image. I do not want to
- re-partition or re-format the flash drive (this eliminates usb-creator, AFAIU)
- extract the contents of the ISO image into the root of the USB drive (this eliminates unetbootin)
- skip the ISO's bootloader and directly boot the kernel+initramfs from the ISO (eliminates this recipe, and this recipe)
I just want a bootloader on the USB to read the VFAT filesystem, mount the ISO image as a loop device, then chain-load the bootloader from that ISO. Bonus points for having a menu letting me choose one of several ISO images. Running a script to edit a text file (say, grub's config) to get that menu is fine.
Is this even possible? If not, can I at least have two out of three (no partition/extraction, but skipping intrinsic bootloader is fine)?
Solution that I finally chose (from Ubuntu forums):
Plug in USB key. Find out the mount point (/media/disk) and the device name (/dev/sdx) of the USB key with
$ mount|grep /media
Install GRUB 2 into the USB key with
$ sudo grub-install --root-directory=/media/usbdisk /dev/sdx
If it says something about embedding being impossible and falling back to UNRELIABLE blocklist-based setup, run
$ sudo grub-install --root-directory=/media/usbdisk /dev/sdx --force
Download a CD image, let's say ubuntu-10.10-desktop-i386.iso. Put it into /media/usbdisk/ubuntu/.
Create a text file /media/usbdisk/boot/grub/grub.cfg with
menuentry "Ubuntu 10.10 (x86 desktop livecd)" { set isofile="/ubuntu/ubuntu-10.10-desktop-i386.iso" loopback loop $isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet splash noprompt -- initrd (loop)/casper/initrd.lz }
You can have as many ISO images as you want, just make sure to add a menuentry for each. There's no need to run grub-install again after adding or removing a .iso file. Oh, and if you want to use an ISO file for a different distribution, you'll have to figure out the correct linux and initrd lines somehow.
Update: Ubuntu 13.04 changed the name of the kernel -- use (loop)/casper/vmlinuz.efi instead of (loop)/casper/vmlinuz.
I tested it with the following images
- ubuntu-10.04-desktop-i386.iso
- ubuntu-10.04-server-i386.iso
- ubuntu-10.04-server-amd64.iso
- ubuntu-10.10-desktop-i386.iso
- ubuntu-11.04-desktop-i386.iso
- ubuntu-11.10-desktop-i386.iso
- ubuntu-12.04-desktop-i386.iso
- ubuntu-12.04-desktop-amd64.iso
- ubuntu-12.04-server-i386.iso
- ubuntu-12.04-server-amd64.iso
- ubuntu-12.10-desktop-i386.iso
- ubuntu-12.10-desktop-amd64.iso
- ubuntu-13.04-desktop-amd64.iso
This solution skips the CD-ROM's boot menu. I haven't found a better one.
Update: I wrote a script to generate a grub.cfg for me so I don't have to do it by hand any more.