Skip to content

Setup your Raspberry Pi

Jason Charney edited this page Feb 25, 2016 · 12 revisions

Assuming you followed the same procedure for downloading the Pi image and formatting the SD card we can get started.

This article is a log of everything that I have done to set up my Raspberry Pi 2 the way that I want it.

I'm going to assume the WiFi drivers have not been installed on it yet so I go downstairs to my modem, hook up my hacktop to it using an Ethernet cable and open the lid on my Hacktop. (Remember! If you close the lid, the power goes off. Never close the lid!)

OK, so you boot up and see four Raspberry Pi images. This inidcates that Linux is ready to use all four CPU cores. Odroid had the same thing but with a standard Tux the Penguin logo for each core.

I goes through and automatically logs in to you raspberry pi with the username pi and default password raspberry. It also launches the GUI. I don't like this. It takes too long.

I'm hoping that these instructions will be no more difficult or different than the ones I wrote for the Raspberry Pi B and B+

DO NOT USE THE GUI PROGRAM! Use the Text interface program, raspi-config, other wise you'll end out doing this twice.

I've burned a version of Raspbian based on Debian Jessie on it.

  1. Run raspi-config - Open an LX Terminal, resize the window a bit first, and run sudo raspi-config. Arrow keys will let you choose an option. Enter will select it.

  2. Expand the file system. - If if you opened another tab in the LX Terminal and type into the terminal df -h you would notice that /dev/root only has a file size of 3.9 GB. But you bought a 64 GB microSD card. So you should expand the file system, otherwise your computer will think you have 4GB instead whatever size your SD card is. Mine is 64GB. Select Expand Filesystem. Your file system should be resized to the correct size after it runs so press Enter again to select OK. You'll get a prompt saying that this change will not apply until the next reboot.

  3. Change the user password - On Raspberry Pi, You can change the password but you can NOT change the user name. If you are working on some secret security thing, go ahead and change the password. The default password is raspberry. Select "Change the User Password". You will be told to press OK again. Enter the new password and enter it again to confirm it. WRITE IT DOWN somewhere.

I'll probably make a post on my Tumblr explaining how to make a password notebook later. Sites that call themselves "password wallets" are STUPID, and can be hacked.  They are also terrible ideas as once a cybercrook has your password wallet password, they have access to your other passwords.  So keep your passwords in meatspace and use a notebook!
  1. Change the Boot Options. - Select "Boot Options". I didn't like that I when I started up my that it did an auto-login and launched the Graphical User Interface (GUI). I prefer to do that myself and I am savvy enough to know how to use the Command Line Interface (CLI) or Console. So select "Console". The GUI takes a while to boot up and can be resource intensive on the Raspberry Pi. But if you need it, you can run startx later.

  2. Wait for Network at Boot - Set to "Slow". It will at least try to connect to the internet. But if it has issues, you can always unplug and replug in the Wifi dongle.

  3. Set the Internationalisation Options - Why is internationalization spelled internationalisation? Because British people! Select "Internationalisation Options". I've made note of this in the past about how if you are an American using a Raspberry Pi, you'll want to change the Locale, Timezone, and especially the Keyboard Layout. Keep in mind, these recommendations are for someone living in the United States. YMMV.

  4. Change Locale - Use the spacebar to deselect any option that was set by default, which was likely just en_GB.UTF-8 UTF-8, but scroll through the entire list to be sure. Select en_US.UTF-8 UTF-8 and press enter. If you get another prompt asking what the default local for the system environment should be, select en_US.UTF-8 and press Enter.

  5. Change the Timezone. - Repeat Step 6 again and select "Change Timezone". Since I live in the United States, I will want to select US. Elsewhere in the Americas, pick America. Since I live in St. Louis, Missouri, I will want to select Central. Daylight Savings time settings are automatically set based on the geographic location database, which is why there are options for Arizona, Indiana, Alaska, and Hawaii. Remember, the Raspberry Pi does not come with a clock battery, so in order for it to sync, it music connect to the Internet. We will cover this later.

  6. Change the Keyboard Layout. - Probably the most important step. Repeat Step 6 and select "Change Keyboard Layout". Select 'Generic 105-key (Intl) PC' then press Enter.

Scroll to the bottom and select `Other` then press Enter. Select `English (US)` then press Enter.

Select `English (US) - English (international AltGr dead keys)` (DO NOT `English (US) - English (US, international AltGr dead keys)`!) then press Enter.

Select either `The default for the keyboard layout` or if you use accent characters for writing notes in Spanish, French, or Portuguese, select `Right Alt (AltGr)` to use the right Alt key to use special characters, and press Enter.

Select `No compose key` then press Enter. Select `No` then press Enter.

Select No for using `Ctrl+Alt+Bksp` to terminate the X server.  It's not analogous to Window's `Ctrl+Alt+Del`.

If we need to fix anything, we can use `sudo dpkg-reconfigure keyboard-configuration` later.
  1. Skip "Enable Camera" - Unless you have the Camera Accessory, you don't need to do anything with it.

  2. Skip "Add to Rastrack" - You don't need to register your geocoordinates with the Rastrack map unless you want to. If you are paranoid about privacy, you would definitely not want to do this anyway.

  3. Skip "Overclock". - Unless you know what you are doing, you definitely don't want to mess with this.

  4. Set Advanced Settings - Select "Advanced Options".

  5. Enable Overscan - Select "Overscan" and then select "Enable". The Advanced Options section of the raspi-config documentation can better explain it. It is likely enabled by default, but just to make sure do it anyway unless you have problems with borders or image shape on the screen you are using.

  6. Change the hostname. - Repeat step 13. You should definitely change your Pi's hostname especially if you own more than one Raspberry Pi. This is helpful if you need to find it on your home router's list of connected devices. You'll be prompted as to what characters you can use. Press Enter then enter the new name. The default was 'raspberrypi'. Press Enter to submit. I set my to 'Hacktop'.

  7. Set the Memory Split. The memory split determines how much of the memory the Graphics Processing Unit (GPU) will get. The rest will go to the Central Processing Unit (CPU). Repeat step 13 and select "Memory Split". The default for Raspberry Pi has been 64 MB indicated by the value 64. But the Pi B+ had 512 MB. The Pi 2 has 1 GB, or 1024 MB, so it is probably OK to give the GPU just a little more, which is why I'm setting it to 128. I would assume that using 0 would mean use the default, which is fine if you are running the pi headless. But since this project requires a monitor, and the Pi 2 has plenty to share, let's set it to 256. This should give the GPU more than enough memory to work with. Press Enter. This will add gpu_mem=256 to the bottom of /boot/config.txt, by the way.

  8. Skip over SSH, Device Tree, SPI, I2C, and Serial. Only SSH, Device Tree, and Serial should be enabled (Enable, Yes and Yes). Those are turned on by default. Don't touch the others unless you know how to use them.

Device tree is enabled for Raspbian and NOOBS distributions. Check the documentation of other distributions for details.  Basically the SPI and I2C settings determine if the [GPIO] pins for [SPI](https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md) (pins 19, 21, 23, 24, and 26),  I2C (pins 3 and 5) are enabled with their respective kernel modules.  You should leave them on espeically if you want to do anything with the GPIO.

I'm not exactly sure what Serial does, but for the most part the documentation says something about "This allows you to disable/enable shell and kernel messages from the serial connection".  I'll have to ask someone about that later.
  1. Skip Setting Audio. If we need to, Step 13 and select "Audio". It should be set to Auto meaning if that if there is any sound it will go through HDMI (or for my Hacktop, the speakers on it) and go through to the audio jack on the Raspberry Pi when that is plugged in. I might be a little bit wrong about this as configuring audio is kind of a crapshoot. I'll have to look into this later.

  2. 🆕 Don't touch GL Driver Something new added to the Feburary 2016 update. This is for an experimental desktop GL driver. It sounds like something OpenGL related. One more item to look up later.

  3. ⚠️ DO NOT RUN UPDATE YET! This should have been the first thing that should have been done, but it wasn't. So do this after we reboot.**

  4. Finish - If you are in Advanced options still, use the right arrow key and move to Back then press enter to select. If you are at the top level menu, use the right arrow key and move to Finish to complete this process. You will be asked to reboot now. Close anything else that is open and select Yes.

  5. Update and Upgrade - After the reboot, login. You should be in the text console. We have some work still to do. sudo apt-get update && sudo apt-get upgrade -y to install and update software. Of course you'll want to get Wifi set up first.

Enable Wifi

I really wish the folks who are working on Raspberry Pi would take a look at the RetroPie-Setup wifi script as a means to set up Wifi in a textual interface much like raspi-config. Unfortunately, we don't live in such a perfect world.

For our first time, we need to do this in command line.

  1. Scan for WiFi networks sudo iwlist wlan0 scan | less -eFMXR. I added the less part so that we can browse through this list. Alternatively, we can save these results as a list. We can do that while we browse (sudo iwlist wlan0 scan | tee wifi_networks.txt | less -eFMXR) or just send all that data into a file (sudo iwlist wlan0 scan > wifi_networks.txt) and look at it later (cat wifi_networks.txt | less -eFMXR)

  2. Pick a network you know you have access to Let's use FBIPartyVan as our example. The networks are generally the line with ESSID: on them. Assuming we saved that wifi_networks.txt file we can look at the list a bit better using the sed command. I'll write a script later that you can use to view this information better. cat wifi_networks.txt | sed -n -e '/ESSID:/p'

  3. Edit wpa_supplicant.conf. Since we don't have [Vim] installed yet, we have to use [nano] to edit this file.

```
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
```

The most common set up for wifi is WPA2, where you just need the network name and the password to get in.  So at the end of that file, add this.

```
network={
    ssid="FBIPartyVan"
    psk="PayNoAttentionToThatVanOutside"
}
```
  1. Verify the connection. Once that file is edited, wpa-suplicant should be updated automatically, but to be sure use ifconfig wlan0 to verify the connection was made. A successful connection should have an IPv6-style address in the 'inet6 addr' if you are configured to used IPv6 or an IPv4-style address in the inet addr field.
Another way to verify, as well as to figure out what your IP Address is, type `ip addr`.

If it didn't connect, try `sudo ifdown wlan0 && sudo ifup wlan0`.  If it still doesn't try unplugging and replugging in the script.

TODO: I'm thinking of writing a shell script that does this later instead of installing wicd-curses. RetroPie has something like this, and it really should be included with Raspbian.

Do a firmware update!

Probably the one thing everyone doesn't seem to bring up on most of their tutorials is a FIRMWARE UPDATE

  1. sudo apt-get update && sudo apt-get upgrade
  2. sudo rpi-update to upgrade the firmware!
  3. If no errors appeared, reboot the Raspberry Pi. sudo reboot

Helpful Info: You can see when you installed packages by browsing /var/log/apt/history.log as well as the terminal log history at /var/log/apt/term.log.

Proceed to [Download the Missing Parts »](Download the Missing Parts)

External sources

Setup

  1. [Assemble the Hardware](Assemble the Hardware)
  2. [Install the Software](Install the Software)
  3. 🆙 [Setup your Raspberry Pi](Setup your Raspberry Pi)
  4. [Download the Missing Parts](Download the Missing Parts)

Typical Utilities

  • [Downloading and extracting with curl and tar](curl and tar)
  • [Browsing with ls and cat](ls and cat)
  • [Searching with grep and find](grep and find)
  • [Filtering with sed and awk](sed and awk)
  • [Piping with less, pv, and tee](less, pv, and tee)
  • Monitor your system with htop
  • Multiplex with tmux

Clone this wiki locally