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 tap nativeos/i386-elf-toolchain
$ 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.

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.

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
Mac
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.
Read More
Apple
Download I recently added a Mac mini to my setup at home, that I’m using to drive my in-home “video on demand” system. With many of the TV’s in the house on AppleTVs, any TV in the house can watch any movie in the library at any time. I put the mini (headless) in the closet, along with the Drobo and a printer. But, the new Mac mini lacks an optical drive. So, how to continue ripping the DVDs I already own? The solution, it turns out, is to continue doing the actual work on my iMac when it comes to ripping, filtering the files through iDentify and MetaX. But I don’t want to have to go to screen sharing on the Mini and add a file to iTunes. I want that to happen automatically. That’s where Automator - one of the most underrated pieces of software that comes with every Mac - comes in. With Automator, you can attach an action to a folder, so that that action will be performed whenever anything is added to that folder. So here’s what I did to get files from a folder into iTunes: Create a folder somewhere on your system. I put mine in my user directory. Open Automator. From the dialog box, select “Folder Action.” At the top, where it says “Folder Action receives files and folders added to,” select “Other” and select your new folder. Search for an action called “Set Var of Value”. Drag that action over to the right. From “Variable” select “New Variable.” Call it “Source” Search for an action called “Import Files into iTunes”. Drag that action over to the right underneath the variable action. Be sure to select “Library” from the empty dropdown. Search for an action called “Get Var of Value”. Drag that action over to the right underneath the iTunes action. Be sure the selected variable is “Source”. Search for an action called “Move Finder Items to Trash”. Drag that action over to the right. Search for an action called “Run AppleScript.” Drag that action over to the right. In the AppleScript action, paste this: on run {input, parameters} tell application "Finder" to empty trash return input end run Save the action. You’re done.
Read More