DEVICE=/dev/sdb
VOLUME=MultiBootUSB
# create filesystem on usb pen
sudo mkfs.vfat -n ${VOLUME} ${DEVICE}1
# mount usb
mount ${DEVICE}1 /mnt/
# install grub2 on usb pen
grub-install --no-floppy --root-directory=/mnt ${DEVICE}
# create grub config
cat <<EOF> /mnt/boot/grub/grub.cfg
menuentry "Ubuntu Live 11.04 64bit" {
loopback loop /boot/iso/ubuntu-11.04-desktop-amd64.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-11.04-desktop-amd64.iso noeject noprompt --
initrd (loop)/casper/initrd.lz
}
menuentry "Ubuntu Live 9.10 32bit" {
loopback loop /boot/iso/ubuntu-9.10-desktop-i386.iso