TITLE: Putting a Linux distro on a USB, from a Mac
DATE: 2018-12-29
AUTHOR: John L. Godlee
====================================================================


Previously I used unetbootin and macOS' built-in Disk-Utility.app
to format USB drives to use for installing Linux distributions on
other computers. However, most recently, I found that I couldn't
get any of the installers to work, so I was looking for an
alternative.

 [unetbootin]: https://unetbootin.github.io

I found that I could accomplish the same thing on the command line.
Here is the process I used.

First, download a .iso image for a chosen linux distribution, for
example, this Linux Server i386 image that I wanted to use as a
minimal installation on a netbook.

 [Linux Server i386 image]: http://releases.ubuntu.com/16.04/

Plug the USB stick into the mac, and open a terminal. Enter:

   diskutil list

To find a list of media volumes connected to the system. This will
include both the hard disk for the mac and any connected external
drives such as the USB.

It's normally trivial to identify the USB stick from the list by
its size. It will be named something like /dev/disk2 and may
contain multiple partitions, like /dev/disk2s1. When you are sure
that you've identified the USB stick you want to install the linux
distro on, enter:

   diskutil eraseDisk FAT32 UNTITLED MBRformat /dev/disk2

This will format the USB (deleting everything in the process), to a
format that should be compatible with any device you plug it into.
I think this might have been the stumbling block in my old system,
and the USB wasn't formatted correctly.

Then, unmount the USB drive:

   diskutil unmountDisk /dev/disk2s1

Finally, install the .iso image you downloaded earlier onto the USB:

   sudo dd if=PATH_TO_ISO.iso of=/dev/rdisk2 bs=1m

Note that it's not a typo putting rdisk2 instead of disk2, it seems
to make the process run faster, similarly adding bs=1m.

Then it's just a case of booting from the USB on the new machine
and following the installation instructions.