Sunday, November 8, 2015

GRUB-based multiple iso booting flash drive

With huge USB flash drives of today it is sad that one can't easily put several bootable ISO images on it and have nice on-boot selection menu.

GRUB to the rescue!

Historically GRUB is being used for hard disks and syslinux for floppies and flash drives. But nothing prevents using GRUB for flash drives as well. Here are instructions for creating bootable GRUB-based USB flash drive (disk on key):
  1. Create vfat partition. For big drives you must use fat32 format.
  2. Unpack the http://skliarie.meshanet.com/skliarie_blog/boot.tar.gz onto it. It will create single directory boot on the drive.
  3. Customize boot/grub/grub.cfg file, put iso images accordingly
  4. On linux box, put bootable MBR onto the DOK (for example on /dev/sdf):
    1. mount /dev/sdf /mnt/dok
    2. grub-install --force --no-floppy --root-directory=/mnt/dok /dev/sdf
    3. umount /mnt/dok 

Caveats:

The ISO image must support GRUB-based booting. Specifically it must be smart enough to locate ISO image on the DOK using parameters specified in grub.cfg file.

Latest Ubuntu and Debian based ISO images are known to work.

Thanks to Jonathan Vollebregt there is a way to boot knoppix as well. You will need custom initrd, with your flash drive specific tuning. I built one for mine: knoppix_minirt.gz, you are free to take and modify it according to your DOK and filesystem parameters. Important commands here are:
  1. Unpack the initrd
    gzip -dc /mnt/dok/boot/knoppix/minirt_ska.gz | cpio -i
  2. Modify the init file (put sector numbers that are correct for your DOK)
  3. Compress back the initrd
    find ./ | cpio -H newc -o | gzip -9 -c > /mnt/dok/boot/knoppix/minirt_ska.gz
Please send me GRUB stanzas for other ISO images and I will put them into the grub.cfg file.