0

I have a few old rpi 3b+ still running stretch which i would like to upgrade to either bullseye or buster. They are all remote and i access them via AnyDesk or reverse ssh tunnels as a backup.

I have attempted to simply upgrade into buster/bullseye on a rpi at home, with the same setup as these remote ones. My hope was that i would upgrade, then reverse ssh or AnyDesk into it after the upgrade, but they never managed to upgrade properly (attempted about 6 tiems with multiple variations and always failed for one reason or another). I can't risk not being able to remote login, so i'm looking at other options.

Ideally here is what i'd like to do:

  1. Remote log into my rpi.
  2. Download a pre-configured image of buster/bullseye (with all the things i need, Anydesk etc..).
  3. Reboot the rpi into the newly downloaded OS image.

I've looked into using some multiboot tools, but they generally need you to do all the setup on a separate SD ard / USB etc. I need to be able to perform all these remotely via AnyDesk or ssh, and on the SD card that contains the currently running OS.

Anyone able to give me some pointers?

1 Answers1

1

Download a pre-configured image of buster/bullseye (with all the things i need, Anydesk etc..); Reboot the rpi into the newly downloaded OS image.

That's a relatively common requirement for embedded devices; now, would you be setting up these for the first time, you might do rather "enterprise-y" solutions like mender to allow for such remote updates, with robust fallback and so on.

But I gather that's not what we're doing. We've got these RPis out in the field, the OS that doesn't come with a robust over-the-wire update functional is still running, so we need to deal with that and can be smart later.

Here's how I'd approach this:

From the running debian stretch:

  1. Shrink the root partition (if classical partitioning is used, and not LVM), or if existent, disable the swap partition
  2. add a new partition (or if LVM is used, add a new LVM volume) if not using the swap partition
  3. download a compressed bootable upgrader system image (this might simply be the debian netinstaller with an installer preseed, or something more advanced like FAI), and uncompress it into the newly created partition or the former swap. Alternatively, if there is enough space, just download your new target system!
  4. configure your bootloader to boot from the new system next boot
  5. reboot

if rebooting into the new image worked, you can log into that system and make the bootloader changes permanent. If not, you would be thrown back to the old image.

Now, I must admit I don't know which bootloader you're using – and that's the "hard part" here.

  • Thank you. Exactly what i was hoping. For point 3, i ahve plenty of space on the SD card and will be bale to re-size the root partition of current OS, to ahve plenty of free space for a full image of the new OS (i'll ahve somesthigns etup which will allow me to remtoe login after). Point 4. is where i will struggle and where i need to research and see what/how to do. – LecauseAndThePi Sep 15 '23 at 14:01
  • first step is probably figuring out what bootloader your debian uses; I don't have an RPi at hand, otherwise I'd just try installing a fresh stretch and see what it does; maybe it just puts a small EFI shim start.elf on the SD card, maybe the start.elf is a GRUB, syslinux or uboot, I honestly don't know. Maybe soemthing else alltogether! – Marcus Müller Sep 15 '23 at 14:12
  • https://www.raspberrypi.com/documentation/computers/config_txt.html#what-is-config-txt maybe what you're looking for – Marcus Müller Sep 15 '23 at 14:15
  • Thanks again. It looks like i need to edit that autoboot.txt file and specify which partition to boot from.

    Any chance you have some usefule info form pioints 1&2? struggling to find some solution that can be done remotely, while the OS is running...

    – LecauseAndThePi Sep 15 '23 at 14:26
  • depends on the file system on your root partition, but if it's ext2/3/4 or similar, you can shrink the file system while in operation using resize2fs, then reduce the partition size accordingly (gparted). Set up your reference partition locally, run fstrim on it, then just take the SD card from your local installation, use zstd -T0 -15 < /dev/sdd3 > partitionimage.zstd (assuming /dev/sdd3 is that partition you want to ship to your remote RPi) to make a compressed device image. Copy that over to your target Rpi and uncompress it on the fly: – Marcus Müller Sep 15 '23 at 14:57
  • ssh root@targetrpi zstd -d -o /dev/sdxx < partitionimage.zstd, where /dev/sdxx is the partition you plan to overwrite with the image. (You might need to install zstd on your local machine and the remote Rpi first, but it's a fast decompressor and even in the relatively high 15 compression setting a reasonably fast compressor, so a good choice for this problem) – Marcus Müller Sep 15 '23 at 14:57