Update 20190624: Today I ran “pacman -Suy” and ended up with a system that does not start. Two blinking green leds indicate failure to read the SD card. That is less than 5 months after I used SD-card for only /boot. I really consider not running RPi as headless servers anymore.
I have found that one of the weakest parts of a Raspberry Pi server or workstation is the SD card: it is slow and it will break sooner rather than later. There may be industrial SD cards or better SD cards, but a good old USB hard drive is just better.
With RPi v3 it shall be possible to boot straight off a USB drive! That sounded great so I got a brand new RPi v3 B+, a USB hard drive, and I installed ArchLinux on the hard drive, just as if it was a memory card. Fail. That did not work (with ArchLinux, Raspbian may be another story).
But there are levels of pain:
- All SD-card
- SD-card, but /home on USB harddrive
- USB harddrive, but /boot on SD-card
- All USB harddrive
I decided to try #3.
It turns out that when the RPi boots it runs u-boot (its like the BIOS of RPi, and many other embedded devices). At one point u-boot reads boot.scr (from the first VFAT partition of the SD card). It had the lines:
part uuid ${devtype} ${devnum}:2 uuid
setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=${uuid} rw rootwait smsc95xx.macaddr="${usbethaddr}"
I figured that I could do this instead:
# part uuid ${devtype} ${devnum}:2 uuid
setenv bootargs console=ttyS1,115200 console=tty0 root=/dev/sda2 rw rootwait smsc95xx.macaddr="${usbethaddr}"
However, boot.scr has a checksum so you cant just edit it. But it tells you what to do: run ./mkscr. But it is dependent on mkimage, so the procedure is:
- Install uboot tools
- ARCH: pacman -S uboot-tools
- Ubuntu/Debian: apt-get install u-boot-tools
- Edit boot.txt (not boot.scr) to your liking
- Run: ./mkscr
Now only /boot is on SD-card. That is quite ok with me. There is very little I/O to boot so the SD-card should survive. If I want to I can make a regular simple backup by simple file copy of /boot to a zip-file or something, and just restore that zip-file to any SD-card.
There seems to be no need to edit anything else (like fstab).
Well, the bad thing is it did not work out 100% as I hoped. The good thing is that this should work with any RPi, not just the RPi v3 that supports USB boot.
0 Comments.