Setting up a Bootable SD Card

Raspian boot images can be downloaded from here.

We recommend the desktop variant of Raspian which will bring up an X11 based GUI at startup. If a GUI is not needed, X11 can be easily turned off later.

Before the first boot

Preparing an SD card

The easiest way to copy the image onto an sd card is using a dd command similar to this:

$ sudo dd if=/tmp/raspian.img of=/dev/sdc status=progress

This will create two partitions on the device /dev/sdc:

  1. The boot partition (/dev/sdc1) which will be mounted at /boot
  2. The main partition (/dev/sdc2) which will be mounted at / and resized to use up the rest of the sd card after the first boot

Use pmount/pumount to mount these partitions for the configuration steps below.

Enable ssh

add an empty file named ssh to the boot partition.

user: pi
password: raspberry

Enable/Disable specific hardware

Edit the file config.txt in the boot partition. Note, the raspi-config tool may also modify this file.

Set WIFI Station and Password

Edit /etc/wpa_supplicant/wpa_supplicant.conf in the main partition to contain:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


change US, your_real_wifi_ssid, your_real_password as necessary

Set Hostname

Edit /etc/hostname in the main partition

This will make it easier to find the Pi’s IP-address by looking for this hostname in the router’s connected-devices-table.

After the First Boot

Most of these are optional.

Change Password for User pi

Run this interactive command and follow the instructions:

$ passwd

(default password is raspberry)

Set Timezone

$ sudo raspi-config

Localisation Options → Change Timezone

Disable GUI

$ sudo raspi-config

Boot Options → Desktop/CLI

Run Startup Script as User pi

To simplify running your own programs as startup, edit /etc/rc.local to contain

$ su pi -c /home/pi/ &

Next, create a the file /home/pi/ with this content and make it readable/executable.

cd /home/pi

<run program 1>
<run program 2>

Disabling on-board LEDs

Add lines like the following to /etc/rc.local:

echo <level> > /sys/class/leds/led<no>/brightness
echo <mode>  > /sys/class/leds/led<no>/trigger

where no is 0 (activity LED) or 1 (power LED). and level is 0 (on) or 1 (off), mode is from the following table and only relevant when the brightness is 1.

mode description
none always off
mmc0 lit when sd card is accessed
gpio gpio controlled (default off)
heartbeat flashes
cpu0 lit when cpu activity
input lit when under-voltage detected

On the Pi Zero only LED 0 (activity LED) is available.