Difference between revisions of "Boot Pi OS from USB"

From eLinux.org
Jump to: navigation, search
(Raspberry Pi OS boot and install from USB SSD / MSD)
(Raspberry Pi OS boot and install from USB SSD / MSD)
 
(7 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
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.
 
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 [https://www.raspberrypi.org/downloads/raspberry-pi-os/ the latest plain Pi OS image]. You can use [https://www.raspberrypi.org/downloads/ 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.
+
Then while you are running the OS on microSD, update the bootloader 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.
 
 
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:
 
 
 
<pre>lsblk # it shows the device for your USB SSD, such as /dev/sdb
 
sudo dd if=2018-11-13-raspbian-stretch-lite.img of=/dev/sdb bs=4M conv=fsync</pre>
 
 
 
After the image is copied, two partitions will be created on the SSD and could be mounted automatically under:
 
 
 
<pre>/media/pi/boot
 
/media/pi/rootfs</pre>
 
 
 
We need to download the .dat and .elf files from [https://github.com/raspberrypi/firmware/tree/a6c9b6b48ce86ef2527586a50760d52f1b33f642 firmware release from May 22] or later and copy them to the <code>/media/pi/boot</code> 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 [https://github.com/raspberrypi/firmware/commit/cb2b95d73e9f0b1ebf05e03bb1959603d982feeb#diff-881cc4157ed641a365a86452f27ed745 from date 06-10] and [https://github.com/raspberrypi/firmware/commit/9d4f640625529b104303a31482f5ccbd2d8da51b#diff-881cc4157ed641a365a86452f27ed745 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.
 
  
 
<pre>sudo apt update
 
<pre>sudo apt update
Line 39: Line 23:
 
vcgencmd bootloader_version
 
vcgencmd bootloader_version
  
# Shutdown to remove microSD card
+
# reboot to use the new bootloader.
halt</pre>
+
reboot</pre>
 +
 
 +
Now to get ready we need to download the .dat and .elf files from [https://github.com/raspberrypi/firmware/tree/a6c9b6b48ce86ef2527586a50760d52f1b33f642 firmware release from May 22] or later and copy them to the <code>/media/pi/boot</code> 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 [https://github.com/raspberrypi/firmware/commit/cb2b95d73e9f0b1ebf05e03bb1959603d982feeb#diff-881cc4157ed641a365a86452f27ed745 from date 06-10] and [https://github.com/raspberrypi/firmware/commit/9d4f640625529b104303a31482f5ccbd2d8da51b#diff-881cc4157ed641a365a86452f27ed745 06-19]. They both work fine. These files in boot folder are explained here: https://www.raspberrypi.org/documentation/configuration/boot_folder.md
 +
 
 +
Then you get [https://www.raspberrypi.org/downloads/raspberry-pi-os/ the latest plain Pi OS image]. You can use [https://www.raspberrypi.org/downloads/ 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:
 +
 
 +
'''# Warning: this dd command erases the content on entire USB drive'''
 +
<pre>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</pre>
 +
 
 +
Of course you can use piped command and don't need to keep the .img file on disk:
 +
 
 +
'''# Warning: this dd command erases the content on entire USB drive'''
 +
<pre>sudo bash
 +
~# unzip -p 2020-05-27-raspios-buster-armhf.zip | dd of=/dev/sdb bs=4M conv=fsync
 +
</pre>
 +
 
 +
After the image is copied, two partitions will be created on the SSD and could be mounted automatically under:
 +
 
 +
<pre>/media/pi/boot
 +
/media/pi/rootfs</pre>
 +
 
 +
Now it is time to copy the .elf/.dat firmware files to <pre>/media/pi/boot</pre>.
  
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.
+
Then you can shutdown by running the command
 +
<pre>halt</pre>
 +
and 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.
  
 
<h3>Boot BerryBoot from USB, yet to be able to install multiple OS from USB</h3>
 
<h3>Boot BerryBoot from USB, yet to be able to install multiple OS from USB</h3>

Latest revision as of 17:03, 24 June 2020

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.

Then while you are running the OS on microSD, update the bootloader 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

# reboot to use the new bootloader.
reboot

Now to get ready 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 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:

# Warning: this dd command erases the content on entire USB drive

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:

# Warning: this dd command erases the content on entire USB drive

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:

/media/pi/boot
/media/pi/rootfs

Now it is time to copy the .elf/.dat firmware files to

/media/pi/boot

.

Then you can shutdown by running the command

halt

and 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.