Overview
This guide will walk you through a headless (no monitor, keyboard, mouse) Raspberry Pi setup.
We'll cover materials, installation, bootstrap a WiFi connection, and optionally configure a hostname & static IP.
Table of Contents
- Overview
- Table of Contents
- Gather the Materials
- Write Raspbian Image to Mico SD Card
- Bootstrap Raspbian Settings
Gather the Mats
Hardware
- A Raspberry Pi. model Zero via Adafruit
- Micro SD Card
- Micro USB cable
- USB Micro SD card reader/writer. Mine via Adafruit.
- Micro USB Male to USB A Female adaptor. Mine via Amazon
- USB Wifi dongle Mine via Adafruit.
Software
- Latest Raspbian release
I’m using Raspbian Jessie Lite, which is a headless distro. This Raspbian image is small because GUI libraries/programs (like X) aren’t included by default. Jessie Lite will fit on a 2GB SD card, but the desktop image will require at least 4GB of space**.
Write Raspbian Image
Raspberry Pi provides official guides for each operating system:
Bootstrap Raspbian
How you mount the Raspbian filesystem and edit files also depends on your operating system.
Windows & OS X Instructions - @todo
### Linux Instructions
Configure WiFi connection
- Run command
df -h
to list filesystem info.
/dev/sdb2 7.2G 831M 6.1G 12% /media/userName/c7f58a52-6b71
/dev/sdb1 60M 20M 41M 34% /media/userName/boot
cd
into the root filesystem, which is/media/userName/c7f58a52-6b71
in the example above.nano etc/wpa_supplicant/wpa_supplicant.conf
to edit the WPA supplicant config.- Add the following config:
network={
ssid="Network_SSID"
psk="yourPassword"
}
- Ctrl+X and press Y to save.
Connect to Wifi automatically
nano etc/network/interfaces
- Add
auto wlan0
to the first line of this file. - If you want to use DHCP, append the following to the bottom of this file. Or, assign a static IP instead.
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
- Ctrl+X and press Y to save.
Change Pi’s hostname (optional)
nano etc/hosts
127.0.0.1 localhost
#The following config should be used for IPv6
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
#Raspberry Pi's new host name
127.0.1.1 newhostname
- Ctrl+X and press Y to save.
nano etc/hostname
newhostname
- Ctrl+X and press Y to save.
Assign Static IP
ifconfig -a
from a machine connected to the same Wifi network, or from a Pi currently using DHCP.- Take note of inet addr, Bcast, and Mask
route -n
- Take note of the Gateway Address and Destination Address.
nano etc/network/interfaces
and add the following:
allow-hotplug wlan0
iface wlan0 inet static
address <desired IP address>
netmask <Mask>
broadcast <Bcast>
network <destination address>
gateway <gateway address>
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Unmout the Micro SD card and boot up the Raspberry Pi!
The default password is raspberry.
$ ssh pi@raspberrypi
# If you don't have a nameserver, use the Pi's IP.
# You can find the Pi's IP in your router's DHCP lease list
# Or setup a static IP
$ ssh pi@10.11.12.13
And you’re ready to go! I recommend running sudo apt-get update
& sudo apt-get upgrade
, then setup key-based authentication and user accounts.