Skip to content

Instantly share code, notes, and snippets.

@lucabelluccini
Last active October 13, 2023 12:38
Show Gist options
  • Save lucabelluccini/9a11c48dcf1d627bbcbd8213f6de3eae to your computer and use it in GitHub Desktop.
Save lucabelluccini/9a11c48dcf1d627bbcbd8213f6de3eae to your computer and use it in GitHub Desktop.
Raspberry Pi 4 - Boot from SD, Rootfs on USB

Raspberry 4B - Boot from SD and rootfs on USB

Update

RPi4 now supports booting directly from USB. First update to get an eeprom which supports USB Boot, then configure the bootloader to boot from USB.

Original guide

  1. Download Raspbian from the official site

  2. Flash it to the USB drive following the procedure detailed here

  3. Fomat an SD Card 2/4 GB as FAT32, label "boot", flag "lba". Generate a UUID. You can use GParted for this task.

  4. Get the UUID of the USB drive and the SD Card partitions using sudo blkid.

  5. Copy the files from the /boot/ partition of the USB drive to the SD Card using rsync -rt <source> <dest>

  6. Modify the file cmdline.txt on the SD Card ensuring:

6.1. root=PARTUUID=<UUID of the USB drive rootfs partition> is present

6.2. rootdelay=5 to give more time to the Kernel to wait for the USB device

6.3. If you're using this USB drive adapter (use lsusb):

Bus 002 Device 002: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge

The disk is slow and reports errors in dmesg like the following:

[  543.071702] sd 0:0:0:0: [sda] tag#16 uas_eh_abort_handler 0 uas-tag 7 inflight: CMD IN 
[  543.071719] sd 0:0:0:0: [sda] tag#16 CDB: opcode=0x28 28 00 00 42 80 88 00 00 08 00
[  543.111634] scsi host0: uas_eh_device_reset_handler start
[  543.262296] usb 2-1: reset SuperSpeed Gen 1 USB device number 2 using xhci_hcd
[  543.297294] scsi host0: uas_eh_device_reset_handler success
[  573.776061] sd 0:0:0:0: [sda] tag#25 uas_eh_abort_handler 0 uas-tag 11 inflight: CMD IN 
[  573.776079] sd 0:0:0:0: [sda] tag#25 CDB: opcode=0x28 28 00 00 09 d4 40 00 00 08 00

Add usb-storage.quirks=152d:0578:u (link to Github, redhat bug report).

It must be disabled via kernel flags as it is built-in (sudo modprobe configs && zcat /proc/config.gz | grep USB_UAS).

6.4. Remove the init script to resize the drive. It doesn't work as the /boot and / do not belong to the same drive.

  1. On the USB drive, edit /etc/fstab:

7.1. Comment out the /boot partition of the USB drive

7.2. Add:

PARTUUID=<UUID of the SD Card boot partition> /boot vfat defaults 0 2

Useful links:

@ciprian-radu
Copy link

Thank you, it worked for me!

Maybe you should clarify that we work with PARTUUID. (UUID is a different identifier...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment