Flashing a Raspberry Pi Image on Ubuntu

When you work with Raspberry Pis you will quickly run into to fact that you want to create a bootable image on a microSD card. On Ubuntu you can install Raspberry Pi Imager which is a snap package.

Although this is an easy install, snap packages run in a confinement for security reasons. Because of this confinement however, not everything works as one would like.

In this post I will explain how to configure the Raspberry Pi Imager snap install on Ubuntu to be able to properly create bootable microSD cards.

Install the Raspberry Pi Imager

Installing the Raspberry Pi Imager is easy. Just open Ubuntu Software and search for ‘Raspberry Pi Imager’. Press Install and you are almost good to go! (almost…)

Setting advanced configuration options

The Raspberry Pi Imager has a ‘hidden’ feature to allow setting advanced configuration options for the image being created. I have no clue as to why it is not visible in the UI, a newbie will not figure this out easily, but the settings can be opened using the key combination <ctrl><shift>x

This will open a settings window as is shown below.

Now you are able to change the hostname, default password, configure wifi and enable SSH access. This will allow you to just boot the Raspberry and connect to it using SSH instead of needing to attach a keyboard and monitor to it.

However….

Here lies the problem

When de advanced settings are changed. The Imager will mount the newly created microSD card and after that it wants to write/change files on the disk with the configured settings. However, because of the snap confinement, the installer is not allowed to read/write to external disks.

The following error will occur:

The flashing of the SD card went ok, but applying the customizations fails with the error:

Error creating firstrun.sh on FAT partition

(Strangely it can write to the raw device, but it cannot read/write to the mounted filesystem).

The solution

The solution luckily is really simple, but it is missed on a lot of forums.

Snap installs can be configured using Ubuntu Software. The configuration allows a user to specify what kind of actions are allowed for the snap install.

For the Raspberry Pi Imager we need to enable ‘Read/write files on removable storage devices’ as is shown in the image below:

After this change is made, flashing the SD cards works as expected.

Happy Raspberry Pi-ing 🙂

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s