Today we are going to be show you how to boot your Raspberry Pi 4 from a USB SSD or flash drive. This is Episode 3 in our Raspberry Pi series .
Note: Only follow this episode if you intend to move the Raspberry Pi Operating system from the SD card to an external Solid-state drive or USB flash drive. If not skip this episode and continue on to Episode 4.
**This post was updated on 7th July 2022
Difficulty = Medium
Why would you want to boot a Raspberry Pi from an SSD or Flash Drive?
Micro SD cards are cheap and wield high storage capacity which is great for Raspberry Pi’s when doing small projects or tinkering.
However, SD cards are prone to unexpectedly failing or corrupting data. Especially when the card is being written to regularly.
Continuous writing over time to a Micro SD card is not a good idea and will at some point cause data corruption or even worse the complete failure of the card leading to data loss.
Power fluctuations and outages can also plague the Raspberry Pi’s and this can also affect any data being written at the time the system power outage happened again leading to data corruption.
This happens more often than gets reported. In the 6/7 years, we have been using Raspberry Pi’s we have had 3 SD cards die in production and several data corruptions which have resulted in complete data loss and a fresh rebuild was needed.
For a server environment, we need stability and up-time and due to this, we recommend moving the micro SD card boot partition and OS to a dedicated external SSD or USB flash drive.
What SSD Drives do we recommend:
We hope you love the products we recommend! Just so you know, we may collect a share of sales or other compensation from the links on our website. Thank you if you use our links, we really appreciate it!
|Crucial BX500 120 GB Internal SSD, Black||SanDisk SSD PLUS 120 GB Internal SSD, Black|
What Flash Drives do we recommend:
|SanDisk Extreme Go USB 3.1 128 GB Flash Drive||SanDisk – 128GB Ultra Flair USB 3.0 Flash Drive|
You should have the Micro SD card inserted into your Raspberry Pi 4 with Raspberry Pi OS Lite installed onto it. If you haven’t got this far please follow our previous guide on how to do this.
You should have the Ethernet cable connected to the router or networked switch, power supply and your raspberry pi should be powered on. You should see lights coming from the Pi.
You will need to have another computer on the network to connect to your Raspberry pi 4 over SSH and to write the Raspberry Pi OS Lite image to the SSD.
Please Note: To begin with please make sure your SSD is disconnected from your Raspberry Pi.
You will also need to know what your Raspberry Pi’s local IP address is. To find that please follow this GUIDE: https://www.addictedtotech.net/how-to-find-your-raspberry-pis-ip-address-on-your-local-network/
Please also make sure that when using the Raspberry Pi 4’s USB ports that you are using the Blue coloured ones which are 3.0 supported.
Ok ready… Lets get started.
How to boot Raspberry Pi 4 from A USB SSD or Flash Drive
Step1: Connect to your Pi over the network via Secure Shell (SSH)
First, we need to SSH (Secure Shell) into the Raspberry Pi over the network using a terminal. From here we can run commands directly on the Pi. We showed you in the previous Episode how to enable SSH so if you haven’t watched it feel free to skip to the part where we show you how to do this.
Once installed open PUTTY and enter in you IP address
Then click “Open”
Accept any prompts
Now login with the Pi’s default username:
and enter the Pi’s default password when prompted
Press Enter to log in.
On Linux & Mac:
You can open a terminal window by opening the Terminal application.
Type the following into the terminal
ssh [email protected]<YOUR_IP_ADDRESS>
You should now see the Raspberry Pi’s terminal splash screen.
Step 2: Updating The Raspberry Pi OS
Before we start we want to make sure our Raspberry Pi is up to date and has all the latest packages installed.
In the terminal
First we need to make sure the Raspberry Pi packages are up to date. This downloads package information from all configured sources.
sudo apt update
Next we need to upgrade all installed packages to the latest version
sudo apt upgrade
Now we need to upgrade any Operating system updates including the new bootloader which was released after 3rd
September 2020 which enabled booting from USB.
sudo apt full-upgrade
Now we are going to change some settings in the raspi-config menu so that on boot the Raspberry Pi will look for the bootable USB mass storage device first. If the device is not present then it will fall back to the Micro SD card also known as 0xf41 Boot mode.
You should now see the Raspberry Pi Software Configuration Tool (raspi-config) splash menu.
From here you need to navigate down the list to “6 Advanced Options”
Then go down the list to “A6 Boot Order”
Then select “B2 USB Boot“
Just press enter and you should see some code execute than the menu screen should show the prompt screen which will say “USB device is default boot device”
Then navigate down the main splash screen to “<Finish>” and press Enter
You will now need to reboot.
Press Enter on “<Yes>”
Your Raspberry Pi will reboot. At this time back into your Micro SD card.
Step 3: Reconnect to your Raspberry Pi using SSH
Once it has finished booting reconnect to your Raspberry Pi through SSH.
ssh [email protected]<YOUR_IP_ADDRESS>
Step 4: Modify The Bootloader
Verify that the Bootloader is up to date
We can now verify if the EEPROM Bootloader firmware is up to date
If you get similar to the following then everything is as expected
BCM2711 detected Dedicated VL805 EEPROM detected BOOTLOADER: up-to-date CURRENT: Thu 3 Sep 12:11:43 UTC 2020 (1599135103) LATEST: Thu 3 Sep 12:11:43 UTC 2020 (1599135103) FW DIR: /lib/firmware/raspberrypi/bootloader/critical VL805: up-to-date CURRENT: 000138a1 LATEST: 000138a1
You should get an output from the rpi-eeprom-update. If it says that there are any updates you can install these manually by running
sudo rpi-eeprom-update -a
Edit the Bootloader Configuration
Now we are going to verify that the rpi-eeprom -config configuration is correct by doing the following
sudo -E rpi-eeprom-config --edit
The default configuration should look similar to this
BOOT_UART=0 WAKE_ON_GPIO=1 POWER_OFF_ON_HALT=0 [all] BOOT_ORDER=0xf41
We need to confirm that our configuration files BOOT_ORDER parameter matches “BOOT_ORDER=0xf41” which is the correct and new parameter. If it has “0x1” or “0x0” (Which was set in versions prior to 3.9.20) then you will need to go back over the steps above from the beginning to make sure the bootloader gets updated.
The value we want is 0x4 USB mass storage device boot.
You can combine other values from the table above but we only recommend using either one of these two values:
BOOT_ORDER=0x4 = Boot straight to USB mass storage
BOOT_ORDER=0xf41 = (Fall back to SD card IF USB boot fails)
However all should be as expected if you have followed the guide correctly.
Now you need to exit nano editor by pressing “Ctrl + X” and then “Y” to save and doing so will also re-update the EEPROM and ask you to reboot.
Now you need to power off your Raspberry Pi.
Step 5: Install Raspberry Pi OS Lite On To The SSD
Well done you got this far. Just one more thing to do!
To finalize the process we need to write a fresh Raspberry Pi OS image onto the SSD or Flash drive.
Insert the SATA USB 3.0 adapter into the SSD and attach the USB port to your computer. Please ensure you use the blue 3.0 USB port and that no other SD cards or USB storage devices are connected.
Please follow our previous Episode how to install Raspberry Pi OS to SD card but instead of writing to the SD card, we will write to our SSD drive or flash drive instead.
Please note on Windows the SSD (if new) may not show up in “My PC” as if it has not been formatted. However, the Raspberry Pi Imager will see it fine so you don’t have to do anything else.
Once you have the Raspberry Pi OS imaged to your SSD drive please remember to add the ssh file to the boot partition so you can SSH into your new SSD powered Raspberry Pi :).
You can now safely remove the SD card from your Raspberry Pi and insert the SSD drive into your powered USB 3.0 hub or directly into your Raspberry Pi 4’s USB 3.0 port.
Power up the Raspberry Pi and you are done.
Enjoy a more stable server and operating system.
Let us know how you got on? How did you do?. Did you have any problems?
We need your support.
We hope you enjoyed this episode and that it was helpful and you got benefit out of it.
If you did, please consider supporting our channel by Subscribing to our YouTube channel, and liking and sharing our content.