Raspberry logo

Headless Installation on Pi Zero W

Picture Raspberry

The Raspberry Pi Zero W is an amazing little device. It's basically the Raspberry Pi Zero with Wi-Fi and Bluetooth added. (See also here for the official specifications)

It has 512MB RAM and a 1GHz single core ARM processor. This makes it good enough to run many fun projects in and around the home.

For only around Euro 11.50 at time of writing, this device is a very affordable Linux server.

Headless installation

The standard Pi OS Lite image works well to start out with, but the default installation requires connecting your monitor and keyboard to your Pi Zero.

If you don't want to connect a monitor or keyboard (known as headless), you can just log on remotely. But you will need to do the following before you insert the micro-SD card in you Raspberry Pi Zero.

Instructions on downloading Pi OS image and writing to SD card are here

Once you've written the image to a micro-SD card from your PC, you should see the boot partition appear. This is the only partition visible on PC or Mac. By adding a few extra files, your Pi Zero will automatically connect to Wi-Fi and allow remote login using ssh.

Automatically connect to Wi-Fi

You will need to create the file wpa_supplicant.conf in boot partition.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1 country=<your two-letter country code>
 network={  ssid="<your SSID>"
 psk="<your Wi-Fi password>"
} 

Just use your specifics: country, SSID and Wi-Fi password.

Enable sshd

To login remotely to you'll need to enable ssh daemon service. Pi OS has this disabled by default. Just create an empty file named ssh in /boot.

In MacOS:

touch /Volume/boot/ssh

Logging on remotely

Unmount/eject your SD card from your PC and insert it into your Raspberry Pi Zero. Now you can boot up your Raspberry Pi Zero for the first time. You can check your router or access-point to see if your Pi Zero has connected and obtained an IP address.

The default hostname is raspberrypi and username pi

In MacOS:

ssh pi@raspberrypi

with default password raspberry.

When you're logged in, you should see your usual Linux prompt.

Linux raspberrypi 5.10.17+ #1403 Mon Feb 22 11:26:13 GMT 2021 armv6l
 The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
 Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@raspberrypi:~ $

It's a good measure to change your password at this time.

~- Have Fun Hacking -~

P.S. This also works with other networked Raspberry Pi versions.