Creating a Multiboot USB

Overview

In some of my past experiences in holding Linux Install Fests it has always been a bit of a challenge keeping track of multiple ISOs across multiple USB thumbdrives. There have been times when having the proper OS architecture for the different types of hardware have left me feeling a bit frustrated. For example, I would have a 64-bit version of a distro on hand when I need a distro for 32-bit hardware. As a result, I would need to scramble trying to download an ISO file. If the download speeds are good and RADIUS isn’t throttling my network connection, then all is good. However, that has not been my experiences in many of the locations our Install Fests have been held. What am I to do?

I could burn an ISO to a USB for each and every distro I have downloaded, but to me it seems to be such a waste of time, money, and storage resources. I know thumdrives are cheap, but keeping track of the many drives are a bit of a hassle. I want to keep the number of drives I carry with me to a minimum. Also, with the storage sizes of thumbdrives today the ISOs don’t come close to maxing out the size limits. That is storage space that could be used for other projects.

I have looked into building a portable version of a kickstart server. The downside to this solution is having to carry around way more cables and hardware than multiple thumbdrives. So this idea didn’t stay on my list for very long.

Eventually I settled on a multiboot USB. A multiboot USB allows for multiple ISOs on one drive and the ability to select which ISO to boot from providing the proper ISO has been installed. So lets get started putting this into action.

Requirements

Hardware

  • One computer system running Ubuntu 17.04 or your distro of choice.
  • One 4GB USB thumbdrive.

Software

  • GRUB2 ( I only mention this because your distro of choice may not use it.)
  • fdisk

ISOs

  • Ubuntu MATE 17.04 Desktop 32-bit
  • Ubuntu MATE 17.04 Desktop 64-bit

Building the Drive

NOTE: The commands used in this tutorial will need to be run as root. You can access the root account by using a couple of commands:

  • sudo su -
  • sudo <command>

Now let’s get started.

Format your USB drive with a single partition.

  1. Open a terminal and type sudo su -
  2. Type fdisk -l to list all partitions on your system. Take note of which device is your USB drive. On my system it was /dev/sdb.
  3. Type fdisk /dev/sdx to start editing your partitions. (x is the letter of your USB device.) You should now see the fdisk prompt.
  4. At the fdisk prompt type d. Select the partition number. Continue with this step until all partitions have been deleted.
  5. Now let’s create the partition. Type n, followed by p, and 1. Select the remaining default values to complete the new partition.
  6. Type a to make the partition bootable.
  7. Type t to select a partition type. Type 83 for a Linux partition type.
  8. Finally, type w to write the changes to the thumbdrive.

Create a filesystem on the USB drive.

  1. Type mkfs.ext4 /dev/sdx1.

Install GRUB2 on the USB drive.

  1. Mount the device: mount /dev/sdx1 /mnt
  2. Install GRUB: grub-install –force –no-floppy –boot-directory=/mnt/boot /dev/sdx

Build the grub.conf file

  1. Create the grub.conf file on the thumbdrive: vim /mnt/boot/grub/grub.conf
  2. Copy the contents to the file and edit the text as needed:

    set timeout=10
    set default=0

    menuentry "Try Ubuntu MATE 17.04 Desktop ISO 32bit" {
    loopback loop /ubuntu-mate-17.04-desktop-i386.iso
    linux (loop)/casper/vmlinuz boot=casper \
    iso-scan/filename=/ubuntu-mate-17.04-desktop-i386.iso noeject noprompt splash --
    initrd (loop)/casper/initrd.lz
    }

    menuentry "Try Ubuntu MATE 17.04 Desktop ISO 64bit" {
    loopback loop /ubuntu-mate-17.04-desktop-amd64.iso
    linux (loop)/casper/vmlinuz.efi boot=casper \
    iso-scan/filename=/ubuntu-mate- 17.04-desktop-amd64.iso noeject noprompt splash --
    initrd (loop)/casper/initrd.lz
    }

  3. Finally, reboot the system using the new thumbdrive to see if it works.