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:
- This Github Gist
- These instructions from Pendrive Linux.
The rest was trial and error. For instance the grub.cfg
file from Pendrive is
incorrect and will not boot Ubuntu.