Install Raspberry Pi OS

Install the official 32-bit Raspberry Pi OS.
  1. Download image
  2. Locate SD card
  3. Unmount SD card
  4. Install coreutils
  5. Image SD card
  6. Enable SSH
  7. Eject SD card
  8. Initial boot

The following instructions are for headless (i.e. without a monitor) Raspberry Pi server installation of Raspberry Pi OS using a machine running macOS.

Consult the official Raspberry Pi installation guide for Linux and Windows instructions.

Download image

Download a copy of the image. Note that the torrent link may be faster. The ZIP file contains an image file (IMG).

zip_file="raspios.zip"
wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest -O "$zip_file"
unzip "$zip_file"

Locate SD card

Locate the mount point of the SD card (e.g. /dev/disk2).

diskutil list

The SD card should look somewhat like this, depending on the size of the card, and how many drives you have attached.

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *32.0 GB    disk2
   1:             Windows_FAT_32 boot                    268.4 MB   disk2s1
   2:                      Linux                         31.7 GB    disk2s2

Be careful with this step to ensure that you don’t select the wrong drive.

n="2"

Unmount SD card

Check active mounts and unmount the target disk.

diskutil unmountDisk "/dev/disk${n}"

You should see something like:

Unmount of all volumes on disk2 was successful

Double check mount status with:

mount
df -H

Install coreutils

I recommend installing the GNU coreutils variant of dd first via Homebrew, and using that version instead of the default BSD variant that ships with macOS.

brew install coreutils

Image SD card

Now you’re ready to format the SD card using dd.

# Input file.
if="$(find . -mindepth 1 -maxdepth 1 -type f -name "*.img")"

# Output file.
# Note the use of 'rdisk' here, for raw disk access.
of="/dev/rdisk${n}"

sudo dd if="$if" of="$of" bs="4M" status="progress" conv="fsync"

Enable SSH

Before removing the SD card, we need to enable ssh support, which is disabled by default. To enable remote access, you must write an empty file named ssh to the boot partition.

sudo touch /Volumes/boot/ssh

Eject SD card

Now we’re ready to eject the disk and boot up the Raspberry Pi device.

sudo diskutil eject "$of"

Initial boot

The default admin account is pi, with the password raspberry.

GUI configuration is accessible via sudo raspi-config.

Additional configuration is available in our Raspberry Pi cheat sheet.