Install an operating system on a Raspberry Pi

From Parallel Library Services
Jump to navigation Jump to search
Raspberry Pi 2 Model B v1.1 underside new (bg cut out)

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.

Automatic installation

Raspberry pi imager 01.png

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.

For my OS installation, I chose Raspberry Pi OS (other) > Raspberry Pi OS Lite (32 bit). The "recommended" OS on this imager is one with a desktop environment. I chose the Lite OS because I plan to run a service from this computer, so I don't need it attached to a screen after the initial setup. Choosing a Lite OS also means that it takes up little space on the SD card, compared to the "Full" or with desktop operating systems. If you want to use the Pi as a personal computer and browse the internet, or use desktop applications such as Calibre or LibreOffice you may want a desktop environment, however it will be more difficult to run web services from it, and there won't be much space on the card left to install or download things.

On your computer:

  1. Download the imager software to your computer and install it.
  2. Connect the SD card to your computer.
  3. 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.
  4. For the basic installation choose an operating system and find your SD card for storage
  5. Click Write. All your existing data will be overwritten. If you are ok to go ahead, click yes.
  6. 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.
  7. Click Continue, then remove the SD card from your computer.

On your Pi

  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 default 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.

You can do this from Raspberry Pi OS application raspi-config, or from the command line.

sudo raspi-config

The interface is text only, and you can scroll through menus using the arrow keys to find system settings for passwords.

Or, from the command line simply run:

passwd

Then, choose a new password and type it twice.

Manual installation

You can also manually install the OS by navigating to this page, and choosing and downloading from the list of operating system images. After you download the OS, then you'll flash the image to a disk using command-line tools.

If going the manual route, be careful that you find the right disk, you can overwrite the hard drive 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.

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 into your computer (not the Pi)

Mac

1. First open terminal

2. Find the disk that you are going to write to

diskutil list

3. 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. Be careful to find the right disk!

4. 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>

5. Then to flash 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

1. 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 to find the right disk!

2. Unmount this disk (notice that the command is "umount", not "unmount")

umount /dev/path/to/disk

3. Write the image to the disk

sudo dd bs=4M if=minibian.img of=/dev/sdc status=progress

4. Insert the SD card into the Raspberry Pi

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

The operating system should now be installed.

6. 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

What next?

What happens next very much depends on what you want to use the Pi for. It could be a shared computer on a local network distributing books. Or a shared library on a wide network. Or a machine to run scripts to make PDFs.

For particular recipes, refer to the Cookbook.