Boot Pi OS from USB
Raspberry Pi OS boot and install from USB SSD / MSD
This is on a Raspberry Pi 4 (8GB) board. I have a USB enclosure with a NVMe SSD. It would be great to boot from it instead of a small microSD card. I also plan to install multiple OS's on it though only installed Pi OS only right now. Here is how to boot from USB massive storage device (MSD).
Boot from USB SSD / MSD
This is not hard and slightly different with the new Pi 4 board. Just need to follow this excellent guide on Tomshardware, in the exact way to ensure easy success.
First the first, I still need a Pi OS installed and running from NOOBS or even better, the plain image. We need to update the firmware under it. And the plain image is needed anyways.
Once you get the latest plain Pi OS image. You can use Raspberry Pi Imager to put it on a SD card. Maybe it can write to your USB SSD directly. I didn't try. You can pick either of the plain Pi OS image, just don't get the NOOBS image. Lite image is smallest, desktop image is medium and can still be put on a 4GB SD card (the size doesn't matter if you know how to write it to USB SSD directly), and the full image takes double the time to download. I don't see the Pi Imager saves the image file anywhere. So I prefer to download manually.
Another reason to keep the image file is I already installed the OS on NOOBS microSD card come with the kit I bought. And I found it is more handy to do it on Pi OS than a PC with Windows. wget downloaded the image much faster than web browser on Windows. It is also easy to use command line to burn the image:
lsblk # it shows the device for your USB SSD, such as /dev/sdb unzip 2020-05-27-raspios-buster-armhf.zip sudo dd if=2020-05-27-raspios-buster-armhf.img of=/dev/sdb bs=4M conv=fsync
Of course you can use piped command and don't need to keep the .img file on disk:
sudo bash #~ unzip -p 2020-05-27-raspios-buster-armhf.zip | dd of=/dev/sdb bs=4M conv=fsync
After the image is copied, two partitions will be created on the SSD and could be mounted automatically under:
We need to download the .dat and .elf files from firmware release from May 22 or later and copy them to the
/media/pi/boot directory. Otherwise it will hit error saying newer software is needed when booting up. You can use wget to download from the raw link to the files. Totally 16 files with similar names. It is easy to reuse the wget command line while slightly change the file name.
I tried the .dat/.elf files from date 06-10 and 06-19. They both work fine. These files in boot folder are explained here: https://www.raspberrypi.org/documentation/configuration/boot_folder.md
Then update the firmware to the version dated 2020-05-15 following the Tomshardware guide. Newer firmware normally works too. The 06-15 one is what I am using. It is also the latest stable one now.
sudo apt update sudo apt full-upgrade sudo nano /etc/default/rpi-eeprom-update # Change it to "stable" and save. FIRMWARE_RELEASE_STATUS="stable" sudo rpi-eeprom-update -d -f /lib/firmware/raspberrypi/bootloader/beta/pieeprom-2020-06-15.bin # Reboot and confirm firmware version shutdown -r 0 vcgencmd bootloader_version # Shutdown to remove microSD card halt
Now you can shutdown, power off, remove the microSD card and boot to USB SSD. Once boots up, it will resize the ext4 partition to cover the whole SSD. You then go through the short setup steps and update process of several minutes to get the OS finally running. You can get more applications to make it same as the full Pi OS image.
Boot BerryBoot from USB, yet to be able to install multiple OS from USB
BerryBoot V2.0 is a great tool for this. It boots up kernel and a tiny system running the app to let you install multiple OS. Just need one little tweak to let it boot from USB SSD. But it still has issues to prepare partitions for OS installation in such setup. We have to wait till it is updated to address this.
Create a small fat32 partition as the first partition on your USB drive.
Get the current berryboot-20200612-pi4.zip. Unzip it onto the fat32 partition you created before.
Now the trick:
~$ blkid /dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="70A2-8001" TYPE="vfat" PARTUUID="b9061a63-01"
Modify the cmdline.txt in the boot partition, add bootdev= with the UUID above so it is like:
bootdev=UUID=70A2-8001 elevator=deadline quiet bootmenutimeout=10
or use the device directly:
bootdev=/dev/sda1 elevator=deadline quiet bootmenutimeout=10
Flush the latest stable firmware that enables USB boot as above. Once it is done, run
sudo halt, turn off power, take out microSD card, keep USB drive plugged, and power on. It should boot up correctly and start Berryboot tool now.
Try to boot PINN
PINN is another great tool, very similar.
PINN shows USB boot support in the changelog. I got the zip file, unzip it to the fat32 partition on SSD, but it can't boot from USB SSD. I only see the rainbow square screen. Some people reported successful boot though.
From the files in PINN I see it is using recovery style image. BerryBoot is using OS image. Theoretically they should both be able to work if crafted to load kernel and initrd ramdisk image correctly from the boot device. Maybe something is still not right.
I also tried the NOOBS image. The first partition is for recovery and the recovery image failed to load. It complains about missing fixup4rc.dat which doesn't exist. So we can settle with the plain Pi OS image for now.