Sysupgrade Behaviour for ext4 Combined

Hi folks,

I'm just going through a process of trying to make the way I upgrade my x86 more failsafe, using a second partition, so my disk layout is currently:

Device     Boot    Start       End   Sectors Size Id Type
/dev/sda1  *         512     33279     32768  16M 83 Linux
/dev/sda2          33792   2130943   2097152   1G 83 Linux
/dev/sda3       4229120 6326271 2097152   1G 83 Linux

With sda2 being the active running version and sda3 being the new partition to use as the secondary partition for the upgrade. My images are built using ImageBuilder for a 1024MB RootFS.

EDITED - My original method was flawed. See below for what I actually did.

OK. I realised that the original method was a ridiculous plan as DDing active filesystems was only going to end in tears. The reason for wanting to do it this way was to ensure the backup config was applied before booting into the new image as I have non-standard network config which would render the router inaccessible if it failed.

Here is what I ended up doing:

  1. Make the new upgrade images using image builder (to the correct RootFS size).
  2. SCP transfer openwrt-23.05.0-x86-64-generic-ext4-rootfs.img.gz and openwrt-23.05.0-x86-64-generic-kernel.bin to the active OpenWRT host into /tmp
  3. Gunzip the RootFS img and DD the file to the 'Secondary' partition
cd /tmp
gunzip openwrt-23.05.0-x86-64-generic-ext4-rootfs.img.gz
dd if=openwrt-23.05.0-x86-64-generic-ext4-rootfs.img of=/dev/sda3
  1. Copy the new linux kernel to /boot and rename the file for efficiency
cp openwrt-23.05.0-x86-64-generic-kernel.bin /boot/openwrt-23.05.0
  1. Add a new entry to grub config in /boot/grub/grub.cfg to boot from new kernel and rootfs
menuentry "OpenWrt Secondary sda3" {
        linux /boot/openwrt-23.05.0 root=/dev/sda3 rootwait   console=tty0 console=ttyS0,115200n8 noinitrd
}
  1. Mount the Secondary RootFS file system into the Primary running image
mkdir /mnt/secondary
mount /dev/sda3 /mnt/secondary
  1. Backup the Primary Openwrt host into the Seconary's filesystem
sysupgrade -b /mnt/secondary/root/backup-primary.tar.gz
  1. chroot into the Seconary rootfs and restore the backup
chroot /mnt/secondary /bin/ash
sysupgrade -r /root/backup-primary.tar.gz
exit
  1. Reboot the system and select the Secondary Image, boot and check everything works.
1 Like

Might want to expand step 5 a bit to explain how you found PARTUUID for /dev/sda3. Did you use partx, like I usually do, or is there another way?

$ partx --show /dev/sda2
NR START    END SECTORS SIZE NAME UUID
 2 33792 246783  212992 104M      0bf605d0-02

skip PARTUUID and use root=/dev/sda3 instead.

2 Likes

Updated as suggested - I used PARTUUID because that was how the existing GRUB entry was setup and I copy/pasted. But you are right, /dev/sda3 is simpler and less error prone.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.