In my previous post about booting CDs from a USB stick, I did find a solution to my problem, which is the need to have readily available a few bootable CDs – for rescue, demo and installation purposes. I was not too happy in the end, because the solution I found was incomplete: it allowed me to only boot 4 systems, due to boot loader limitations.
Matei helped me out by pointing me to a email by H. Peter Anvin that broght me back to the path of righteousness and opened my eyes to the correct solution: Syslinux can use chain.c32 to chainload to any partition on any disk, including extended partitons on USB devices
So here is the new and improved guide to booting any number (well, there is a limit, of course, but I don’t think I’ll reach it soon) of CDs off a USB stick.
Step 0. Make sure you got the USB stick device correctly! Mine is usualy /dev/sdc, I’ll use that.
Step 1. Clear any partition table or previous boot loader.
# dd if=/dev/zero of=/dev/sdc bs=512 count=63
Step 2. Create partitions on the stick. A little more explanations here: we will use Syslinux also for the MBR bootloader. However, even when booted from the MBR, Syslinux still requires some files, which it will look for on the first bootable partition that it will find. So you should partition your stick like this:
- partition 1 should be primary and can be any size (even 1 MB, since the Syslinux files are really small). I use this to store my personal files too, so mine is larger. Make sure the type is set to 06 (FAT-16) and is marked as bootable. It will usually be called /dev/device1 (mine is /dev/sdc1).
- the other partitions can be either primary or logical. To keep things clean, I only created logical partitions (also type 06 for FAT-16). Their numbering will start from 5.
Step 3. Format all the partitions you created and give them nice labels.
# mkfs.vfat -n BootFiles /dev/sdc1
# mkfs.vfat -n SysResCD /dev/sdc5
# mkfs.vfat -n UbuntuSvr /dev/sdc6
And so on, repeat for all the partitions.
Step 4. Copy the files from the ISO files to the USB stick.
# cd /tmp
# mkdir part5 iso1
# mount /dev/sdc5 /tmp/part5
# mount -o loop /location/of/iso1.iso /tmp/iso1
# cd /tmp/iso1
# cp -R * /tmp/part5
Repeat for all the partition-iso pairs.
Step 5. Move the menu system of each CD where Syslinux expects it (in the root of each partition, and the filename is syslinux.cfg)
# cd /tmp/part5/boot/isolinux
or
# cd /tmp/part5/isolinux
(dependind on the case)
# mv -f * /tmp/part5
# cp /tmp/part5/isolinux.cfg /tmp/part5/syslinux.cfg
Repeat for all the partitions.
Step 6. Make the partitions bootable by installing Syslinux on each.
# syslinux /dev/sdc5
# syslinux /dev/sdc6
Repeast for all the partitions.
Step 7. Install Syslinux on the MBR of the USB stick, and copy its needed files.
# cat /usr/lib/syslinux/mbr.bin > /dev/sdc
# syslinux /dev/sdc1
# mkdir /tmp/part1
# mount /dev/sdc1 /tmp/part1
# cp /usr/lib/syslinux/menu.c32 /usr/lib/syslinux/chain.c32 /tmp/part1
Step 8. This is the final step! You need to create the following file, named syslinux.cfg, in the root of partition 1:
ui menu.c32
prompt 0
menu title Sample Menu
menu autoboot Starting first option in # seconds
timeout 300
totaltimeout 9000
label sysrescd
menu default
menu label System Rescue CD
kernel chain.c32
append boot 5
label ubuntusvr
menu label Ubuntu Server
kernel chain.c23
append boot 6
Create labels and menu entries for all your partitions, of course.
And that’s it! You now have a bootable USB stick with a menu that will allow you to choose which of the other partitions you want to start, the it will execute the original menu of each CD. This is the complete solution that I was looking for!
Just for reference, I am using a Kingston DataTreveler 4GB USB stick, with one primary partition and 8 logical partitions that allows me to boot the following CDs:
- SystemRescueCD
- DamnSmallLinux
- Ubuntu Netbook Remix
- Ubuntu Desktop
- Ubuntu Server 32 bit
- Ubuntu Server 64 bit
- Debian 32 bit (netinstall)
- Debian 64 bit (netinstall)
Sis. fișiere Dim Uz Liber Uz% Montat pe /dev/sdc1 361M 104K 361M 1% /media/SYSTEM /dev/sdc5 259M 248M 11M 96% /media/SysResCD /dev/sdc6 63M 50M 14M 80% /media/DSL /dev/sdc7 698M 683M 16M 98% /media/UbuntuNRmx /dev/sdc8 714M 692M 22M 97% /media/UbuntuDesk /dev/sdc9 659M 658M 848K 100% /media/UbuntuSvr32 /dev/sdc10 683M 675M 7,7M 99% /media/UbuntuSvr64 /dev/sdc11 181M 151M 30M 84% /media/Debian32 /dev/sdc12 236M 132M 104M 57% /media/Debian64
Of course, now I want to get my hands on a 16 GB (or more) stick
.
Enjoy
What you think about this solution? Write to me in the comments section!
PS: For my Romanian readers, there’s a new post of NOVIT news’ selection, that you can read here!
Image credit: Ambuj Saxena.
Related posts:







[...] you’ve read my previous post about booting multiple CDs from a USB stick and the one before it, you know that I need to have multiple live or installer CDs with me almost [...]
[...] you’ve read my posts about booting CDs from a USB stick (with ext2 partitions too) and the problems that I encountered, you know that I was pretty [...]
[...] using my method for booting multiple CDs from a USB stick (with ext2 partitions) (see also the version with FAT16 partitions, you most likely encountered the error “No common CD-ROM drive was detected.” [...]