HiFiPi.net
The blending of the Raspberry Pi with old and new music systems resulting in extreme cases of function and beauty..

Tech: Pi Headless Boot with SSH and Wireless


Raspberry Pi Zero W

Configuring the Raspberry Pi range to operate headlessly has little to do with decapitation.

What this does mean is that the system boots without a screen, monitor, mouse or even a keyboard and can be configured using SSH. All this can be achieved by editing a few config files on the SDCard prior to booting.

These instructions should work for all RasPi models. First off install the required operating system. In this case I have used the native Raspbian image available from the raspberrypi.org website.

SDCard-to-USB ReaderBefore plugging the MicroSD card into the Pi, plug it into a reader and plug into a computer. Navigate to the root directory of the drive with the SDCard in it, using a file explorer. Here I'm using Windows Explorer. This is a simple 4-step process. Time to edit some text files..

Raspberry Pi Zero W

1. Add the following command on a new line at the end of cmdline.txt file..

modules-load=dwc2,g_ether


2. Add the following command on a new line at the end of config.txt file..

dtoverlay=dwc2

Save the changes and close the files.


3. To enable Wi-Fi, create and then edit a text file called wpa_supplicant.conf

Add the following commands to this file, substituting your own Wi-Fi details and your country code..

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=AU
network={
ssid="Your WiFi SSID"
psk="Your WiFi password"
key_mgmt=WPA-PSK
}

Make sure no extra spaces appear in the lines. Save the changes and close the file. Make sure the file ends in .conf and not .txt or .conf.txt


4. To enable SSH login, create an empty text file called ssh - with no file extension.


You should end up with four new and/or modified config files in the root of the SDCard..

Config Files..

Note that the files ssh and wpa_supplicant.conf will both disappear from the root of the SDCard after the next Pi boot. This is normal. The system will use these files to configure itself and then delete them. To reconfigure the system, repeat the instructions above..

Finally dismount the MicroSD card, lob it into the Pi and start it up. The Pi should connect to your wireless base station and get an assigned IP Address. Check the DHCP log of your wireless router to establish the IP assigned to the Pi. This can be used to ping the device and to connect using SSH.

Move on to Configuring SSH and LAMP Server to connect to the system using SSH..

 

- AndyM