Setup Pi Zero W Headless Wifi

These instructions are for a Raspbian Jessie image that I downloaded from here:

https://www.raspberrypi.org/downloads/raspbian/

I'm using the lite image (no desktop) version 4.9 from July 05, 2017.

Once you download the file, unzip it and note the location of the *.img file.

These steps emulate what an install script does.

Put a blank micro SD card in an adapter and plug it into your computer.

Open up a terminal window and type:

diskutil list

At the bottom of the output, you should get a result similar to this:

/dev/disk2 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *7.9 GB disk2 1: Windows_FAT_32 boot 66.1 MB disk2s1 2: Linux 7.9 GB disk2s2

Assuming that your SD card is 8GB, you can tell that /dev/disk2 is the SD card. On your machine it may be different. Make sure you have the correct one before proceeding.

Before you can burn an image to the card, you needs to unmount it first, by issuing this command (assuming disk2!):

diskutil unmountDisk /dev/disk2

To burn the image to the SD card, run this command (adjusting for the location and filename of the image that you downloaded):

sudo dd bs=1m if=~/Downloads/2017-07-05-raspbian-jessie-lite.img of=/dev/disk2

The command should take several minutes. Once it's done you should see the new Raspbian boot volume when you execute this command:

ls -ls /Volumes/

For security reasons, ssh is no longer enabled by default. To enable it, run this command:

touch /Volumes/boot/ssh

Create a new empty file that will hold network info:

touch /Volumes/boot/wpa_supplicant.conf

Edit the file that you just created and paste this into it (adjusting for the name of your country code, network name and network password):

country=US ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1

network={

  ssid="NETWORK-NAME"
  psk="NETWORK-PASSWORD"

}

Issue an eject command:

diskutil eject /dev/disk2

The command won't physically eject the disk/card. It's more of a logical eject: meaning it's safe to remove the card now. You can also do this by right-clicking on the card on your desktop.

Source