Create FreeBSD installation memstick on OS-X


This isn’t hard, but I have to look up the arguments to diskutil(8) often enough and it’s never the first hit on (note to self, this content really should end up in the handbook:

Obtain a copy of the memstick

  1. Download a copy of the installation media:

    For today I’m using and its checksum file (based on the date and the subversion commit version 11.0-CURRENT-amd64-20150618-r284544):

    NOTE: Always download the checksum file and verify. While the download is happening you can skip down to step 4.

  2. Unzip the image:

    % unxz -kf FreeBSD-11.0-CURRENT-amd64-20150618-r284544-memstick.img.xz
  3. Verify the checksum:

    % grep memstick CHECKSUM.MD5-FreeBSD-11.0-CURRENT-amd64-20150618-r284544
    MD5 (FreeBSD-11.0-CURRENT-amd64-20150618-r284544-memstick.img) = e87a89c493236da86a1bf785bd7e76f4
    MD5 (FreeBSD-11.0-CURRENT-amd64-20150618-r284544-memstick.img.xz) = 811e3c6a3cfe99d8e2da9fb8ab8714c6
    MD5 (FreeBSD-11.0-CURRENT-amd64-20150618-r284544-mini-memstick.img) = 93b95aae56a9677359c527dff40b061e
    MD5 (FreeBSD-11.0-CURRENT-amd64-20150618-r284544-mini-memstick.img.xz) = 3ef36e7bded305a7de2b42e1e4e5502c
    % md5 FreeBSD-11.0-CURRENT-amd64-20150618-r284544-memstick.img*
    MD5 (FreeBSD-11.0-CURRENT-amd64-20150618-r284544-memstick.img) = e87a89c493236da86a1bf785bd7e76f4
    MD5 (FreeBSD-11.0-CURRENT-amd64-20150618-r284544-memstick.img.xz) = 811e3c6a3cfe99d8e2da9fb8ab8714c6

In this case, yup, the MD5s match. If you downloaded the SHA256 checksum (which is superior to MD5) but don’t have a dedicated CLI utility, use openssl(1)’s dgst mode:

% openssl dgst -sha256 FreeBSD-11.0-CURRENT-amd64-20150722-r285794-memstick.img
SHA256(FreeBSD-11.0-CURRENT-amd64-20150722-r285794-memstick.img)= 59e89f44a2d7588a31408a811e95aa3825028478f0af9c15fd16db8a53243e87
% grep memstick CHECKSUM.SHA256-FreeBSD-11.0-CURRENT-amd64-20150722-r285794
SHA256 (FreeBSD-11.0-CURRENT-amd64-20150722-r285794-memstick.img) = 59e89f44a2d7588a31408a811e95aa3825028478f0af9c15fd16db8a53243e87
SHA256 (FreeBSD-11.0-CURRENT-amd64-20150722-r285794-memstick.img.xz) = 61031aab2eb0473ec21650dda70452a5ebc8b4e29bb587b9c765900c6e96c0d2
SHA256 (FreeBSD-11.0-CURRENT-amd64-20150722-r285794-mini-memstick.img) = db9a92668b32cb2e7e6c2a7e70a8f51b58449fe9d30b4fcddc81aa7e217b61be
SHA256 (FreeBSD-11.0-CURRENT-amd64-20150722-r285794-mini-memstick.img.xz) = f92f4a65f008017718405719a87f427125d3df5227dfa967c542b484a8a1e2c3

Figure out the USB Device Name

  1. Open Disk Utility:

    % open '/Applications/Utilities/Disk'

    Disk Utility

  2. Obtain the disk name by selecting the USB device and pushing ⌘i:

    USB Disk Info

    Record the name of the disk found in the row labeled Disk Identifier.

    NOTE: this could be discovered using diskutil list but I want to make sure no one selects the wrong disk. It’s my experience that USB ports on the left of MacBook Pro laptops are disk3 and the USB port on the right of the laptop is disk4, but double check. This is a destructive operation (i.e. “measure twice, cut once”).

Overwrite the USB memstick

  1. Unmount the USB disk using the value found in the previous step (i.e. /dev/disk4):

    % sudo diskutil unmountDisk /dev/disk4
    Unmount of all volumes on disk4 was successful
  2. Write out the disk image to the USB device:

    % sudo dd if=FreeBSD-11.0-CURRENT-amd64-20150618-r284544-memstick.img of=/dev/disk4 bs=1m conv=sync
    717+1 records in
    718+0 records out
    752877568 bytes transferred in 313.225319 secs (2403629 bytes/sec)
  3. Eject the USB disk:

    % sudo diskutil eject /dev/disk4
    Disk /dev/disk4 ejected
  4. Profit.