BlogGallerieÜber michImpressum

Daniels Blog

Multiboot Linux USB-Stick

First, if you want to do it yourself and brick anything using this guide, don't make me responsible: THIS COMES WITH ABSOLUTELY NO WARRANTY!

I tested this method with 2 different ubuntu versions and it works like a charm even on Mac Minis with EFI!

For this, you have to be root on the system. I've used Debian Wheezy and installed the following packages:

aptitude install syslinux p7zip-full dosfstools

I presume that your usb stick is already available in Linux.

So, check which device it is:

fdisk -l

Then partition it (mine was /dev/sdb) using fdisk:

fdisk /dev/sdb

I've then created a new empty dos partitiontable using 'o' command. Create new partitions using 'n' command and be sure that they have a size of 800 MB to have enough space for everything. After creating the partitions you should change the type of each to FAT32 LBA (type c). You can change the type using 't' command, select the partition and then put in 'c' as the type. The first partition should also have the boot flag enabled, which can be done using 'a' command.

After that format each partition with mkfs.vfat, like this (replace the X with the partition number):

mkfs.vfat /dev/sdbX

Install syslinux into mbr of the USB drive:

dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr.bin of=/dev/sdb

mount the first partition, the initial boot partition and put a syslinux config there:

mount /dev/sdb1 /mnt
cd /mnt
cp /usr/lib/syslinux/menu.c32 .
cat <<EOF >syslinux.cfg
TIMEOUT 600
PROMPT 0
DEFAULT menu.c32
MENU TITLE MultiBoot
ONTIMEOUT first
LABEL first
MENULABEL FirstOS
COM32 chain.c32
APPEND boot 2
LABEL second
MENULABEL SecondOS
COM32 chain.c32
APPEND boot 3
EOF
cd ~
umount /mnt

the fowolling has to be done for each iso/partition:

install syslinux into partition boot sectors:

syslinux -i /dev/sdbX

mount the partition and go there:

mount /dev/sdb2 /mnt
cd /mnt

put the iso's content onto the mounted partition:

7z x <path to iso>

now convert isolinux to syslinux:

mv isolinux syslinux
rm syslinux/isolinux.bin
mv syslinux/isolinux.cfg syslinux/syslinux.cfg
cp /usr/lib/syslinux/vesamenu.c32 syslinux/
cp /usr/lib/syslinux/menu.c32 syslinux/
cp /usr/lib/syslinux/gfxboot.c32 syslinux/
cp /usr/lib/syslinux/chain.c32 syslinux/

unmount the partition and prepare the next one or reboot:

umount /mnt

Thanks to:

{{comment.user}}{{comment.text}}