Creating a Multiboot USB Stick under macOS

This is an old post!

This post is over 2 years old. Solutions referenced in this article may no longer be valid. Please consider this when utilizing any information referenced here.

Here’s a quick article about how to make a multiboot USB stick under macOS. These are useful in a lot of situations - such as for doing system installs or system rescues - because you can boot a wide variety of live OSs from a single stick.

There are a lot of guides out there for doing this on Linux, and a lot of software for automating it on Windows, but not a lot of guides for doing it on macOS. Fortunately, it is pretty straightforward as the instructions will be broadly similar to doing it on Linux.

Prerequisites

This guide assumes you have Homebrew installed. If you don’t, you will need to install it. If you are using MacPorts or another package manager, the initial instructions might be slightly different.

You will also, obviously, need a USB stick.

Creating the Stick

First, we will need the grub package:

$ brew install i386-elf-grub

Next, we need to identify what node your USB stick came up as:

$ diskutil list

In my case, this came up as disk6. Be very careful here. If you are not paying attention you might accidentally wipe your system drive.

$ brew install i386-elf-grub
$ USBDEV=disk6  # this will be whatever your USB stick came up a$
$ sudo diskutil unmountDisk $USBDEV
$ sudo diskutil eraseDisk FAT32 MULTIBOOT MBR $USBDEV
$ sudo diskutil mountDisk $USBDEV
$ sudo /usr/local/opt/i386-elf-grub/sbin/grub-install --force --no-floppy --boot-directory=/Volumes/MULTIBOOT/boot /dev/r$USBDEV
$ cd /Volumes/MULTIBOOT/boot/grub

So what we did here was wipe the USB stick and create a new FAT32 partition with a Master Boot Record partition table and we installed Grub on it. So now it should be fully capable of being booted, though there’s nothing to boot yet.

Next, download a Linux ISO or some other things you might like to boot. Some useful ones to download might be:

Any image you download, put in the root of the USB drive.

Next, in /Volumes/MULTIBOOT/boot/grub, create a file called grub.cfg. Here’s an example based on the links above:

set timeout=60
set default=0

menuentry "Ubuntu 20.04.3 (AMD64) Desktop Live Boot" {
    set gfxpayload=keep
    set iso_path="/ubuntu-20.04.3-desktop-amd64.iso"
    loopback loop ${iso_path}

    linux   (loop)/casper/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=${iso_path} noeject noprompt splash --
    initrd  (loop)/casper/initrd
}

menuentry "Ubuntu 20.04.3 (AMD64) Server Install" {
    set gfxpayload=keep
    set iso_path="/ubuntu-20.04.3-live-server-amd64.iso"
    loopback loop ${iso_path}

    linux   (loop)/casper/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=${iso_path} noeject noprompt splash --
    initrd  (loop)/casper/initrd
}

menuentry "DBAN 2.3.0 (i586)" {
    set iso_path="/dban-2.3.0_i586.iso"
    loopback loop ${iso_path}

    linux   (loop)/DBAN.BZI nuke="dwipe" iso-scan/filename=${iso_path} silent --
}

menuentry "memtest86+ 5.31b" {
    linux16 /memtest86+-5.31b.bin
}

So for each ISO you add to the stick, add a menu item to the list so that you can boot it. You may have to fiddle with the config a bit to get it right, but the instructions should be generically similar for most.

That’s it! If everything went correctly, you now have a bootable USB stick that can do multiple things. One thing I noticed is that it does take several seconds, depending on the speed of the USB stick and the speed of the target machine, for the actual Kernel startup to happen. On an older machine I was installing this on, after hitting enter on the Ubuntu image, it just sat there for about 20 seconds with a flashing cursor before the init happened. So you might need to just give it some time.

Limitations

The largest limitation to be aware of are those related to using the positively ancient FAT32 filesystem. This means that your ISOs are limited to 4 gigabytes in size. Some systems will also not boot a FAT32 drive over 1TB in size. Theoretically you could get around these limitations by using exFAT, and most newer systems should be able to boot that with no problems, but I haven’t tried it.

Attributions

Most of these instructions came from these two links:

The rest was trial and error. For instance the grub.cfg file from Pendrive is incorrect and will not boot Ubuntu.

Did this article help you out?

That's great! I don't earn any money from this site - I run no ads, sell no products and participate in no affiliate programs. I do this solely because it's fun; I enjoy writing and sharing what I learn.

All the same, if you found this article helpful and want to show your appreciation, here's my Amazon.com wishlist.

Comments (0)

Interested in why you can't leave comments on my blog? Read the article about why comments are uniquely terrible and need to die. If you are still interested in commenting on this article, feel free to reach out to me directly and/or share it on social media.

Contact Me
Share It

Read More

Multiple Calibre Servers under Mac OS X

So there’s this program out there called Calibre which, despite it’s pretty terrible UI, is pretty much the gold standard for managing eBooks. Seriously, it’s such a great program whose only fault is its terrible engineer UI. One of the nice things that Calibre includes is a built-in web server that can serve books via OPDS. If you have an OPDS-compatible reader (I use Marvin), you can browse and download from your library directly on your device, basically creating your own private eBook cloud. But, this presents a little bit of an issue. Namely, I don’t want all of my books to be publicly available, while still providing a subset of my library for visitors to browse and use. But I still want to be able to access them myself from my “private reserve collection.” Fortunately, with a little bit of work, you can do that under Calibre.