Install an operating system on a Raspberry Pi

From Parallel Library Services
Revision as of 19:08, 23 October 2021 by Simon (talk | contribs)
Jump to navigation Jump to search

Setting up a Raspberry Pi single-board computer can be daunting if it's the first time but it's not too difficult with practice. This guide is a basic primer on installing Raspberry Pi OS Lite on a Raspberry Pi 3.

Raspberry Pi OS (formerly known as Raspbian) is an operating system based on Debian and optimised for use with Raspberry Pi. With this installed, you are able to use your Pi for a wide range of purposes; both over the local network to run local services and from the outside to run web services.

You will need the following:

  • a Raspberry Pi computer & power cable
  • an internet connection
  • a computer (desktop or laptop) with an SD card burner (or dongle)
  • a HDMI cable
  • a monitor to connect to the Pi
  • a keyboard to connect to the Pi
  • an SD card for the operating system

SD cards come in various capacities and speeds; choose something suitable for what you want to use the Pi for. I used a SanDisk Ultra microSDHC UHS-I Card, in 32GB capacity.

Flash an operating system image on an SD card

Automatic installation

The Raspberry Pi website offers operating systems for RPi, as well as an installer called "Raspberry Pi Imager". This installer allows you to "flash" (or copy) an "image" (the OS firmware, in this instance) on to an SD card in a streamlined, seamless process.

Raspberry pi imager 01.png
  1. Download the imager software to your computer and install it.
  2. Connect the SD card to your computer.
  1. Open the imager application. From here you can follow a basic, or advanced installation process. If you type shift+control+x, you can prefill options for overscan, wifi, SSH and password. You can also configure these options later.
  2. For the basic installation choose an operating system and find your SD card for storage
  3. Click Write. All your existing data will be overwritten, and a warning will pop up to tell you the same. If you are ok to go ahead, click yes.
  4. The imager application will begin writing or "flashing" an operating system to your SD card. After it has finished, it will run a process to verify if the image is free of errors. If it is ok, you will be prompted to continue, and safely remove your SD card.
  1. Click Continue, then remove the SD card from your computer.
  1. Insert your SD card into your Raspberry Pi.
  2. Connect a keyboard and monitor to it for the initial configuration. You will not need a mouse, but you should have a screen.
  3. Connect a power source and turn it on. You should see a lot of scripts running, and when they stop, you have a basic operating system installed.

For Raspberry Pi OS, if you need to manually log in, the default user name is pi, with password raspberry, and the default keyboard layout is set to United Kingdom (UK).

Raspbian GNU/Linux 10 raspberrypi tty1
raspberrypi login: pi
Password:

Enter in the correct login credentials (pi, raspberry), and you will be logged in as the default pi user. You should change the default password straight away to ensure your Raspberry Pi is secure.

Change the Default Password

From the command line:

<syntaxhiglight lang="bash" line> passwd </syntaxhighlight>

Choose a new password and type it twice.

Manual installation

You can also choose to manually install the OS by navigating to this page, and choosing and downloading from the list of operating system images. Once the image has been downloaded to your computer, you will still need to transfer it to the SD card, following these steps:

1. Unzip the downloaded OS

2. Stick SD Card in to your computer (not the Pi)

mac
  • First open terminal
  • Find the disk that you are going to write to
diskutil list

!!! Be careful that you find the right disk, you can overwrite the harddrive of your computer easily when you pick the wrong one !!! To make it easier, and to avoid wiping external drives, make sure you have nothing else plugged in aside from your SD Card.

  • Find the disk name that reads something like /dev/disk<number> that doesn't have a partition on it named something like Macintosh HD. For example /dev/disk2
  • You need to unmount the SD Card before imaging (replace <number> with the disk number found in the first step)
sudo diskutil unmountDisk /dev/disk<number>
  • Then to image the disk with your image put in the following command (replace the minibian.img with the full path to your downloaded image file, and the <number> with the disk number that you found in the 1st step)
sudo dd bs=4m if=minibian.img of=/dev/rdisk<number>

linux

  • Find the disk that you are going to write to, find its path, for example /dev/sdb/

You can do this using software like gparted or Disks (on Gnome), or use the command line tools df.

df -h

!!! Be careful that you find the right disk, you can overwrite the harddrive of your computer easily when you pick the wrong one !!! To make it easier, and to avoid wiping external drives, make sure you have nothing else plugged in aside from your SD Card.

  • Unmount this disk (notice that the command is "umount", not "unmount")
umount /dev/path/to/disk
  • Write the image to the disk
sudo dd bs=4M if=minibian.img of=/dev/sdc status=progress

3. Insert the SD card into the Raspberry Pi

4. Power the RPi, wait for crazy blinking to stop

The operating system should now be installed. Connect a screen and keyboard to the Pi, and you should be able to operate it under the default "Pi" account, with the default login "raspberry". Make sure you change your password immediately,

passwd

Configuring the Pi

The operating system has an application called raspi-config, which allows you to make changes to the configuration of the Pi. To open it, from the command line, run

<syntaxhiglight lang="bash" line> sudo raspi-config </syntaxhighlight>

The interface is text only, and you can scroll through menus using the arrow keys. Some things you may want to do here are configure Wireless LAN, change the hostname of the computer, and enable SSH, especially if you are planning to access it remotely.

Configure a Raspberry Pi Enable SSH on a Raspberry Pi Make new user accounts in Unix Shell