Linux Format

Flashing a new OS

Les Pounder is always flashing a new OS to his Raspberry Pi and these are the tools of his trade.

- Les Pounder is associate editor at Tom’s Hardware and a freelance maker for hire. He blogs about his adventures and projects at bigl.es

Les Pounder is always flashing a new OS and these are the tools of his trade.

Microsd cards are fickle little things. One moment they’re fine, the next they no longer work. Backing up your SD cards and keeping up to date with the latest releases is an essential part of the Raspberry Pi experience. In this tutorial we shall take a look at two graphical tools that can be used to create new SD cards, a terminal tool that offers the same but for more advanced users, and look at how you can back up your Raspberry Pi OS image to share with friends and colleagues. We also examine how it’s possible to copy our Raspberry Pi OS install to an SSD for use with a Raspberry Pi 4 for a speedy Raspberry Pi experience. All this in just two pages!

Using a GUI

There are two main ways to flash an SD card via a GUI. For many years Etcher was the main means with which to flash a card. Etcher provides a simple three-step interface where we choose our downloaded OS image, choose the destinatio­n SD card, then write the image. Download Etcher for your OS from www.balena.io/ etcher and extract the contents to your home directory. Next, open a terminal and move the extracted balenaetch­er file, which is an executable program image, to the /usr/bin directory. You may need to change the version number of your download to match the latest release.

$ sudo mv Desktop/balenaetch­er-1.5.115-x64.appimage /usr/bin/

To run Etcher, open a terminal or press Alt+f2 to enter a command, type balena and then press TAB to autocomple­te the rest of the command. Press Enter to run. The Etcher user interface is simple: we work from left to right, completing the steps as we go.

The first step is to select the source file containing the image that we wish to flash on to the SD card. This can be a local file, saved to your hard drive, or it can be a URL from a website, such as raspberryp­i.org. We chose to flash the latest Raspberry Pi OS image to our target 16GB microsd card. Clicking Flash! prompts Etcher to ask for authentica­tion before downloadin­g and flashing the image to our card. Depending on your internet and SD card speed, this process can take a few minutes.

While we wait for this to finish, now is a great time to talk about Etcher’s little-known features. Etcher can write to multiple USB sticks or SD cards at once. Etcher can even write to microsd cards inserted into Raspberry Pi Zeros and the EMMC flash of Raspberry Pi Compute Modules. So if you need to write cards for your next Raspberry Pi event, class or project, Etcher is an exceptiona­lly handy applicatio­n to have in your toolkit.

A second option

There’s an alternativ­e to Etcher and it comes directly from Raspberry Pi. Raspberry Pi Imager works in a similar process to Etcher, but it has a great choice of alternativ­e operating systems, grouped by their purpose. Raspberry Pi Imager has the same three-step process as Etcher, but under CHOOSE OS we see a plethora of options. Obviously at the top is the latest Raspberry Pi OS 32-bit image, but under that option is Raspberry Pi OS (other). By clicking this, we can see alternativ­e versions of Raspberry Pi OS including a lite version for headless/server projects.

Under Other general purpose OS there are install candidates for Ubuntu 20.04 (Raspberry Pi 3 and upwards) and Ubuntu’s IOT Core OS used in embedded/ headless projects. If your needs are more entertainm­ent-based, then you can install the emulation OS Retropie and Recalbox or Kodi OS to consume your media library.

Raspberry Pi Imager has a couple of useful extra features, namely an EEPROM recovery tool for the Raspberry Pi 4 and a FAT32 format tool to fix corrupt

SD cards or USB sticks. Raspberry Pi Imager can also be used with any downloaded custom imagers. The tool can be downloaded from www.raspberryp­i.org/ software. It’s extremely easy to use and recommende­d for new users. Raspberry Pi Imager can also be installed in the Raspberry Pi OS – just open a terminal and type the following commands:

$ sudo apt update

$ sudo apt install rpi-imager

Raspberry Pi Imager can now be found in the Accessorie­s menu.

From the terminal

In the early days of the Raspberry Pi, it was common for many to flash their SD cards using the terminal. The main tool for this task is dd and it’s a powerful tool, but with great power comes great responsibi­lity. The dd command is pre-installed on Ubuntu and so we can use it straight away. Before we get started, take great care with dd. If you’ve never flashed an SD card before, use one of the GUI tools – dd is capable of causing great damage! You have been warned.

First let’s write a downloaded Raspberry Pi OS Image to a microsd card inserted into a USB card reader. Open a terminal and navigate to the directory containing the downloaded image. Insert a USB card reader with your SD card inserted. In the terminal enter this command to list connected and mounted devices: $ df In our case the USB card reader was at /dev/sde1 and so to write the image to the SD card, we need to unmount that USB device: $ sudo umount /dev/sde1 We’re now ready to write the image to the SD card using dd. The syntax of the command is that we tell dd where the input file (if) of our downloaded image is located and then we pass the output file (of) to the USB card reader device. We don’t need to pass the number at the end of the device because that will write to a partition – we want to write to the whole drive, then we pass the bytes (bs) to be written each time a write is made. Before running the command, check the if and of options before pressing Enter.

$ sudo dd if=rasberrypi­os.img of=/dev/sde bs=1m

This will take about 10 minutes to write and during that time there’s no progress indicator, so grab a cup of tea and come back when it’s done. Eject the SD card and you’re ready to use it in your Raspberry Pi

Back up an existing card

Raspberry Pi OS has an ace up its sleeve – a great tool to back up SD cards ready and waiting for us! Found in the Accessorie­s menu, SD Card Copier is a powerful tool. It’s used to copy the current Raspberry Pi OS to another device. This is handy for backing up our important projects, sharing custom installati­ons with friends or even installing Raspberry Pi OS to a USB drive or SSD – something that can massively boost your Raspberry Pi experience.

 ??  ?? The Etcher user interface is a simple three-step process, which sees us move from left to right, setting up the input file and output device.
The Etcher user interface is a simple three-step process, which sees us move from left to right, setting up the input file and output device.
 ??  ??
 ??  ?? The official Raspberry Pi Imager tool is simplicity in design and operation. Choose from a wide selection of general operating systems, and specialist Oses for gaming and media consumptio­n.
The official Raspberry Pi Imager tool is simplicity in design and operation. Choose from a wide selection of general operating systems, and specialist Oses for gaming and media consumptio­n.
 ??  ?? Often overlooked, SD Card Copier is an essential tool to copy your current card to SD, USB and SSD drive. Very handy for increasing your enjoyment of the Raspberry Pi.
Often overlooked, SD Card Copier is an essential tool to copy your current card to SD, USB and SSD drive. Very handy for increasing your enjoyment of the Raspberry Pi.

Newspapers in English

Newspapers from Australia