Zynthian "rescue partition"

Hello

Is it possible to create a “rescue partition” to make a low level zynthian backup, that will get rid of failed updates, wrong configurations or bad shutdown procedures?

If it’s not currently possible, I was thinking of:

  1. Install Zynthian on the first half of SD card space
  2. Configure and customize it
  3. Clone the main partition on a “rescue partition” on the second half of SD card space
  4. If anything goes wrong happens, copy back the rescue partition on the main one.

As far as I know, steps 3 and 4 could only be done externally (e.g. from a separate linux machine).

What do you think about it?

Thank you

Sergio

1 Like

The idea is good, but the proposed solution is too low level for my taste.

After the last crash last week I crafted a backup procedure because a re-flash costs too much time setting everything up again.
The procedure is as follows;

First prepare a backup SD card.
To prepare the card, the easiest way is to flash the lastest Zynthian image and start it in the device so it becomes a bootable system.

(******************
The less easy way is:

  • prepare a 512Mb partition mmcblk0p1 and a partition mmcblk0p2 for the rest of the disk:
-Device         Boot   Start       End   Sectors  Size Id Type
/dev/mmcblk0p1         8192   1056767   1048576  512M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      1056768 124735487 123678720   59G 83 Linux

mount the second partition as /mnt/sda2

  • On this partition create the following directories:
sudo mkdir /mnt/sda2/proc
sudo mkdir /mnt/sda2/sys
sudo mkdir /mnt/sda2/tmp
sudo mkdir /mnt/sda2/run
sudo mkdir /mnt/sda2/mnt
sudo mkdir /mnt/sda2/boot
sudo mkdir /mnt/sda2/media

******************)

Put this prepared SD card in another linux device. This can be a RPi 3 or something else you have lying around. As long as a micro SD card fits it’s ok.
Then use rsync to copy your production system to this backup.
I use the following commands:

sudo mount /dev/sda1 /mnt/sda1
sudo mount /dev/sda2 /mnt/sda2

sudo rsync -aAXvn --exclude "/dev/*" --exclude /proc --exclude /sys --exclude /tmp --exclude /run --exclude /mnt --exclude /media --exclude /var/cache --exclude /boot --delete-after --exclude lost+found root@zynthian:/ /mnt/sda2/

sudo rsync -aAXvn --exclude /firmware --delete-after --exclude lost+found root@zynthian:/boot/ /mnt/sda2/boot/

sudo rsync -aAXvn --delete-after --exclude lost+found root@zynthian:/boot/firmware/ /mnt/sda1/

The above commands perform a dry run (they do everything except copying data).
When it looks ok, replace the rsync -aAXvn option by rsync -aAXv (remove the ‘n’) and run again. Now all data gets copied.

Take the newly created backup and test.

If it works, you have a working backup, that can be put back in case of emergency using the same procedure as before, with the corrupted disk as the target.

Well, I hope this makes some sense to you..

Kind regards,
Hans.

2 Likes

What you’re talking about are “immutable” linux distributions. Like Fedora Silberblue.

I think zynthian moves too quickly for it to be appropriate for us.

There’s an interesting article here with a useful checklist on if immutable distros are what you’re looking for. Immutable Linux Distros: Are They Right for You? Take the Test.

If you have a Pi5 inside your Zynthian, you could configure the EEPROM to alternatively boot from USB like this via
rpi-eeprom-config --edit

[all]
BOOT_UART=0
BOOT_ORDER=0xf164
NET_INSTALL_AT_POWER_ON=0
NET_INSTALL_ENABLED=0
SDRAM_BANKLOW=1
USB_MSD_DISCOVER_TIMEOUT=1000
POWER_OFF_ON_HALT=1
PSU_MAX_CURRENT=5000

Please leave out the line PSU_MAX_CURRENT=5000 if you power the Pi5 from USB-C, because this line would defeat PD negotiation and allow only 2A current draw from the Power supply.
Make a 64GB minimum USB stick with Raspberry Pi OS on it. Then boot the Zynthian from that USB stick and update, then on terminal:
apt install clonezilla
And use Clonezilla to backup or restore the MicroSD onto the stick. The good one is, Clonezilla, if set so, compersses the image and saves only allocated data blocks, making the backup or restore process much faster and more space-saving on the backup drive.
For the users manual of Clonezilla, please read at https://clonezilla.org/

1 Like

Thank you,

I have some questions on your approach:

  1. Both backup and restore procedures have to be done on a separate machine?
  2. Why do you use rsync instead of cp or scp?
  3. Why do you prefer to stay on a higher layer?

Thank you

I’d like to have a procedure to create a rollback point.

Anyeay, after a successful software update, I can update the rollback poont too.

I have a pi4, do you think it can boot from usb too?