Recipe for booting Venus OS on RasPi4 from USB/SSD

When I started with Venus OS on a Raspberry 4 two years ago, I soon experienced a lot of trouble with write errors on the SD card (even if this was a “high quality” device). I figured out how to boot from an SSD attached via USB to work around this issue, but never got the time to write down all the required steps. But now’s the time. Here we go, short version first:

  • Copy the kernel image from /boot to /u-boot
  • Adjust /u-boot/config.txt
  • Adjust /u-boot/cmdline.txt
  • Adjust /etc/fstab

And now for the loooong version:

The following works for RasPi4 only (afaik)!
And please note all software updates from the GUI do not work any more.
You should thus disable automatic updates!

  • Copy a Venus OS image to an SD card and boot the RasPi from it
  • Enable ssh on LAN
  • Set a root password
  • Login via ssh
  • Attach an empty (!) SSD via USB
  • Create partitions on the SSD:
parted /dev/sda -ms mklabel msdos mkpart primary fat16 2048s 50MB set 1 boot on \
set 1 lba on mkpart primary ext4 50MB 33% mkpart primary ext4 33% 66% mkpart primary ext4 66% 100%
  • Create file systems on the partitions:

mkfs.ext4 -F /dev/sda2
mkfs.ext4 -F /dev/sda3
mkfs.ext4 -F /dev/sda4

  • Unmount the U-Boot partition:

umount /u-boot/

  • Repeat the command above until an error occurs to make sure the device is actually unmounted
  • Copy the U-Boot partition to the SSD:

dd bs=32M if=/dev/mmcblk0p1 of=/dev/sda1; sync

  • Mount the U-Boot partition from the SSD:

mount /dev/sda1 /mnt

  • Copy the kernel to the U-Boot partition (adjust the file name if required):

cp /boot/zImage-5.10.110 /mnt

  • Change the image booted by U-Boot to the kernel copied above

sed -i.bak -e 's/=u-boot.bin/=zImage-5.10.110/' /mnt/config.txt

  • Enable boot from USB:

echo -e '\n# turn on boot from USB\nprogram_usb_boot_mode=1' >> /mnt/config.txt

  • Get the partition UUID of the SSD root partition (write down the output of the following):

ls -l /dev/disk/by-partuuid | fgrep sda | egrep -o '[0-9a-f]+-02'

  • Change the kernel command line (replace YOURUUID by what you got above):

echo 'dwc_otg.lpm_enable=0 console=serial0,115200 root=PARTUUID=YOURUUID rootfstype=ext4 fsck.repair=yes rootwait' > /mnt/cmdline.txt

  • Unmount the U-Boot partition:

umount /mnt

  • Copy the root and data partitions (the SSD partitions get
    mounted automatically by Venus OS; may take some minutes):

tar cfC - / --one-file-system . | tar xfC - /run/media/sda2
tar cfC - /data . | tar xfC - /run/media/sda4

  • Adjust /etc/fstab:

sed -i.bak -e 's/mmcblk0p/sda/' /run/media/sda2/etc/fstab

  • Unmount the SSD partititions:
umount /dev/sda2
umount /dev/sda3
umount -l /dev/sda4
  • Power down the RasPi:

poweroff

  • Disconnect power from the RasPi and remove the SD card
  • Reconnect power

Et voilà!

Hi.

Looks promising, but if the updates will not work anymore, this procedure is somehow “useless”. We need updates, making this procedure for each update is unpleasant.

Maybe you’ll find a way to allow updates on the device. I found it, and it is working .. even if it is manual, but at least I don’t lose data. :blush:

Cheers

If you found it, would you beso kind to let us know how?

Thank you

Here it is @wolferl

EDIT:
Look here the picture showing the devices working :blush:

thank you

This procedure works for 3.75. Note, there is a typo in the command ls -l /dev/disk/by-partuuid | fgrep sda | egrep -o ‘[0-9a-f]±02’it should be ls -l /dev/disk/by-partuuid | fgrep sda | egrep -o '[0-9a-f]{8}-02'Also note the straight block quotes, vs the smart quotes in this command and others in the guide.

Yep, that was garbled by the forum editor. I tried to fix it in my posting above. It was meant to be +-. Thanks for the heads-up!

I’ve been running this recipe for a while and it works nicely, but the line in the first post about GUI updates not working any more always bothered me. Sitting on a frozen firmware version felt wrong, so at some point I sat down and worked out what actually breaks. Turns out it’s fixable, and my Pi has been doing normal GUI updates ever since. Last one went from v3.80~39 to v3.80~42 while I watched the log, two reboots, no hands on keyboard.

The core issue is that swupdate writes to /dev/mmcblk0p2 or p3, hardcoded. There is no such device when you boot off an SSD, so nothing lands where it should.

What made this genuinely nasty for me: I still had an SD card in the slot as a rescue system. So mmcblk0 did exist, and swupdate cheerfully flashed the update onto the SD card while I kept booting the old firmware from the SSD. The GUI said the update succeeded. Version number unchanged. I spent an evening on that one before it clicked.

Fixing the write target is only half of it though. The image lands in the inactive root slot, but that slot comes with a stock fstab, a stock fw_env.config, and boot
settings that all still say mmcblk0. Reboot into it and the Pi comes up… sort of. It answers ping. Every port is closed, including SSH. Took me a while to understand that this isn’t a dead Pi at all, it’s /data failing to mount, and since the SSH host keys live on /data, dropbear never starts. Looks identical to a brick from the outside.

So what I ended up with is three pieces, all sitting on /data so they survive updates:

A wrapper that replaces check-updates.sh. It sets up the mmcblk0 to sda symlinks before handing over to the original script (which I keep untouched as .orig). It also refuses to do anything if it detects a real SD card, which would have saved me that evening. Since both the GUI button and the nightly auto-update go through this one file, wrapping it covers everything.

A patcher that runs after swupdate and fixes the new slot before the Pi boots into it: fw_env.config, fstab, cmdline.txt, that sort of thing.

And a handful of hooks in rcS.local that put it all back after every update, because /etc is gone with each new slot.

One design detail I want to call out because it saved me twice: the patcher does the boot switch absolutely last. Everything else is patched first, and only then does cmdline.txt get changed. If the script dies anywhere before that, the old working slot just keeps booting and you can log in and look at what happened. I originally had it the other way round and got exactly one half-patched slot out of it, plus a recovery session with the SSD unplugged and a rescue SD card.

Everything is here, with a README and installation notes:

Honestly the file I’d read first is PITFALLS.md. It’s the list of things that went wrong on the way, and some of them are not obvious at all. The one that hurt most: don’t ever run fsck on a slot that swupdate just wrote. The image is already verified, and fsck rebuilds the journal and orphans the lot. 59,745 files into lost+found, in one command. If a slot really is broken, just write the image again, it overwrites completely anyway.

One thing I’d add rather than contradict in the original post: telling people to disable automatic updates is the correct advice as long as the boot path isn’t sorted. An unattended update on a stock SSD setup will write to the wrong place or leave you half-patched at three in the morning. I only turned mine back on after the wrapper was in and I’d done a manual update and read through the logs.

Usual disclaimer, this pokes at the boot path and it’s not a Victron-sanctioned setup. Keep a spare SD card with a plain Venus image somewhere. Pull the SSD, the Pi boots off it, and you can hot-plug the SSD back in to repair things. That’s how I got out of trouble both times.

Happy to answer questions if anyone tries it.