Versatile USB Boot Stick

After trying for a long time I finally have my USB Stick boot everything I want: any Linux ISO & a Windows installer.

To make the USB stick still behave properly with Windows the NTFS partition needs to be the first partition. The bootloader, Syslinux/Extlinux in this case, goes onto a second partition which I formatted with ext2. This partition gets the `bootable` flag. From my experience it's not necessary to write a bootloader to the MBR because the BIOS loads the PBR of the first partition marked as active/bootable.

The first thing to do is partitioning the drive properly. I created a 28.8 GiB NTFS partition for the Windows Installer and other files and a 700 MiB ext2 partition for Syslinux and a small Linux ISO or two. Don't forget to set the `bootable` flag.

When putting the Windows installer onto the drive make sure you remove the `bootable` flag from the NTFS partition again or the bootloader on the second partition won't even load. To get the Installer onto the Stick I used the Windows 7 USB/DVD download tool. There probably are other ways too but this one is simple and works (assuming you have a working Windows installation).
This step doesn't have to be done first, but it's as good as anything.

Now for the Syslinux part. Mount the second partition of the USB drive and install Syslinux with the `extlinux` command. You also have to copy the required Syslinux executables over. Those are menu.c32, chain.c32 and memdisk and can be found in /usr/lib/syslinux.
$ mkdir -p /mount/usb/boot/syslinux $ extlinux -i /mount/usb/boot/syslinux $ cp /usr/lib/syslinux/{menu.c32,chain.c32,memdisk} /mount/usb/boot/syslinux

Now for the Syslinux configuration. Here's a rather minimal one:
# 2 minute timeout TIMEOUT 1200 # text menu UI menu.c32

# ISOs that are on the stick
INCLUDE isos.cfg

# chainloading the NTFS partition
LABEL ntfs-chain
MENU LABEL Chainload NTFS Partition
COM32 chain.c32
APPEND hd0 1

This can already chainload the NTFS partition, the config for the ISOs is included because it will be generated by a shell script.

Next, the ISOs go into boot/isos/. update-isos.sh, which goes into boot/, will generate the Syslinux menu for the ISOs in boot/syslinux/isos.cfg. Here's the script:
#!/bin/bash echo -n "" > syslinux/isos.cfg cd iso for iso in *.iso; do echo "LABEL arch-iso MENU LABEL $iso LINUX memdisk INITRD ../iso/$iso " >> ../syslinux/isos.cfg done

Now put some CD image in there, run the script and give it a try. Be aware though that the ISO will be loaded into memory when booting it. This makes it easy to add new images and also makes the boot/installation process a lot faster once it's been copied to memory.

Here's the download of the config & script