Difference between revisions of "RaspberryPi:Installation"

From UCT EE Wiki
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:RaspberryPi]]
 
[[Category:RaspberryPi]]
 +
= Overview =
 +
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.
  
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).
  
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:
  
 +
# Flash the SD Card
 +
# Edit the configs to get headless access
 +
# Complete first boot
 +
# Enable configs for other connectivity
  
== Prerequisites ==
+
= Prerequisites =
Hardware Requirements:
+
== Software Requirements ==
* Raspberry Pi, and a means of connecting to it, such as an Ethernet Cable for a Pi 3b+ or a standard USB cable for the Pi Zero/ZeroW
+
'''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 [https://www.raspberrypi.org/downloads/ 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.
* A micro SD card
 
* If you're using the Pi 3b+, a power source (the USB port doesn't provide enough current)
 
* A means of writing to the SD card, such as an SD card reader
 
  
Software Requirements
+
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 [https://www.raspberrypi.org/downloads/raspbian Raspbian]. You can read more about operating systems for the Pi on [http://wiki.ee.uct.ac.za/RaspberryPi:Overview#OperatingSystems this page]
+
* An operating system image. It's recommended you use [https://www.raspberrypi.org/downloads/raspberry-pi-os/ Raspberry Pi OS]. You can read more about operating systems for the Pi on [http://wiki.ee.uct.ac.za/RaspberryPi:Overview#OperatingSystems this page]
 
* Something to allow you to SSH in to your Pi. On Windows you can use [http://wiki.ee.uct.ac.za/PuTTY PuTTY] or [http://wiki.ee.uct.ac.za/Windows_Subsystem_for_Linux WSL]
 
* Something to allow you to SSH in to your Pi. On Windows you can use [http://wiki.ee.uct.ac.za/PuTTY PuTTY] or [http://wiki.ee.uct.ac.za/Windows_Subsystem_for_Linux WSL]
 
* On Windows, you will need an [https://www.sdcard.org/downloads/formatter\_4/eula\_windows/index.html SD Card Formatter]
 
* On Windows, you will need an [https://www.sdcard.org/downloads/formatter\_4/eula\_windows/index.html SD Card Formatter]
 
* On Windows, you will require software to burn the image. [https://www.balena.io/etcher/ Balena Etcher] is recommended.
 
* On Windows, you will require software to burn the image. [https://www.balena.io/etcher/ Balena Etcher] is recommended.
  
== Installation Process ==
+
== Hardware Requirements ==
 +
{| class="wikitable"
 +
|- style="font-weight:bold;"
 +
! 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 =
 +
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:
 +
# Install the operating system
 +
# Adjust configuration for the first boot
 +
# Upon first boot, validate settings and update any other configurations
 +
 
 +
== Using the Pi Imager ==
 +
<ol>
 +
<li>Plug your SD card in to your machine.</li>
 +
<li>Select your image, select the correct SD card, and select "Write". </li>
 +
<li>The tool will process the image and write it to the SD card.</li>
 +
</ol>
 +
== Using seperate tools ==
 
<ol>
 
<ol>
 
<li> Preparing the SD Card </br>
 
<li> Preparing the SD Card </br>
Line 26: Line 61:
 
<li> Burn the image to the SD card </br>
 
<li> Burn the image to the SD card </br>
 
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. <strong>Ignore the Windows popups about needing to format the SD card.</strong> 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. </li>
 
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. <strong>Ignore the Windows popups about needing to format the SD card.</strong> 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. </li>
 +
</ol>
  
<li> Enable SSH <br>
+
= Enabling Connectivity =
SSH is covered in detail in [[SSH]], but for now just enable SSH by creating a file called “ssh” (no file extension) on the boot partition of the SD card.</li>
+
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 ==
 +
<ol>
 +
<li> Open the partition called "boot"
 +
<li> Create a file '''without a file extension''' called "ssh".</li>
 +
<ul>
 +
<li> To show file extensions on Windows, click "View" and then "File name extensions".  
 +
</ul>
 +
</ol>
  
<li>Configure Networking<br>
+
More information on the general use of SSH can be found in [[Network Protocols]].
Please read through [[RaspberryPi:Networking]]. Configuring networking on the Pi depends on what Pi you are using. For example, if you're using a 3b+, you may want to connect via a static IP over Ethernet. If you are using a Pi Zero, you may want to connect over a USB to Serial or USB to Ethernet connection. In both cases, you will likely want to connect your Pi to Wifi through Eduroam.
+
 
</li>
+
== Configure Networking ==
 +
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 ===
 +
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 <code>wpa_supplicant.conf</code>. The contents would be the same as described at [[RaspberryPi:Networking]]
 +
 
 +
If you've already got access to the Pi, you can run <code>sudo raspi-config</code> to configure wifi through command prompts.
 +
 
 +
 
 +
For details on connecting the Pi to Eduroam, visit [[RaspberryPi:AdvancedConnectivity]]
 +
 
 +
=== Static IP for Pi with Ethernet ===
 +
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 ===
 +
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 =
 
<li>Boot<br>
 
<li>Boot<br>
Insert the SD Card into the Pi, and connect your Pi via the interface you are using</li>
+
Insert the SD Card into the Pi, and power it on.</li>
  
 
<li>Ensure Connectivity <br>
 
<li>Ensure Connectivity <br>
Line 57: Line 118:
 
<ol>
 
<ol>
 
<li>On your Pi, run <pre> $ sudo raspi-config</pre></li>
 
<li>On your Pi, run <pre> $ sudo raspi-config</pre></li>
<li>Use the arrow keys and scroll down to “Interfacing Options”</li>
+
<li>Use the arrow keys and scroll down to "Interfacing Options"</li>
 
<li>If not enabled, enable SSH, VNC, SPI, I2C and Serial</li>
 
<li>If not enabled, enable SSH, VNC, SPI, I2C and Serial</li>
 
<li>Save and exit raspi-config by using the left and right arrow keys to jump to the bottom buttons. Your Pi will reboot.</li>
 
<li>Save and exit raspi-config by using the left and right arrow keys to jump to the bottom buttons. Your Pi will reboot.</li>
 
</ol>
 
</ol>
 
</li>
 
</li>
 
  
 
<li>Expand the Filesystem <br>
 
<li>Expand the Filesystem <br>
Line 76: Line 136:
 
</ol>
 
</ol>
  
== More detailed Information ==
+
= More detailed Information =
 
If you need more detailed information on how to configure the SD card when using a different operating system (such as Mac), visit the [https://www.raspberrypi.org/documentation/installation/installing-images/README.md Raspberry Pi Website]
 
If you need more detailed information on how to configure the SD card when using a different operating system (such as Mac), visit the [https://www.raspberrypi.org/documentation/installation/installing-images/README.md Raspberry Pi Website]

Latest revision as of 11:10, 4 September 2020

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