Updated 2024-06-06 !
After having tested several methods creating a bootable USB SSD, or other USB drive, for Raspberry Pi(RPi) 3 4 and 5, I finished with this simple method
- Create the setup you want on a ordinary SD card(Or use existing)
- Make a bootable backup/clone of the SD card saving it to the USB SSD
- Remove the SD card and boot from the USB SSD
Having a RPi 4, 5 ? Use this post on how to write the OS direct to the SSD.
Prerequisites
The tests was made with this SSD
If You are starting from scratch with a new SD card you can
check these instructions to install the RPi OS and after that you install your selected software.
Please note !!! Before you continue you MUST update/upgrade !! to
get the latest OS/firmware
sudo apt update && sudo apt full-upgrade -y && sudo apt
clean
Check out the clone alternatives att Extra below !
Setup
Raspberry Pi 3(RPi3)
Sometimes you find excellent "how to" posts and
this one is such, explaining how to set up the RPi3 for SSD boot. Thanks
"HawaiianPi" ! (Here you also find some hints for RPi 2)
On my RPi 3, 7 years old, I had to set the OTP bit and add
program_usb_boot_mode=1
program_usb_boot_timeout=1
to "config.txt", sudo nano /boot/firmware/config.txt (Older RPi OS? => sudo nano /boot/config.txt, and reboot to make it work. (After the reboot, check if the 2 added lines are still there, otherwise delete them.)
Also please check the issue below with high CPU load due to the RPi 3 is polling the SD card !!
Raspberry Pi 4, 5
Run the command
and then select "6 Advanced options => A4 Boot order => B2 NVMe/USB Boot"
This isn't really mandatory since the RPi will check all 3 ways but selecting makes the boot quicker.
Common instructions
Copy alternatives are found at Extra, below!
Power down the RPi
sudo shutdown now
disconnect the power and remove the SD card. Connect the power again and
the RPi will boot from the USB SSD.
If you
do updates to the USB SSD I recommend to make a backup with the backup program to a SD card. Probably the boot disk will be named "sda" and the inserted, in a USB port, backup SD card will be named "sdb" so the command will be
RPi 5 boot problem
USB boot is disabled by default when connected to a 3A power supply so you must use a proper power supply, and power cord, that have at least 5 Amp capacity. Another way is to edit "config.txt", sudo nano /boot/firmware/config.txt and add "usb_max_current_enable=1" at the end of the file.
Speed test
A speed test
is made available by the RPi guys. This software can be used to compare the SD
card speed with your installed USB drive. Install with
sudo apt install agnostics
sudo sh /usr/share/agnostics/sdtest.sh
Another way is using the command (Inspire link)
dd if=/dev/zero of=./speedTestFile bs=20M count=5 oflag=direct
which will create and copy a file, speedTestFile, and report the write speed. Go on with reading the file with
dd if=./speedTestFile of=/dev/zero bs=20M count=5 oflag=dsync
and get the read speed. Then delete the file with rm speedTestFile
High CPU load on a RPi 3 ?
I detected that the CPU load on my RPi 3, booting from the SSD, was over 15 %, used the "top" command, even when the RPi 3 didn't do anything ?? Did some googling and found this which helped. In short, add "dtparam=sd_poll_once" to "/boot/config.txt"
Extra Clone alternatives- Use the standard "Accessories => CD Card Copier" found in the RPi meny. (If you don't use RPi OS lite) If not installed ? sudo apt install piclone
- After a format of the USB drive use "dd if=/dev/mmcblk0 of=/dev/sda status=progress" and after the boot, from the USB drive, expand the filesystem via "sudo raspi-config", 6, A1. Please note that this only works if the target has a bigger storage than the source and that the command will copy the whole source SD card which will take longer time than the recommended clone above.
Check out this post connecting RPi to external storage/disk
Checking USB boot bit
Use command(Not RPi 4,5)
vcgencmd otp_dump | grep 17:
The output could be 17:3020000a. If there is a 1, where the 3 is, USB boot is not enabled.
Boost read/write speed without SSD
Instead of using the standard SD card, or a SSD, you could use a USB flash card with high read speed. Just follow the instructions above as if it was an SSD.
RPi 4, 5
Info regarding Raspberry Pi boot EEPROM update is found here, but the best way is just to run
sudo apt update && sudo apt full-upgrade -y && sudo apt clean
mentioned above.
Hi, I have a rasperry pi 2. In your title it is also mentioned but after that I could see any info.
ReplyDeleteraspy2 again.. I saw that you had a link and I followed it. It says:
ReplyDeletemay also work on the Pi 2B v1.2, but not v1.1
So I checked with unlucky result.
pi@RasPi2:~ $ cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 2 Model B Rev 1.1
I think it's a silly question, but here goes:
ReplyDeleteIf I tried sucessfully attaching an SSD to a USB3.0/Sata adapter (but to my oldish rpi3) and it works and clocks at 18 MBps - is it safe to assume that the rpi3 will boot and perform at that same speed after booting from this same USB SSD ...
So the performance gain will be just around nothing.
Unless the rpi3 is replaced with a rpi4... which has USB 3.0, right?
There is no silly questions ! Logically, your reasoning seems quite right and since it's so quick to make the clone I would just test it and confirm.
DeleteDid some quick test and there are really big differences testing speed against a FAT partition or ext4. How did you test ?
Delete