Creating a multiboot USB stick using syslinux

Creative Commons License

aLive Multiboot USB

Outcome: To create a USB stick that contains multiple GNU/Linux (Linux) distributions using syslinux as the boot loader.

Last Update: 18th February 2014

I love to play around with different Linux distributions; I find certain ones to be better suited at certain tasks, but having to switch between, and carry around, a key chain full of USB stick is not really practical, or something I can afford.

Thankfully, syslinux allows me to easily create a single, multi distribution USB stick, which is my little geeky life saver: whenever I’m asked to do a bit of repair work on a friends computer, I can bring along a single stick full of maintenance goodness; and also, if I’m away from home and don’t have my laptop with me, I can boot up my beloved, live version of Arch Linux customised with all my usual programs and files (see my ‘howto’ if you’re interested).

How To

I’m going to assume that you are sitting in front of an Arch Linux box to create the USB; however, these instructions will, well should, work no matter what operating system you are using (read: *nix); I will try to point out any OS specific points.
The process is quite simple. It basically amounts to: formatting the stick, installing syslinux and the MBR, copying the distribution over, and creating a configuration file.

First, install syslinux with your package manager to your OS. We are not installing syslinux to the disk, just grabbing the files so we have them to hand. The mtools package is also required.

Arch Linux (root)#: pacman -S syslinux mtools
Debian (root)#: apt-get install mtools

The syslinux files will be installed to /usr/lib/syslinux/bios/, some distributions may install them to /usr/lib/syslinux/, or /lib/syslinux.
For this tutorial, I’ll assume they are located within /usr/lib/syslinux/bios.

Next, plug in your USB stick. You’ll want to completely format it, and create at least one partition with FAT32, marked ‘bootable’, which is where the distros shall live (I’ve not had much luck with ext, yet).
If you create more than one partition, make sure that this FAT32 distro partition is the first.
On my 8GiB USB, I’ve created two partitions: the first being a 4GB FAT to hold the distros, and the second being an encrypted (Luks+Ext4)  partition where I can hold my private data.

I’ll assume you are aware on how to partition a disk using *nix tools such as fdisk and cfdisk.
If not, gparted and qtparted makes the process quite simple, but if you get stuck just leave a comment.

Once complete, mount the first partition of the USB and create a directory called “syslinux” at the root of it.

(root)#: mount /dev/sdX1 /mnt/
(root)#: mkdir /mnt/syslinux

Install syslinux to the first partition of the USB:

(root)#: syslinux -d syslinux -i /dev/sdbX1

Now install the MBR (Master Boot Record) to the USB itself (not the partition. ie. don’t add a number after sdX).
The MBR file we need is located in the same place where syslinux was installed earlier (either: /usr/lib/syslinux/mbr.bin, or /usr/lib/syslinux/bios/mbr.bin, or /lib/syslinux/mbr.bin):

(root)#: dd conv=notrunc bs=440 count=1 if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sdX

That takes care of syslinux, well for the most part. Now you want to copy over the Linux distributions you want.
I’ll assume you’ve downloaded some Linux ISOs.
Once you have, you’ll want to mount the ISO somewhere so you can get to it’s files. I’ll assume here that distro.iso is the distribution you’ve downloaded, and /media will be the mount point.

(root)#: mount -t iso9660 -o loop,ro distro.iso /media

If you take a look in /media, you’ll see the contents of the ISO file. Now here is where it starts to get a little tricky.
Each distribution will have their own way of laying out the files. Normally you will have a folder which contains OS files (such as the kernel, initrd, and the filesystem(s) in a squashfs format), and a folder which contains all the syslinux/isolinux related files.

Create a new directory at the root of your USB with a brief name of the OS your are going to copy over, for example for BackTrack:

(root)#: mkdir /mnt/backtrack

Now copy over everything from mounted ISO file, to this newly created folder.
If there is a syslinux or isolinux folder at the root of the mounted ISO you can ignore copying that over, but if you are unsure just copy  everything, so, again using BackTrack as an example:

(root)#: cp -r /media/* /mnt/backtrack

Do this process for all the distributions: creating a new directory at the root of the USB, mount the ISO, and copy the files over.

All that is required now is to create a syslinux.cfg file which is the configuration file for the menu you see when you boot the USB.
You can either have a basic command line based boot loader (probably not what you want), or a pretty GUI so you can easily select the distribution to boot.

There are a number of other files which syslinux depends on, so I strongly recommend you copy everything from the syslinux directory to the USB (you can copy just the ones you need if you know which). Again, these files may be located in /usr/lib/syslinux, /usr/lib/syslinux/bios, or /lib/syslinux/, so adjust the command as necessary.

(root)#: cp /usr/lib/syslinux/bios/*  /mnt/syslinux

Next, we need to create the syslinux.cfg file which holds all the entries for the distributions on the USB. You can use this one (obtained from the Arch Linux Wiki) as a good starting point.
Save this to the syslinux directory on the USB (/mnt/syslinux/syslinux.cfg).

What you need to do is copy the relevant syslinux entries from all ISOs, paste it into the syslinux.cfg you’ve just placed on the USB, and modify the paths slightly.

For some distributions, this is a straight forward process, for others, if they use complex syslinux menus, it can require a bit of searching and thought.

When you mount the ISO, have a look for a syslinux/isolinux directory. It can sometimes be located within a boot folder, or sometimes, as in the case of BackTrack, at the root.
Once you’ve found it, you’ll then want to look for the relevant file which has the menu entries.
Again, for some distributions, such as BackTrack, the syslinux.cfg will be what you are looking for; others maybe using isolinux so you’ll have to look for an isolinux.cfg file; for others, there may be many files and it may be unclear as to which ones contain the menu entries.
You will need to go through all the *.cfg files and look for the entries that is responsible booting the system, and contain references to the kernel (normally called vmlinuz), and the inital RAM disk (normally called initrd).

For BackTrack, the syslinux.cfg has multiple entries for booting into different modes (normal, fallback, stealth, etc).
Copy one, or all if you want them, of the entries to the the syslinux.cfg file on your USB (/mnt/usb/syslinux.cfg).
As we have created multiple directories on the USB to hold each distribution, you’ll want to modify the paths to the lines calling the kernel, initrd (and any thing else it expects) to fit in with our layout.
This will normally just amount to appending a forward slash ‘/ along with the name of the directory you created to the beginning of the kernel and initrd paths.

For example. With BackTrack, this is one of the entries from the original syslinux.cfg that came from the mounted ISO:

label DEFAULT
menu label BackTrack Text – Default Boot Text Mode
kernel /casper/vmlinuz
append  file=/cdrom/preseed/custom.seed boot=casper initrd=/casper/initrd.gz text splash vga=791–

As all the files for BackTrack are now stored within the new folder (‘backtrack), all references to the files it needs has to be changed.
Here’s the working, modified version:

label DEFAULT
menu label BackTrack Text – Default Boot Text Mode
kernel /backtrack/casper/vmlinuz
append live-media-path=/backtrack/casper boot=casper initrd=/backtrack/casper/initrdf.gz text splash vga=791–

Note here that I’ve added an extra line (“live-media-path”), you will not need to add this most distribution; BackTrack (and some other Debian based ones) are a little picky in the way they boot, and that is just a quick fix.
Do the same process for each distribution: mount the ISO, find the syslinux entries, and copy them to your syslinux.cfg.

That should be it. Reboot your machine with the USB stick in, make sure your BIOS is set to boot from it, and all should work.

If not, feel free to post a comment and I’ll give you a hand.

Spare change? :)
Bitcoin: 1An5GQ8atkzUxJMFXU42Dfcq1RzSvNHK6A
Litecoin: LSERj49g1ywBTCFcNhxrsPPcHBcehSN8EB
DOGE: DP9gA9xkSz1ZR6Wh9UjN1WcLaoDuFJhgfg

17 thoughts on “Creating a multiboot USB stick using syslinux

  1. J says:

    Hey thanks so much for the How To… I just need help with the last section… This is what I have so far

    LABEL
    MENU TEST
    KERNEL TEST123/file.bss
    APPEND

    When I try to boot the file.bss it start loading the files but it can’t find them because is looking for the files inside the root of the usb but all the files are inside another folder (test123) how can I tell the file.bss to look/load the file from that particular folder? is more than 1 file that it need to load

    • Hey, you need to add a forward slash / to the beginning of the path, so:
      TEST123/file.bss will become /TEST123/file.bss.

      If you leave off the forward slash, syslinux will look for the files within the current directory (which will be where syslinux is located); the forward slash tells it to look at the root of the USB.

  2. Mike Cloaked says:

    This looks like a nice guide – I have been having a problem trying to make a bootable usbkey to run a firmware update for Crucial mSATA SSD from the page at http://www.crucial.com/uk/help/ssd/index.aspx?source=web (select mSATA SSD from the pulldown list) – I have been trying to make a bootable key from the downloaded iso using several different methods including running unetbootin – but nothing I have tried gets booted on my machine (an Intel DQ77KB motherboard) – though a bootable Parted Magic iso made into a usbkey using unetbootin works fine! So I presume there is something oddball about the firmware update iso – which has memdisk and a floppy image as a .img file in it.

    I have been tearing my hair out trying to get it to work but maybe your method might lead to a usbkey that will boot on my system!

    Thanks for any advice.

  3. Mike Cloaked says:

    I ran through the technique you described – (from my arch linux laptop) – but I either did the specifications wrong in my syslinux.cfg or maybe put the paths wrong to link into the directory where the copy of the files from the iso went – either way it fails to do anything at all when I boot the key! Yes on the same machine the archiso usbkey written with dd boots just fine! So I will await any useful hints and tips!

    • After a bit of trail and error I’ve managed to get the firmware update to boot, here’s how:
      -Assuming a freshly formatted USB stick with one partition using FAT32 **marked as bootable**:

      1) Mount the USB and the ISO image some where (I’ll assume /mnt/usb and /mnt/iso)

      2) Follow the first three commands above to create the syslinux directory, install it, and install the MBR

      3) Create the folder “crucial” on the root of the USB.

      4) Now copy everything from within the isolinux directory in the ISO to BOTH the “crucial” and “syslinux” directory on the USB, (you may only need to copy the boot2880.img & memdisk files to the “crucial” folder, but I haven’t tested this, just copy everything to both locations to be safe). So:
      —cp /mnt/iso/boot/isolinux/* /mnt/usb/crucial/
      —cp /mnt/iso/boot/isolinux/* /mnt/usb/syslinux/

      5) Within /mnt/usb/syslinux, move (rename) the “isolinux.cfg” file to “syslinux.cfg”
      –This could be where you had a mishap. Some images will use a variant of SYSLINUX called ISOLINUX.
      They are essentially the same thing, but the differ in where they store the boot information.

      6) Now edit the syslinux.cfg (/mnt/usb/syslinux/syslinux.cfg) file, and append “/crucial/” to the initrd path.
      –The file should now look like this; http://codepad.org/YireZGsQ

      Hope that helps, it booted find on my system, just don’t forget to make the partition bootable.
      If you need any more help just let me know.

  4. Mike Cloaked says:

    Thanks for the additional hints – I will try it in a few days – I have had to build a new system as a relative’s computer had a hard disk failure yesterday so it will take a few days to sort that out.

    One additional thing that I discovered that may be an issue for me is that I have learned that some bioses don’t see the usb key during boot as in the same mode as on other machines! There are apparently 4 different modes – usb-hdd, usb-fdd, usb-zip and usb-cdrom. I have only just discovered this and I don’t know much about it – but apparently this can lead to a usbkey which boots perfectly well on one machine not booting at all on another where the bios is buggy! Anyway once I can get back to this I will try your method and see if I can glean any more information about these strange usb connection modes. I have seen some methods for making sure that the largest number of bioses will see the drive as usb-hdd and boot it but I have not had time to look into that.

    • Ouch. You should give SpinRite a try (https://www.grc.com/spinrite.htm); it’s extremely good at recovering from even the worst hard disk failures to recover data and get the system bootable. It’s not free, but you can find it on some torrent sites to see if it works before you buy.

      I’ve noticed the same thing on some BiOSes (as with my own), and it’s never been an issue; the USB flash drive is recognised and boots as a USB-HDD.
      I’ve only had the issue of one of my flash drives not booting on a BIOS like this and that was a fairly modern PC.

  5. Mike Cloaked says:

    Actually the system that broke was an old Fedora system and the new system is Arch Linux – so the only files from the old system were some user files that were kept on backup, and a few config files which were also in backup. So nothing needs retrieving from the old machine – though I have had a total disk failure before where, just like this occasion, the disk problem prevents the system firing up at all until the old disk is removed and a new fresh HD put in to replace it! So it is just a question of time building the new system and then copying back the user files that are needed into the user area concerned.

    Hard drives sometimes last up to 10 years but others only 2 or 3 years. I guess that in the past decade I have had 3 or 4 occasions where the HD has totally failed – always 7200rpm drives and different Brands. So it is pot luck as to how long drives seem to last! Having regular backups is the only really safe way to work!

    I will get back to the SSD boot issues within the next week or so I hope.

  6. Mike Cloaked says:

    After spending some time away to build the new system I mentioned I finally had some time to revisit the bootable key issue – it turns out that in the interim since I was last working on this Intel has released a BIOS update to my motherboard. Tonight when I checked the Intel website tonight for BIOS updates it turns out that, between when I built the machine and today, Intel released a BIOS update that fixed a whole tranche of bugs including ” Updated VBIOS to fix issue where there is no display in DOS.”

    So I downloaded the BIOS update file – and updated the motherboard BIOS. Then I put the Crucial SSD firmware update file onto a bootable usbkey – and booted the system, selecting the usbkey for the boot – it DID boot perfectly well into the Crucial SSD firmware update just fine – so both my SSDs now have the current latest firmware….. so all the problems I had failing to update the SSD drives was due to a BIOS bug that is now fixed! So now I will not be subject to the infamous 9000 hour SSD failure!

    I think that your method for making the key is just fine – and so are alternative methods – but whatever I did would have failed until I updated the motherboard BIOS since the SSD update firmware runs DOS!

    Thanks for your replies previously.
    Mike

  7. Shaun says:

    Jak, thank you for your tutorial, I managed to get various Debian 7.1.0 installers to boot using syslinux. However, when it went to mount the cd in the installer, it would give a “incorrect cd-rom” error. I isolated this to when I copy the iso to the folder on the usb. There are symbolic links on the original iso that are not getting copied (it says “operation not permitted”. I figured these were only the documentation not being copied, but it is infact /debian and /dists/stable symbolic links that aren’t being copied. These appear to be important links for the install process, either that, or them missing causes the md5sum check to fail (I’m not sure how linux installers handle this). In any case, it all comes back to symbolic links not being supported on the file system on the usb (thats what thunar tells me when I tried to copy the symbolic links using a rooted thunar window). Important to note, I am running Debian 7.1.0 as a guest in VirtualBox on a Win 7 host. Any advice you have for me would be much appreciated. Thank you.

  8. achilleas.k says:

    I managed to get it to work on an ext2 partition with extlinux.
    See here for differences http://www.syslinux.org/wiki/index.php/EXTLINUX

    I didn’t add a extlinux.cfg file, which makes it default to syslinux.cfg

    I wanted to use ext2 instead of fat32 because some distros (e.g., Debian) use symlinks in their image. After a bit of fighting with the “append” options, I managed to get Debian working with the following config:


    LABEL debian
    MENU LABEL Debian Linux
    LINUX /debian/live/vmlinuz
    INITRD /debian/live/initrd.img
    APPEND live-media-path=/debian/live cdrom-detect/try-usb=true noprompt boot=live live-config

  9. rainman says:

    and now just please the entries for arch – the system you brought this up with.. because the syslinux.cfg i found refers to lot of other files.
    when i put this entry:
    “CONFIG /multibootusb/archlinux-2014.03.01-dual//isolinux/isolinux.cfg
    APPEND /multibootusb/archlinux-2014.03.01-dual//isolinux”
    which works for kali btw. quite pretty, i get:
    “Unknown keyword in configuration file: PATH
    boot/syslinux/whichsys.c32: not a COM32R image”

    So, where to go next? Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>