There are already lots of guides covering various aspects around setting up your Raspberry Pi, including this useful guide: https://www.raspberrypi.org/documentation/installation/
As I as I don’t tend to do it all that often, I’m capturing this more for my own benefit, but of course this may be useful for others. The raspberrypi.org website produce a NOOBs image which enables you to install Raspian, or several other distributions. If you are just starting out, then that image maybe something you want to consider. Alternatively if you know you just want Raspbian, then just download that image as it is going to be quicker.
First things first: SD Card
Not all SD cards are equal, check out: https://www.raspberrypi.org/documentation/installation/sd-cards.md for details. Also be very aware of cheap SD cards being offered for sale. A friend of mine purchased several 8GB cards which turned out to be fakes. Only actually storing 512MB of data. So if you are having issues, try writing and reading back a multi-gigabyte file and see if it works.
Preparing your SD Card
Download SD Formatter: https://www.sdcard.org/downloads/formatter/ then follow these simple steps:
- Install SD Formatter
- Run SD Formatter
- Ensure the drive letter selected is that of your SD Card
- Format the SD Card after selecting Option: Format Size Adjustment: ON
Getting NOOBS or Raspbian images on to your SD card
If you’re using the NOOBS image, you just download and extract the zip and copy the files to your freshly formatted SD Card. See more info here: https://www.raspberrypi.org/documentation/installation/noobs.md
If you’re using Raspbian, you’ll download a zip. Once you extract it you’ll be left with an IMG file. Download and install Win32DiskImager. Run Win32DiskImager as administrator, then follow these steps:
- Select the Raspbian Images file you previously extracted
- Select the drive letter of your formatted SD card
- Select Write
- Once writing is complete. Close Win32 Disk Imager and using Explorer “eject” the SD card before physically removing the card from your card reader.
First time boot
For the initial configuration of your Raspberry Pi, you really need to have a USB keyboard and HDMI video connected. I’m sure there are ways and means to avoid this step, but for now, let’s keep it simple.
If you’re using the NOOBs image your first time boot with be to select the distribution/software you want to install on the card. Once you’ve done that the process that follows is the same.
When booting Raspbian for the first time you’ll be presented with the menu screen of the Raspberry Pi Software Configuration tool (raspi-config).
For the most part, unless you know you want to enable I2C, SPI, overclocking etc, you may just want to select Finish. However there are a couple of options I feel you may want to consider:
- “1 Expand Filesystem” which allows you to use the entire capacity of your SD card for the OS.
- “2 Change User Password” to something secret to you, rather than the default password: raspberry (BTW the default username is: pi)
I’m not all that keen on the idea of running a GUI based distribution on my Raspberry Pi as my plans typically are around making them headless. However option 3 controls what environment your Pi will boot into.
If you need to come back and change any options, once logged in run:
So once you’ve completed the initial configuration your Raspberry Pi will reboot and it should boot to a logon prompt. Logon and have fun. If you want to start using your Raspberry Pi headless (without a local keyboard and video output), then the first step will be to determine its IP address and use an SSH client to connect in.
Basic file editing can be performed with the built in editors:
Or you can download your favorite editor, or better still follow my guide on how to setup remote file editing.
If you are using a wired network connection to your Raspberry Pi and have DHCP running on your network, obtaining the IP address is very easy. If you’re lucky when your Pi boots it will have obtained it’s IP address and will display it on screen before the logon message. If not, then logon and run either: hostname -I or ifconfig. Examples below, with the IP address highlighted in the output in yellow:
[email protected] ~ $ hostname -I
[email protected] ~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:c1:d9:ea
inet addr:10.30.129.60 Bcast:10.30.143.255 Mask:255.255.240.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42187 errors:0 dropped:1 overruns:0 frame:0
TX packets:2569 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:2445952 (2.3 MiB) TX bytes:177420 (173.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:72 errors:0 dropped:0 overruns:0 frame:0
TX packets:72 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:6288 (6.1 KiB) TX bytes:6288 (6.1 KiB)
wlan0 Link encap:Ethernet HWaddr 80:1f:02:d3:33:ca
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:15 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Playing a game of hunt the IP address shouldn’t necessary very often as DHCP leases often last for days so your Pi is likely to keep the same address. To ensure you can find your Pi on the network without needing to scan the IP range to find it, I’d recommend one of two options.
- Option 1: Configure a DHCP reservation for the MAC address of your Pi. Routers vary what they call this, by Draytek router for example offers this capability under “Bind IP to MAC” in it’s UI.
- Option 2: Configure your Pi to use a static IP address on your network. This should be outside the DHCP range of addresses, but still within your network as defined by the subnet mask. More information on configuring your Pi to use a static IP address can be found over here: http://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address
Basic WiFi Setup
If you are wanting to use Wireless networking, then I’d recommend the Edimax EW-7811UN, as this doesn’t need any special drivers to be used with the Raspbian image, it just works out of the box. Though’ll need to configure your wireless settings. For configuring this see this guide which will apply to most common deployments: http://thepihut.com/blogs/raspberry-pi-tutorials/16018016-how-to-setup-wifi-on-the-raspberry-pi-raspbian
If your Wireless Networking environment is more complex, or actually more simple in some cases, you’ll need to dig a little deeper into the options for the wpa_suplicant.conf file. The following guides and manuals I’ve found most useful as a reference for accessing both open access points and Enterprise secured networks which required authentication:
Shutting Down Your Raspberry Pi Computer
Like any computer they really ought to be shutdown properly and not just have the power yanked from them.
- On the raspberrypi.org site they issuing the command:
- Waiting for the Pi to signal it’s ready to turn off by flashing the signal light.
- I prefer:
sudo shutdown -h now
- Since I’m shutting it down I’d like to have it turned off too.
Either method is fine and will result in ensuring all the services are cleanly stopped and date writes committed to the storage before being powered down.
Note: This guide was written based on experience with Raspbian Wheezy, 2015-05-05, Kernel: 3.18 from https://www.raspberrypi.org/downloads/ and tested on a Raspberry Pi 2, though this should apply to other distributions and models of Pi. The USB WiFi adapter used is Edimax EW-7811UN 150Mbps Wireless Nano USB Adapter, I purchased mine via Amazon.