RaspberryPi:Installation

From UCT EE Wiki
Jump to navigation Jump to search

Overview[edit]

In order to use the Pi you need to install an operating system on it and set up networking. You will then configure the networking settings on your Pi to allow you to access the Pi using SSH.

This process will follow headless installation, as we are going to assume most students do not have access to spare screens, keyboards and mouses for the Pi. Headless mode on the Raspberry Pi refers to using it without direct user input and output (essentially no screen, mouse or keyboard connected directly to it).

The instructions below may seem complicated, but configuring any Raspberry Pi consists of the same basic steps:

  1. Flash the SD Card
  2. Edit the configs to get headless access
  3. Complete first boot
  4. Enable configs for other connectivity

Prerequisites[edit]

Software Requirements[edit]

Note: Recently, the Pi Foundation released an imager tool which can be run from multiple operating systems and also has support for a selection of operating systems which can be installed on the Raspberry Pi. you can downlaod this tool from here. It will automatically download the selected operating system for your Raspberry Pi too, or allow you to select one you have already downloaded and have stored on local storage.

If you'd prefer not to use the Pi Foundation imager, you'll need the following tools:

  • An operating system image. It's recommended you use Raspberry Pi OS. You can read more about operating systems for the Pi on this page
  • Something to allow you to SSH in to your Pi. On Windows you can use PuTTY or WSL
  • On Windows, you will need an SD Card Formatter
  • On Windows, you will require software to burn the image. Balena Etcher is recommended.

Hardware Requirements[edit]

All Pi's Pi 0/0W Other
Micro SD Card Micro USB cable Ethernet Cable
Micro SD Card Reader 3A or greater power micro USB power supply
Computer with USB port

Installation[edit]

Using a Raspberry Pi for the first time can be intimidating, but over time (and countless flashing of software) you will realise it's quite easy! In general, it consists of the following steps:

  1. Install the operating system
  2. Adjust configuration for the first boot
  3. Upon first boot, validate settings and update any other configurations

Using the Pi Imager[edit]

  1. Plug your SD card in to your machine.
  2. Select your image, select the correct SD card, and select "Write".
  3. The tool will process the image and write it to the SD card.

Using seperate tools[edit]

  1. Preparing the SD Card
    Plug your SD card in to your machine and format it. On Windows, this can be done using the SD Card Formatter linked in the Software Requirements section.
  2. Burn the image to the SD card
    Open Etcher. Select the downloaded zip image, and the SD card, and format. At the end of format, it may read that it failed, but don’t worry. Ignore the Windows popups about needing to format the SD card. Upon completion, Windows will try to mount partitions on the SD card that it can’t read. Just press “Cancel” and then “OK” to the dialog boxes that pop up. The boot partition is the only partition we will be dealing with.

Enabling Connectivity[edit]

The form of connectivity you use depends on the Raspberry Pi you are using. However, there are some steps which are applicable to all Raspberry Pis. Before starting, disconnect and reconnect the SD card to ensure it is mounted correctly.

SSH[edit]

  1. Open the partition called "boot"
  2. Create a file without a file extension called "ssh".
    • To show file extensions on Windows, click "View" and then "File name extensions".

More information on the general use of SSH can be found in Network Protocols.

Configure Networking[edit]

Which network connectivity you decide to enable is up to your use case and the the Raspberry Pi model you're using. However, we'll cover the basics for general WiFi, Ethernet over USB for the Pi Zero, and Ethernet on other Pi models. To learn more about connectivity on the Pi, read through RaspberryPi:Networking.

General Wifi Connectivity[edit]

You can enable WiFi connectivity before first boot by adding a wpa_supplicant file to the boot partition. Simply open the boot partition and create a file called wpa_supplicant.conf. The contents would be the same as described at RaspberryPi:Networking

If you've already got access to the Pi, you can run sudo raspi-config to configure wifi through command prompts.


For details on connecting the Pi to Eduroam, visit RaspberryPi:AdvancedConnectivity

Static IP for Pi with Ethernet[edit]

When using an Ethernet connection, it can be beneficial to assign a static IP to the Ethernet port on the Pi. This however requires knowledge of subnets and IP addresses. For information on this, see RaspberryPi:AdvancedConnectivity#Static_IPs

SSH over USB for Pi 0/0W[edit]

When using a Pi 0 or 0W, using the on-board USB as a connection for SSH is very useful. It means just a single port is required for all access to the Pi, so long as you're not doing anything that requires too much current. To see details on setting up Ethernet over USB on the Raspberry Pi, visit RaspberryPi:Networking#Using_USB_connectivity_on_the_Pi_0.2F0W.

First Boot[edit]

  • Boot
    Insert the SD Card into the Pi, and power it on.
  • Ensure Connectivity
    Try and ping the Pi's static IP, or view COM Port connections if you are using the Pi Zero Serial option. For example,
    $ ping 192.168.137.15

    You should see a response similar to

     $ 64 bytes from 192.168.137.15: icmp_seq=1 ttl=64 time=0.557 ms

    or

     $ Reply from 192.168.137.15 bytes=32 time=0.5ms TTL=52
  • SSH In to your Pi
     $ ssh pi@192.168.137.15

    You will be asked to add the machine to known hosts. Select yes. The default password for Raspbian is simply "raspberry".

  • Change your password
    To change your password, you can simply run
    $ passwd 
  • Enable Services
    It's a good idea to enable useful services on the Pi.
    1. On your Pi, run
       $ sudo raspi-config
    2. Use the arrow keys and scroll down to "Interfacing Options"
    3. If not enabled, enable SSH, VNC, SPI, I2C and Serial
    4. Save and exit raspi-config by using the left and right arrow keys to jump to the bottom buttons. Your Pi will reboot.
  • Expand the Filesystem
    The Rasberry Pi Installation may not make use of the full SD card. In order to give yourself as much file space as you have access to, you need to expand the filesystem.
    1. SSH into the Pi
    2. Run
       $ sudo raspi-config 
    3. Use the arrow keys and scroll down to “Advanced Options
    4. Select "Expand Filesystem"
    5. You will be shown a message saying that the root partition has been resized. Select “Ok”, then “Finish” then “Yes” to reboot your Pi.
  • More detailed Information[edit]

    If you need more detailed information on how to configure the SD card when using a different operating system (such as Mac), visit the Raspberry Pi Website