USB Boot

Why ?

Why USB boot ? Well for a start I’m a tinkerer who just can’t leave things alone. Secondly I’ve had an SD card fail and didn’t want to go down that path again – maybe I should’ve got better cards ? And thirdly I’ve always, rightly or wrongly, regarded the SD card boot scenario a bit clumsy.

I got rid of some of the clumsiness by moving the root partition to a 1TB Toshiba X1 portable SSD. This was easily done and was a great success. I still had a bit of SD clumsiness though which I wanted to get rid of.

Then along came the announcement of USB booting and for once in my life I didn’t leap into the deep end with the first BETA. I waited until the BETA was elevated to STABLE and then leapt into the deep end.

What follows is what I did to get it working.

First steps

The first thing to do was to get my hands on another portable SSD.  This time it was a Seagate 1TB portable SSD. Not cheap but hey, you can’t let money stand in the way of a bit of tinkering, can you ?

The second thing to do was to make sure that my existing installation was completely up to date by doing “sudo apt update” followed by “sudo apt full-upgrade”. Because I hadn’t done this for a while there were about sixty packages updated. While I was at it I had a look to see what I could get rid of and removed a couple of packages that I didn’t require.

Next on the list was to update the boot loader and get it configured. That’s the bit the seemed a bit daunting at the start.

Update the bootloader

I was a bit worried about this bit but only because I had no real backout plan if it all went badly. I needn’t have worried.

First up I had a look at “/lib/firmware/raspberrypi/bootloader/” and saw that there was a “stable” directory and saw that there was “pieeprom-2020-06-15.bin” which was what I was after according to this topic on the Raspberry Pi forum.

Because I have a second Pi that USB boots 64 bit Raspbian that I set up a couple of weeks ago I had already done a lot of reading about the configuration. The story of the second Pi is here.

Anyway I’m jumping the gun a bit here. Before updating the bootloader I downloaded the latest version of Raspberry Pi OS and using the Raspberry Pi Imager I set my Seagate portable SSD up with it. While that was happening I got the bootloader updated and configured. Easily done in a few steps.

I needed a configuration so I used the one from my 64 bit Pi :-

[all]
BOOT_UART=0
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
DHCP_TIMEOUT=45000
DHCP_REQ_TIMEOUT=4000
TFTP_FILE_TIMEOUT=30000
ENABLE_SELF_UPDATE=1
DISABLE_HDMI=0
BOOT_ORDER=0xf41

I got this by doing vcgencmd bootloader_config > bootconf.txt on my 64 bit USB booting Pi. It was a simple matter to copy that to my non USB booting Pi.

Back to the 32 bit Pi and I did “rpi-eeprom-config –out pieeprom_new.bin –config bootconf.txt  /lib/firmware/raspberrypi/bootloader/stable/pieeprom-2020-06-15.bin”  which gave me a new bootloader called pieeprom_new.bin to install.

Installing the bootloader was my mental sticking point. Up to this point I had a working system with the root partition on an SSD and the /boot partition still on an SD card. Would it still boot after the new bootloader was installed ? I certainly hoped so!

Anyway I went ahead confident that I could roll it back to the old non USB booting model simply by installing the bootloader from the “critical” directory. Anyway I did a “sudo rpi-eeprom-update -d -f ./pieeprom_new.bin” followed by a reboot and it booted just fine. I did a “vcgencmd bootloader_version” and a “vcgenccmd bootloader_config” and was greeted by the new version and the new configutation. It had worked and my web server / samba / other stuff system worked as it it always did.

 

Making the new boot SSD

Now to the fun part.

Remember the SSD that I made with the latest Raspberry Pi OS ? Well now its time to shine has arrived.

I plugged it into the Pi and copied /boot/*.elf and /boot/*.dat to the boot partition of the SSD. I closed the Pi down (sudo poweroff and unplug the power) and unplugged the original SSD and the SD card leaving the new SSD plugged in. I plugged the power in and lo and behold it booted OK and I went through the whole setup process. That’s half the job done. The brand new SSD had the boot and root partitions and all was right with the world.

I powered off again and rebooted the original configuration – SD + SSD (Toshiba). The new Seagate was plugged in and I formatted the root partition “mkfs -t ext4 /dev/sdxx” and mounted the new empty, clean partition in /mnt. Then came “rsync -axv / /mnt” There’s about 700 GB in that partition so it was going to take a while so I went to bed.

One caveat here. If I plug both SSD’s into USB-3 ports it will fail at some point probably, I think, because it’s on the edge of the available power from a genuine Pi power supply. If I plug one of the SSD’s into a USB-2 port it’ll work OK so I did that which made it a lot slower.

It worked

The next morning, after a couple of cups of coffee, I had a look at what happened overnight. The “rsync” had completed without error.

At this point I needed to copy from the SD card config.txt and cmdline.txt to the new SSD so I did that. I also needed to edit cmdline.txt to make sure that the PARTUUID pointed to my new SSD. On the new SSD I needed to edit /etc/fstab to put in the new PARTUUID’s for the boot and root partitions.

At this point I was very hopeful but not certain that it would work out properly but I went ahead and powered the Pi down and removed the original SD and SSD and plugged the new SSD into a USB-3 port and plugged the power in. Success. Everything works OK. This web site works OK as does Samba and everything else.

The whole operation was a success. Apart from the “rsync” it only took about half an hour. Because of the sheer quantity of “stuff” the “rsync” was a lengthy affair.

The next step will be to update with Raspberry Pi OS 64bit when that becomes prime time. I’m sure that won’t be a simple upgrade like this ended up being.

Leave a Reply

Your email address will not be published.