Boot Raspberry Pi 4 From a USB SSD or Flash Drive

From CMEE4K
Jump to navigation Jump to search

From https://www.tomshardware.com/how-to/boot-raspberry-pi-4-usb
We are using RPi (32-bit) 2021-05-07 image to prepare these steps on RPi 4b (4G RAM). The raps-config boot options are moved into Advanced options.

Steps

  • BOOT UP from microSD card (RPi OS).
    • sudo apt update
    • sudo apt full-upgrade
    • sudo rpi-update
  • REBOOT
    • sudo rpi-eeprom-update -d -a

  • REBOOT
    • sudo rasps-config
      • Select Boot Options and Enter
        • (Note: in the 2021-May version, this options moved to Advanced options.)
      • Select Boot ROM Version, and Enter
      • Select Latest, then Ok
      • Select No to use the latest boot ROM.
        • This will trigger the Raspberry Pi to complete a series of behind the scenes configuration steps.
        • Press Ok to close the next dialog.
      • Select Boot Order and Enter
      • Select USB Boot and click Ok.
        • Note: 2021-May version has 3 choice. We still select USB Boot option.
        • Note that if there is a bootable micro SD card inserted, the Raspberry Pi will boot using that.
        • Press Ok to close the next dialog.
      • Select Finish. When asked to reboot select No.
    • raspi-config program exit. (For 2021-May version)
      • It shows the firmware is set to VL805.
      • EERPOM updates pending. Please reboot to apply the update.
      • To cancel a pending update, run sudo rpi-eeprom-update -r.

  • Launch SD Card Copier program.
    • Plug-in SSD or Flash drive to USB 3 port.
    • Select the Copy from Device is micro SD card.
    • Select the Copy to Device is SSD.
    • Click Start. It takes ~10 min to copy the device.
  • Shut down RPi
  • Remove microSD card
  • Power up RPi, it will boot from USB SSD or Flash drive.



Performance: SD card speed test

https://www.raspberrypi.org/blog/sd-card-speed-test/

  • sudo apt update
  • sudo apt install agnostics
  • Run Raspberry Pi Diagnostics

SanDisk 256G SSD

Using no power USB 3 to SATA cable; and then use HDD Docking station with 12V power supply

Raspberry Pi Diagnostics - version 0.9
Sat Jun 19 16:41:37 2021
prepare-file;     0; 0;  254,015;    496   ==>   316,599;    618
seq-write;        0; 0;  182,551;    356   ==>   186,181;    363
rand-4k-write;    0; 0;   52,054; 13,013   ==>    43,866; 10,966
rand-4k-read;   63,503;   15,875;   0; 0   ==>    48,834; 12,208;  0, 0
Sequential write speed 182,551 KB/sec (target 10000) ==>  186,181
Random write speed      13,013 IOPS (target 500)     ==>   10,966
Random read speed       15,875 IOPS (target 1500)    ==>   12,208

SanDisk Ultra 64GXC 1 microSD Card

Raspberry Pi Diagnostics - version 0.9
Sat Jun 19 16:57:00 2021
prepare-file;      0; 0;   29,547;    57
seq-write;         0; 0;   30,200;    58
rand-4k-write;     0; 0;    3,405;   851 
rand-4k-read;    10,028;    2,507;    0;  0
Sequential write speed    30,200 KB/sec (target 10000)
Random write speed           851 IOPS (target 500)
Random read speed          2,507 IOPS (target 1500)

What does it means

No idea how to interrupt these number. SSD has higher numbers than SD card. In general, SSD should have better performance than SD card. However, we found

  1. SSD without power, everything is slow.
  2. Ultra microSD card runs (feel like) almost twice faster than SSD.
  3. SSD with power, it running a little bit faster than microSD card.



Mount USB drive on RPi

https://raspberrytips.com/format-mount-usb-drive/

  • Main menu > Preferences > Add / Remove software
    • Search gparted and install.
  • System tools > GParted
  • Use GParted or sudo fdisk /dev/sd# to remove and create partition
  • Use sudo fdisk -l to list disk and partition names.
    • Get the partition name
  • Format the partition
    • sudo mkfs.ext4 /dev/sda# where sda is an example, # is partition number.
  • Mount the USB Drive
    • Use sudo fdisk -l to see the disks
    • sudo mkdir /opt/apps
    • sudo mount /dev/sda# /opt/apps
      • sudo umount /opt/apps
    • sudo blkid to see the PARTUUID
  • Automatic mount on boot
    • Edit /etc/fstab file
    • Wrong & remove: Add line PARTUUID=xxxxxx /opt/apps ext4 defaults,umask=000 0 0
      • Note: umask=000 is for FAT, NTFS fileysystem
    • Add line PARTUUID=xxxxxx /opt/apps ext4 defaults,auto 0 0
  • Save and Exit. Reboot


No work? May be not

  • After fstab add new mount point to /opt/apps, RPi OS cannot boot.
  • Reverse the process by cloning microSD card to SSD drive again.
  • The extra SATA drive will auto be mounted as /media/pi/XXX where XXX is partition Label.
    • Look like the external SATA drive must mount as /media/pi/....
  • After I change fstab above line to defaults,auto, RPi can boot up.


External storage: https://www.raspberrypi.org/documentation/configuration/external-storage.md




Note: Split and move Turn RPi into a NAS section to another page.