A couple of days ago I wrote this quick script to generate a roughly correct grub.cfg from the contents of a directory filled with .iso files. The goal: generate a USB bootable key that runs GRUB and allows you to choose which ISO to boot. It could be Ubuntu desktop, netbook, etc, doesn't matter, as long as you have enough room on the key.
This is done by leveraging the loopback grub command and the isoscan parameter. But first, setting it up...
You'll need (to):
- one free USB key, formatted to vfat (mkfs.vfat -F 32 /dev/sdX1) the more space the better
- create a directory called "iso" on it
- install grub on it:
grub-install --root-directory=/media/MOUNTPOINT /dev/sdX
- this will create the boot/grub directories and install everything grub needs
- copy iso files to the iso/ directory
- run update-grub.py (available in bzr branch: lp:~mathieu-tl/+junk/bootable-iso-usb) from the key's mountpoint
- Careful: it's only quickly tested, and overwrites boot/grub/grub.cfg from the current working directory.
Sorry for the unimaginative naming of the script.
In short, this script attempts to guess what kind of distribution is in the ISO file. I've tested desktop and alternate with success, both seem to boot and properly get you to an install (or for desktop, "maybe-ubiquity", which means you'll get a prompt for whether you want to run the live session or just ubiquity to install). All this needed was to make use of the iso naming scheme and more importantly of the contents of the ISO files, as read by isoinfo (from the genisoimage package).
Even if it never ends up being of any use, it was at least a fun little thing to write.