Categories
HowTos Journal Linux

USB Boot Ubuntu 20.4.3 LTS on Raspberry Pi 4 FROM SSD

Introduction

I have been using my raspberry pi 4 to monitor my network and my Synology NAS. So far, I’ve been using a SanDisk MicroSD card for storing all the data which died (remember: MicroSD cards have a limited number of writes)

After doing some research I learned that the Raspberry Pi 4 gained direct boot capabilities from USB Mass Storage (aka SSDs) with a bootloader (eeprom) update in 2020.

I struggled for about 2 nights to make it work despite following various how-tos/tutorials. The method outlined here is what worked for me as of 2021-10-23. It could change in the future. With new updates to the ubuntu image those steps might not be necessary anymore.

Preparation – Upgrade bootloader

The easiest way to upgrade the bootloader on the raspberry pi is to use the raspi-config tool built into the raspian os image. Therefore first write the Raspian OS image to an MicroSD Card to make use of raspi-config. Afterwards, write the Ubuntu Image to the MicroSD card You can use the raspberry image writer. Flash the image to a MicroSD card

Raspberry Image Writer: Choose Raspberry PI OS Lite (32-bit)

Boot the raspberry pi with raspian os, login with the default credentials and run

sudo raspi-config

raspi-config main screen
raspi-config

Choose Advanced Options –> Bootloader Version –> Latest

Select No when asked to restore Default Settings

Exit and Select Yes when asked to reboot

On Reboot the bootloader should be upgraded.

Check in the Terminal that the upgrade was applied

pi@raspberrypi:~ $ sudo rpi-eeprom-update
BOOTLOADER: up to date
   CURRENT: Tue Jul  6 10:44:53 UTC 2021 (1625568293)
    LATEST: Tue Jul  6 10:44:53 UTC 2021 (1625568293)
   RELEASE: stable (/lib/firmware/raspberrypi/bootloader/stable)
            Use raspi-config to change the release.

  VL805_FW: Dedicated VL805 EEPROM
     VL805: up to date
   CURRENT: 000138a1
    LATEST: 000138a1

Use raspi-config to set the boot-order to USB-Boot by default

Choose: 6 Advanced Options

raspi-config, go to Advanced Options

Next choose: A6: Boot Order

Choose A6 Boot Order to set boot priority

Choose B2 USB Boot

B2 USB Boot

Check in the in the terminal that bootloader order has been modified. Confirm BOOT_ORDER statement is there.

pi@raspberrypi:~ $ sudo vcgencmd bootloader_config
[all]
BOOT_UART=0
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0

[all]
BOOT_ORDER=0xf14
pi@raspberrypi:~ $ 

Write Ubuntu to MicroSD Card

TBD

Clone MicroSD card to USB-SSD

To Clone the content of the MicroSD card to the USB-SSD I used rpi-clone script

Install rpi-clone

$ git clone https://github.com/billw2/rpi-clone.git 
$ cd rpi-clone
$ sudo cp rpi-clone rpi-clone-setup /usr/local/sbin

Check with fdisk -l or lsblk SDD device name (e.g. sda or sdb etc.)

Clone the content of the MicroSD card to USB-SSD

pi@rpi0: $ sudo rpi-clone sdb

Booted disk: mmcblk0 16.0GB                Destination disk: sdb 8.0GB
---------------------------------------------------------------------------
Part      Size    FS     Label           Part   Size    FS     Label
1 /boot   58.4MB  fat16  --              1       8.0GB  fat32  --
2 root    16.0GB  ext4   SD-RPI-s1                               
---------------------------------------------------------------------------
== Initialize: IMAGE mmcblk0 partition table to sdb - FS types mismatch ==
1 /boot     (22.5MB used)    : IMAGE     to sdb1  FSCK
2 root      (6.0GB used)     : RESIZE(8.0GB) MKFS SYNC to sdb2
---------------------------------------------------------------------------
Run setup script       : no
Verbose mode           : no
-----------------------:
** WARNING **          : All destination disk sdb data will be overwritten!
                       : The partition structure will be imaged from mmcblk0.
-----------------------:

Initialize and clone to the destination disk sdb?  (yes/no): yes
Optional destination rootfs /dev/sdb2 label (16 chars max): SD-RPI-8a
... 

Update config.txt to enable booting from USB SSD

Mount the system-boot partition on the SSD drive in order to change config.txt

sudo mkdir /mnt/ssdboot
sudo mount /dev/sdb1 /mnt/ssdboot
cd /mnt/ssdboot

Add kernel=vmlinux & initramfs initrd.img followkernel in the [all] section. Leave the rest the way it was before.

[all]
arm_64bit=1
device_tree_address=0x03000000
kernel=vmlinux
initramfs initrd.img followkernel

Boot From USB-SSD

Shutdown the Raspberry PI, unplug the MicroSD Card and plug-in the power again to boot from USB SSD.

If it can’t find the bootloader the raspberry pi will default to PXE boot. In case the raspberry pi is unable to boot from the USB SSD try another USB – Port (e.g. USB 2 instead of 3 etc.)

A list of compatible / tested SSDs can be found here.

Sources

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.