How to boot balenaOS on an SSD: why it matters and how it works

In this blog post, we’re going to cover how to boot balenaOS on an SSD for Raspberry Pi 4. This opens up many benefits, including faster load read and write times for not only running the OS on edge devices, but also for application operations.

We will be using a USB3 to SATA converter as a go-between our standard 2.5inch SSD, and your regular RPi4 - as the RPi4 doesn’t ship with a SATA or PCIe port exposed.


## Why boot from something other than an SD card?

I feel the need for speed

Booting your OS from an SSD can yield far faster, snappier results than using an SD card. You’ll get much better read and write speeds and, in many cases, SSDs are just more wear and tear-resistant than SD cards.

Booting from an SSD is also helpful in:

  • Edge projects and applications where you want to set up a device and not worry about it for long periods of time
  • Projects in environments where there might be power fluctuations that can be harmful to SD card performance and wear-and-tear
  • Edge applications and use cases where you need a lot of storage and can leverage savings from upfront investments into SSDs (by the GB, it’s cheaper to use SSD over time)

We’ve heard community members echo similar reasons for wanting to boot balenaOS from an SSD and for more SSD support. Some folks are curious about booting from an SSD, and some want the reliability increase from SSDs.

## Getting the Hardware

### Choosing wisely

The quality of the hardware that you choose matters, especially for the main disk drive of your SBC. Similar to how choosing too low-quality of an SD card causes immature failure or performance issues, this is the same even when moving to SSDs.

From an at-scale, industrial perspective, poor choices in picking the medium can be expensive. For example Tesla has to recall cars because they used eMMC that can’t be easily replaced.

For testing and prototyping, choosing something convenient (by price or ease of access) is fine to get a better understanding of how this works. However, please consider SSDs with a good track record for industrial use before putting SSDs to work in the field in your IoT fleet.

### What’s a UASP and do I care?

Yes, you should care!

When you search for USB3 to SATA cables on Amazon or any similar site, you are going to find some that support UASP, and some that don’t. Make sure that you pick one that has UASP. It should be mentioned in the description, but another way to tell if UASP is supported is by looking at the chipset that is involved. For example, ASM 1153e is the most popular chipset used in such converters that supports UASP.

Read this article to learn more about the importance and performance benefits of UASP.

### Recommended hardware

You’ll need the following to use this guide.

  1. A Raspberry Pi 4 (for the best performance and results)

  2. A SD card for one of the steps to prepare your device to recognize an SSD (e.g. SanDisk Extreme Pro)

  3. A USB to SSD converter based on the ASM 1153e chipset (like this one, or similarly accessible in your region)

  4. An SSD, options are many, and include:

  5. Crucial BX500 120GB (I’m testing this-- value for money)

  6. Samsung EVO series (supposed to have epic performance)

How to boot balenaOS from an SSD

  1. Flash Raspberry Pi OS Lite on an SD card using balenaEtcher

    1. Head over to raspberrypi.org, and make sure to download the Raspberry Pi OS Lite. We don’t necessarily need the lite version, but we only need it as a stop gap measure so we are optimizing for quick download :slight_smile:
    2. Enable ssh, in case you don’t have a spare screen and keyboard handy.
    • To enable SSH: Add a file in the boot partition of the just-flashed SD card called ssh.
    1. Unmount or safely remove the SD card from your PC
  2. Plug in the SD card in your Raspberry Pi 4, connect ethernet cable or optionally plugin the keyboard and screen - and turn on the power.

  3. Update eeprom

    1. You can either connect a screen and keyboard, or plug it in using an ethernet cable to your router.

    2. Open an ssh terminal to the RPi4 or launch the terminal app.

      1. Run sudo raspi-config
      2. Select Advanced Options
      3. Select Boot Order
      4. Select USB
      5. Reboot
  4. Flash balenaOS on SSD

    1. Download the app you want to flash on your RPi4 by clicking on the Deploy with Balena button on hub.balena.io. For this example we’ll use the Nextcloud app by Balena’s very own Kyle Harding.
    2. Put the SSD in the USB enclosure/connector - and connect it to the laptop that you are using Etcher on. It should show up as a USB mass storage device.
    3. Flash the device!

        * Unplug the ssd from your computer
  1. Power down the RPi4 if you haven’t already
  2. Plug into one of the 2 blue-on-the-inside (those are the USB3 ports) USB ports of the RPi4. Remove the SD card from it’s slot
  3. Power up the RPi4. Make sure you use a good power supply - at least 20 watts - as the SSD will consume more power than your regular SD card.
  4. Wait for a couple seconds for the device to connect to balenaCloud. Some USB-SATA converters have an activity LED. Those should be blinking during this process.Once it does, you should see something like the following for your device -

Community help: WANTED

At some point, we can remove more friction from this guide by eliminating the eeprom update steps. Until we get to that point, users will either need to just follow the guide as-is, or some courageous, talented community members can help us create a Project to containerize these steps. It’s a great way to meet some of the balena crew, learn about Projects and Blocks, and level up your edge development skills.

If you’re interested, please get in touch via the comments or on our Forums.

What’s next?

This guide is a first version of what will hopefully be a much smoother process. We’re researching ways to reduce the number of steps to install balenaOS onto an SSD. We didn’t want to wait on fully polishing that path, so we released all the steps in this guide so that our users and community could get started.

Our team will also try and compare a few different brands of SD cards and SSDs to do a little benchmarking of read and write speeds. Once we get our hands on a few more CM4 boards, we’ll do some tinkering and testing here as well.

See the performance benefits

Did you get balenaOS to load on your device via SSD? Congratulations! You’re now ready to enjoy the benefits of fast, reliable, and cheap - albeit a little bulky - storage on your Raspberry Pi 4. Some apps that can benefit from a faster, more resilient storage device include:

  • Edge/IoT display projects, like Screenly OSE and balenaDash
  • Jenkins
  • Projects where you need to write sensor data to a volume over time, like balenaSense and balenaPlant
  • Video and surveillance projects, like balenaCam and Kerberos.io
  • Nextcloud
  • Minecraft Server
  • Image Classification, like Edge Impulse
  • …and more on balenaHub

Now that you have a RPi4 configured to boot from a fast SSD over USB - check out all the above apps on hub.balena.io. Let us know about your new projects on our Forums. We’d love to see how using an SSD inspires new project ideas or breathes new life into ones you’re already running.

1 Like

@wyatt @anujdeshpande : Hey all! Discourse is a little finnicky with the specific groups and posts thing, so I hope this works. The previous message is an internal draft of our upcoming balenaOS on SSD guide created by Anuj.

Wyatt, thanks for your interest in trying this out. Please give it a go. Feedback and questions are totally welcome.

P.S. Eventually, this whole category and this topic will be public, so treat this as you’d treat the rest of the forums :slight_smile:

1 Like

Thanks for the guide folks! It worked flawlessly with a samsung SSD 1TB, T5 series.

The ssd is the cheapest SSD i could find that I was certain is reliable, has UASP support and will play nice with raspberry pi 4. NVME are not really meaningful with a raspberry pi cause of the USB connection, thus SATA is OK, as far as speed are concerned.

I am using this for a pet project (@mpous it’s Urbit!) and I want to skip the intermediary step of installing the raspbian. Do you have any insight into what a solution could look like? Happy to contribute back the code for everyone to use!

In the boot menu, saw that USB boot was second in the order. Shouldn’t it automatically boot from the ssd if the SD card I put is not bootable? (I think you have to have an SD card in order for the whole boot sequence to begin).

2 Likes

Great that it working good for your pet project @odyslam

Actually we are looking for contributors as Andrew suggested on his message

Did you test your hypothesis? Looking forward to see if you can contribute on this :slight_smile:

Thanks a lot @odyslam ! cc @anujdeshpande check the feedback, dawg!

Is it possible to boot from a NVMe with CM4 based designs? If so is there a guide for that?

Thanks,

The boot sequence is correct on newer Raspberry Pis that are shipping with the latest bootloader. If you have an RPi4 that you bought a while ago and haven’t updated the bootloader of, then you’d need to do the step where you flash raspbian, update bootloader, etc.
So this whole situation is in a way temporary - as newer Pis won’t need any of this, and older Pis will update to newer firmware.

A better way here would be to let balenaOS handle firmware updates but we don’t have that functionality in here yet.

A third way to do this would be to have an app which flashes the latest firmware, and then optionally flashes the connected SSD with the OS+app that is running on the device (this bit is trickier). That way existing devices can migrate seamlessly to running off an SSD
I started some work on this approach here but haven’t had time to take it forward tbh

1 Like