Linux DIY: Creating a Multiboot USB Drive With ISO Images Of Multiple Distros

Though I’m not a distro-hopper exactly, I keep trying live versions of popular linux distros like debian and ubuntu every now and then, and while I generally use the “dd” command which works right out of the box, today I thought that instead of burning a new ISO image each time, why not create a single 16GB USB stick which can boot multiple distro images!

dd if=xubuntu-18.04.1-desktop-amd64.iso of=/dev/sdb bs=1M

This simple dd command does the job, but you are left with a single ISO image occupying the entire disk space which is an inefficiency if you have a larger drive that can hold multiple images. So, let’s learn how to reclaim all that space by creating a single USB which can boot multiple ISO images. Though the process is a bit more involved than the dd command, the reward is obviously worth it too.

Step-1: Format your USB drive to FAT32, there should be a single partition on the drive with boot flag enabled. – Also, label the drive as MULTIBOOT or something for recognizing it easier. Though the linked article below uses the fdisk/mkfs.vfat commands, you can even use graphical tools like gparted to make this process simpler.

Gparted

Step-2: Install grub2 on the newly formatted drive, create a boilerplate grub.cfg file:

  1. Close the gparted window if its open, otherwise the drive won’t be mounted.
  2. Type sudo grub-install --force --no-floppy --boot-directory=/media/prahlad/MULTIBOOT/boot /dev/sdx (replacing path with yours, x with your actual USB device)
  3. Type cd /media/prahlad/MULTIBOOT/boot/grub (or whatever your path is)
  4. Type wget http://pendrivelinux.com/downloads/multibootlinux/grub.cfg (to get the grub.cfg file)

Step-3: Copy whatever ISOs you want into the root folder of your drive. For the purposes of this example, let’s consider latest LTS releases of Ubuntu and Xubuntu (swap with any other flavors or debian too if you prefer):

cp ubuntu-18.04.1-desktop-amd64.iso /media/prahlad/MULTIBOOT/
cp xubuntu-18.04.1-desktop-amd64.iso /media/prahlad/MULTIBOOT/

Step-4: Edit the grub.cfg you just downloaded, and configure entries for your ISOs accordingly. Its important that you do this carefully:

# This grub.cfg file was created by Lance http://www.pendrivelinux.com
# Suggested Entries and the suggestor, if available, will also be noted.

set timeout=10
set default=0

menuentry "Ubuntu Desktop ISO" {
 loopback loop /ubuntu-18.04.1-desktop-amd64.iso
 linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-18.04.1-desktop-amd64.iso noeject noprompt splash --
 initrd (loop)/casper/initrd.lz
}

menuentry "Xubuntu Desktop ISO" {
 loopback loop /xubuntu-18.04.1-desktop-amd64.iso
 linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/xubuntu-18.04.1-desktop-amd64.iso noeject noprompt splash --
 initrd (loop)/casper/initrd
}

As you can see, I’ve changed only the menu entries to keep things simple. The arguments are also self apparent. For instance, loopback and loop attributes are used because we aren’t booting directly from the USB, but mounting the virtual loop device (ISO file) instead.

However, note that there could be subtle differences between distros, xubuntu uses /casper/initrd instead of /casper/initrd.lz, for instance. To know the right entry for your own distro, compare the “/boot/grub/grub.cfg” file of your distro ISO to get a hint about what menu entry to add. If your ISO isn’t one of the ‘buntus or a debian, then it might get trickier.

Step-5: Boot from your USB drive and ensure that it works.

Make sure that you boot from your newly created USB drive, not from the hard drive as usual. If everything goes right, you should be able to see a grub boot screen with the two menus for Ubuntu and Xubuntu.

Once this process is successful, adding new ISOs to your drive is only too easy. Just copy the brand new ISO to your drive’s root directory and just add the necessary entry in /boot/grub/grub.cfg, that’s it!

Finally, you’ll have to enable legacy boot option if not already done in your bios settings, this process won’t work with EFI/UEFI systems since the drive doesn’t have an EFI partition. I might do another post about creating a similar drive for EFI/UEFI setups in future, until then you can refer to this reddit post by /u/need2burn.

Best of luck, and let me know how it goes in comments below.

Reference:

Boot Multiple ISO from USB via Grub2 using Linux

9 comments

  1. This is wicked cool! I’ll have to try it when I get a chance!

    It would be great if we could write a script to generate the grub.cfg based on the isos in the directory. Either that, or I don’t know too much about grub so I don’t know if it’s possible, but it should be awesome if the cfg file was dynamic and built up the menu entries from the isos at boot time.

  2. Danny says:

    Wicked cool, many thx for sharing! Will be making one out of my 16gb tonight.

    Any idea if this process would also work to boot virtual hard disk formats, or is this limited to just .iso formats?

    Ive been doing exactly what you did above in Windows using VHDX/Hyper-v files to multiboot test/dev environments and its awesome! It’s sort of like having a virtual stash of different os installs selectable at boot, with all the benefits of virtual machine disks combined with bare metal performance. So cool.

    But I’ve been having trouble figuring out to do this in native linux, this gives me hope it can be done! 🙂

  3. Sunkim says:

    My name is kim.i am sorry to bother you guys I bought one of you guys usb hard drive LINUX from Amazon for $15.oo dollar it won’t boot my hp laptop please help me.sincerliykim

  4. dilip modi says:

    can we add windows image. that would be awesome

  5. Brainstorms says:

    Check out YUMI on peddrivelinux.com. it can not only make a multiboot from ISO images, it will create and manage the menus and Grub config files for you, too.

    I’ve built one that not only boots various Linux distros, but even Windows 7 All-in-One for repair or installs.

    YUMI also supports installing or running various tools, security testers, utilities, etc.

    Makes a good “Swiss Army Knife” thumb drive for your computing needs.

  6. You might be interested in a tool I wrote at https://github.com/fkmclane/mkusb

    It makes a multiboot EFI/Legacy boot USB drive and I’d like some feedback on it. It includes an examples/extra file that has a ton of distributions in it (though I haven’t tested all of them) showing how to use the tool with them. It also supports adding the Refind ISO and the FreeDOS USB image.

    Let me know what you think!

  7. NumOpen says:

    You can use multisystem too, it’s easier : http://liveusb.info/dotclear/

Leave a Reply

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