These are the steps that I follow when initially configuring a Raspberry Pi. This is based on the Raspberry Pi Software Configuration Tool (raspi-config) which comes with 2014-06-20-wheezy-raspbian.img.
To access raspi-config you have two options:
-
Plug in a monitor and keybard.
-
The system has sshd listening so if you can figure out its IP address remotely (possibly consulting your router or DHCP server's logs, or using
nmap
) you can configure it by accessing via ssh. The pi user's default password is: raspberry. Once in you can executesudo raspi-config
.
To get around you typically use the arrow keys, tab, and enter, as you do in the default Debian setup environment.
-
Expand Filesystem - if you are using a card larger than the Raspbian image this is a no-brainer.
-
Change User Password - the default Raspbian distribution creates a standard login: "pi". This option allows you to change that default user's password. Highly recommended.
-
Enable Boot to Desktop/Scratch - the default is a boot to console - if you wish to boot to the X Window desktop it can be selected here. For headless use, you want to boot to the console.
-
Internationalisation Options - as you can tell by the spelling here, US English is not the default i18n configuration. In this option, I choose:
- Change Locale - I deselect the default (en_GB.UTF-8) and select the appropriate locale for me (en_US.UTF-8). It will then confirm that you want to use this locale for the system environment (you do). This will dump you back to the main configuration menu, you'll have to go back into "I18n Options" to change further settings.
- Change Timezone - The default timezone is UTC which is appropriate for a Unix-like system. A timezone can be selected for each individual user by following the steps described by running
tzselect
. If you go into this option, UTC is under "None of the above". I leave my systems set to UTC. - Change Keyboard Layout - you'll almost certainly want to do this and change to an appropriate keyboard layout. For example, in the default UK keyboard layout Shift-3 results in a pound sign (£) rather than a hash (#) which makes commenting lines out (for example, in
/etc/network/interfaces
) a challenge (the backslash (\) key in a UK keyboard layout types the hash).
-
Enable Camera - this is for the Raspberry Pi Camera Board.
-
Add to Rastrack - if you want your installation to show up on the Rastrack Raspberry Pi Map, choose this.
-
Overclock - To date, I do not overclock my Raspberry Pis.
-
Advanced Options - there are a few things to change here:
- Overscan - this setting may be needed when using the Raspberry Pi in desktop mode.
- Hostname - obviously it's good to set a hostname, by default it selects "raspberrypi".
- Memory Split - configures the memory split between video memory and available memory. Since my Raspberry Pis are mostly headless, I typically choose this option and enter the minimum allocation for the GPU (16).
- SSH - I'm mostly accessing over the network so I enable this.
- SPI - I do not enable, this, I do not use the PiFace.
- Audio - whether you want audio to come out the HDMI jack or the 3.5mm headphone jack. Irrelevant for most headless use.
- Update - updates the
raspi-config
tool we are currently using. A little late for that, don't you think?
We're done! If you select "Finish" it will prompt for a reboot and you are good to go!
Upon first boot, you'll want to log into the Raspberry Pi with the "pi" login and the password you specified during configuration. If you didn't change the default password, it is: raspberry. Some steps you might take at this point:
- Remote access is enabled, however by default the Raspberry Pi is configured to use DHCP. For headless Raspberry Pis, I like to configure a static IP address. This is done following the same steps as in Debian:
-
Edit
/etc/network/interfaces
(I usevi
. By default,nano
is installed and may be easier if you are unfamiliar with vi). -
Comment out
iface eth0 inet dhcp
by putting a hash (#) in front of the line (if you didn't change your keyboard layout from UK and you are using a US keyboard, you may need to to use the backslash (\) key to type a hash). -
Add the following (obviously customize for your address and gateway):
iface eth0 inet static address 10.0.0.23 netmask 255.255.255.0 gateway 10.0.0.1
-
If you want to enable IPv6, as well, you can add
ipv6
on its own line to the end of/etc/modules
andiface eth0 inet6 auto
on its own line in/etc/network/interfaces
. -
You can either reboot at this point or
sudo ifdown eth0 && sudo ifup eth0
to reset the network interface (you can see the current configuration with/sbin/ifconfig
). -
If you do intend to continue working remotely, don't forget test SSH access before disconnecting the monitor and keyboard so that you don't have to hook everything back up if you've made a typo. I do not speak from personal experience on this at all.
-
From this point on, you can SSH in from another workstation to continue configuration if you have been working at the console and remote access would be easier (it might be due to the ability to have cut and paste).
-
You may wish to change the time zone for the "pi" user. You can run
tzselect
to walk you through the time zone options which will end up providing you a line to add to the end of your.profile
file. Cut and paste is handy here. -
You may want to remove some packages that you aren't likely to use. I've prepared a document outlining how I remove packages that I don't need for headless Raspberry Pis.
-
At this point it's probably a good idea to ensure Raspbian is up-to-date. I typically use
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
. -
If you are working in an environment with OS X, you may want to enable ZeroConf/Bonjour name resolution. You can do that using the Avahi package with
sudo apt-get install avahi-daemon avahi-discover libnss-mdns
. Once this is installed, you will be able to resolve the machine as hostname.local. This is very handy if your headless Raspberry Pi is configured with DHCP. -
The Raspberry Pi does not have a real-time clock so it appears to use the time saved during the last shutdown to set the clock upon boot if it cannot reach a time server. It might be a good idea to take a look at the NTP configuration and ensure that it's appropriate for your environment. By default, the Raspberry Pi will use NTP servers sent out by your DHCP server. You can see the current status with
ntpq -p
, you are looking for a line with an asterisk (*) in the first column indicating that there's a valid time source (you might need to wait a while after a reboot for things to sync up). If you need assistance in configuring NTP, I'd recommend reviewing: How do I use pool.ntp.org?.If you wish to manually configure NTP while still using DHCP, you can remove
ntp-servers
from the "request" line in/etc/dhcp/dhclient.conf
, remove the/var/lib/ntp/ntp.conf.dhcp
file, and then configure NTP normally (/etc/ntp.conf
). If you do not take this step, every time the DHCP lease is renewed it will update the/var/lib/ntp/ntp.conf.dhcp
file and use those NTP servers.