Setting up a Pi Zero

These are just some notes on installing Raspbian and setting up a Pi Zero from scratch. It assumes that you work from a Linux machine, which you already need to use Ansible. There is more information on the Raspberry Pi site.

The SD Card

Download the latest Raspbian image. The Lite minimal image is fine, because it will be running headless. Verify it with sha256sum to make sure that you have a good download.

# compare output with the SHA-256 on the downloads page
$ sha256sum 2019-09-26-raspbian-buster-lite.zip

Next, push the image to the SD card. Run lsblk -p before and after inserting the SD card to find the device name. It is often /dev/mmcblk0. Umount any partitions from the SD card.

$ umount /dev/mmcblk0p1
$ umount /dev/mmcblk0p2

Write the image with DD, unzip it to stream if zipped. Sync to flush the write cache and then unmount your SD card.

# if unzipped
$ dd bs=4M if=2019-09-26-raspbian-buster-lite.img of=/dev/mmcblk0 conv=fsync

# if zipped
$ unzip -p 2019-09-26-raspbian-buster-lite.zip | sudo dd of=/dev/mmcblk0 bs=4M conv=fsync status=progress

$ sync 
$ umount /dev/mmcblk0

First Boot

Put the SD card into the Pi, power it up, and then login as pi/raspberry. Root has a starred password and pi is the only account that can log in.

Run sudo raspi-config and set up wifi under "Network Options". Exit and verify that you have a good connection by running ifconfig and checking the wlan0 interface. Under "Boot Options" make sure you are using Text console, no autologin.

SSH is not enabled or running by default, so start it. Change the password for pi if you are not going to immediately run the first.yml playbook.

$ sudo service ssh start

When running the first.yml playbook on a Pi, it might die when doing a dist upgrade just from packages timing out. Just try again. After running the first playbook, you can log in as 'deploy' and remove the pi account with:

$ sudo deluser --remove-home pi

Disabling swap can also avoid memory card corruption. Check with free -m.

$ sudo dphys-swapfile swapoff
$ sudo dphys-swapfile uninstall
$ sudo update-rc.d dphys-swapfile remove

To mount exfat USB drives, you need the exfat utilities.

sudo apt-get install exfat-fuse exfat-utils