Raspberry pi 4 boot from USB

Posted under » Raspberry Pi on 30 Apr 2022

Your Pi doesn't have a hardisk and soon your SD card will run out space. Adding a thumbdrive or a USB drive is a solution. However I prefer the latter because thumbdrives tend to corrupt after a while especially under heavy usage. Now that we have SSD, it will improve the performance significantly.

Normally, the hardisk is mounted on /mnt or /media but you may want to add the USB disk automatically using fstab under a folder that you specify, eg. /usbdrive. Use 'df -H' in conjunction with 'lsblk -f' to know the name of your USB drive

You will see the hard disk name and his location. Something like /dev/sda1 before it. Now you can add to your fstab at /etc/fstab.

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
/dev/sda1       /usbdrive       ext2    defaults          0       0

Now make a new folder "/usbdrive" on your pi. Restart and your done. However, mounting a disk is not enough. We want to boot from USB.

For this you need to update the firmware and you can only do this from Raspberry OS.

As SUDO run terminal or connect through SSH

$ apt update
$ sudo apt full-upgrade
$ vim /etc/default/rpi-eeprom-update

The default value of the FIRMWARE_RELEASE_STATUS parameter is “critical,” if pi3 which must be changed to “stable”. In Pi4 it is "default".

$ rpi-eeprom-update
*** UPDATE AVAILABLE ***
BOOTLOADER: update available
   CURRENT: Tue 16 Feb 13:23:36 UTC 2021 (1613481816)
    LATEST: Thu 29 Apr 16:11:25 UTC 2021 (1619712685)
   RELEASE: default (/lib/firmware/raspberrypi/bootloader/default)
            Use raspi-config to change the release.

  VL805_FW: Using bootloader EEPROM
     VL805: up to date
   CURRENT: 000138a1
    LATEST: 000138a1

Force update if update is available.

$ rpi-eeprom-update -a

Verify whether the update was successful by typing the following command in the terminal.

$ vcgencmd bootloader_version
$ vcgencmd bootloader_config

You can configure that your USB drive will boot first or boot if there is no SD card. It is under `Advanced Options'. Once you do this, go to

$ vcgencmd bootloader_config

It will show the boot order. Look for the last row of the result which should be 'BOOT_ORDER=0xf41'. This is important!

You then have to prepare your USB SSD with the OS of your choice.. eg. mine is Ubuntu Server or good ol Raspberry OS.

It is best that you use the imager that is on the Raspberry Pi OS instead of the windows Raspberry Pi Imager.

If you are using Raspberry Pi OS and your SD card is working very well and configured to the way you want, then I recommend you use the 'SD card copier' that is under the 'accessories' menu, It will make the exact partition including the boot partition.

If your SD card is 32GB and your SSD card is 300GB, you can raspi config to the largest partition that is available on the SSD after boot.

Once the OS image is flashed to your SSD, plug the SSD/USB to your Raspberry Pi 4.

Only after you have done all the above especially the BOOT_ORDER=0xf41 bit, remove your SDcard and reboot. You will now be able to boot your Raspberry Pi 4 from your USB with the OS of your choice.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS