Questions on x86 upgrade and maintenance strategies

I have a couple of questions and confusions about the long-time maintenance of running OpenWrt on x86.

Situation: Let us assume the device in questions has SATA disk, and I have written generic-ext4-combined-efi.img to its SATA-disk.

How do people upgrade their devices properly with minimal downtime, and at best without physical access?

Plug in i.e. a flash thumb drive with a live system, reboot, and writing a new .img to disk, unplug the drive and reboot again, does not seam right to me.

Using pivot_root?
Disclaimer: I have no real clue what I'm doing here, but copy/paste https://gist.github.com/TobleMiner/d85cc71709164b443cbbe42150875cde, remove set -x, seams to work. I could boot. But this leave the boot partion untouched, which is also not cool, as in, then I need to ensure that it is up to date myself.

Just use dd out of the running system to write to disk?
Again, I have no clue, why this could be a bad idea or what could possibly go wrong, but this worked without an issue (so far), too...

Currently my devices has no network connection and I'm only using the serial connection. Could it be a problem (writing a new .img to disk) while dropbear has an active session or other services are running? For upgrade I could use the serial connection as this will be permanently plugged into computer next to the x86, to which I have local network access.

TL;DR; I'm looking for clues how to upgrade x86 with minimal downtime. I will only use disk-images build with image-builder if that matters.

PS: Using 2 openwrt root partions and having a really poor mans dual boot setup seams also broken to me. I need to manually ensure the correct openwrt version is booted, and write a second time to the "primary" partion to ensure that the device is boot safe without manual actions.

Hi.
This is why the squashfs version exists : it can update itself.

You can use sysupgrade with ext4 images as well.

1 Like

check here Sysupgrade help for x86_64

on x86 you can create as many root partitions as you want so you can have a working (old) release and new (test) release parallel. and just need a simple grub magic to even automatically revert to working root if new release is not working for you.

Could you please a little bit more verbose because it seams to me that this was not the recommended way?

So I will write the combined ext to disk and later I use sysupgrade with the compressed root image?

Yes (you could even give sysupgrade the full download URL, but sysupgrade /tmp/openwrt-...-generic-ext4-combined-efi.img would be the customary approach - no difference to sysupgrading on non-x86).

Then the note on the wiki is outdated or not correct? In the wiki is this clear fat warning that sysupgrade is not recommended for x86 under any circumstances...
With a default vanilla disk image maybe because you loose everything but with packages and configs baked in, sysupgrade seams as the easiest solution?

Don't tell that to my devices, whichvhave been sysupgraded for almost half a decade (albeit squashfs).

3 Likes

Do you preserve your config or do you use a configured image?
Nah, your dirty secret is safe with me :wink:

1 Like

Btw, has someone details how sysupgrade works with ext4 and whole disks? On devices with EPROM? Flash mtd is used AFAIK but what happens on or with a SATA disk?

Flip images in VMs i.e. proxmox, roll forward or back as needed.

Whoa. I'm flashed! /badpun

BusyBox v1.35.0 (2022-10-07 23:34:56 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 22.03.1, r19777-2853b6d652
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# mount /dev/sdb1 /mnt/
[   24.301974] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)
root@OpenWrt:/# sysupgrade -n /mnt/openwrt-22.03.2-x86-64-generic-ext4-combined-
efi.img.gz
Thu Dec 29 21:11:01 UTC 2022 upgrade: Image not in /tmp, copying...
Thu Dec 29 21:11:02 UTC 2022 upgrade: Image metadata not present
Thu Dec 29 21:11:02 UTC 2022 upgrade: Reading partition table from bootdisk...
Thu Dec 29 21:11:02 UTC 2022 upgrade: Extract boot sector from the image
Thu Dec 29 21:11:02 UTC 2022 upgrade: Reading partition table from image...
Thu Dec 29 21:11:02 UTC 2022 upgrade: Commencing upgrade. Closing all shell sessions.
Command failed: Thu Dec 29 21:11:02 UTC 2022 upgrade: Sending TERM to remaining processes ...
Thu Dec 29 21:11:02 UTC 2022 upgrade: Sending signal TERM to ntpd (3065)
Thu Dec 29 21:11:02 UTC 2022 upgrade: Sending signal TERM to ntpd (3068)
Thu Dec 29 21:11:06 UTC 2022 upgrade: Sending KILL to remaining processes ...
Thu Dec 29 21:11:06 UTC 2022 upgrade: Sending signal KILL to ntpd (3065)
Thu Dec 29 21:11:06 UTC 2022 upgrade: Sending signal KILL to ntpd (3068)
[   49.209330] stage2 (4521): drop_caches: 3
Thu Dec 29 21:11:12 UTC 2022 upgrade: Switching to ramdisk...
[   49.527709] EXT4-fs (sda2): re-mounted. Opts: (null)
Thu Dec 29 21:11:13 UTC 2022 upgrade: Performing system upgrade...
Thu Dec 29 21:11:13 UTC 2022 upgrade: Reading partition table from bootdisk...
Thu Dec 29 21:11:13 UTC 2022 upgrade: Extract boot sector from the image
Thu Dec 29 21:11:13 UTC 2022 upgrade: Reading partition table from image...
Thu Dec 29 21:11:13 UTC 2022 upgrade: Writing image to /dev/sda1...
Thu Dec 29 21:11:13 UTC 2022 upgrade: Writing image to /dev/sda2...
Thu Dec 29 21:11:14 UTC 2022 upgrade: Writing new UUID to /dev/sda...
[   50.913822] F2FS-fs (sda1): Magic Mismatch, valid(0xf2f52010) - read(0x0)
[   50.920683] F2FS-fs (sda1): Can't find valid F2FS filesystem in 1th superblock
[   50.928013] F2FS-fs (sda1): Magic Mismatch, valid(0xf2f52010) - read(0x6020601)
[   50.935349] F2FS-fs (sda1): Can't find valid F2FS filesystem in 2th superblock
Thu Dec 29 21:11:14 UTC 2022 upgrade: Upgrading bootloader on /dev/sda...
grub-bios-setup: warning: Your BIOS Boot Partition is under 1 MiB, please increase its size..
Thu Dec 29 21:11:15 UTC 2022 upgrade: Upgrade completed
Thu Dec 29 21:11:16 UTC 2022 upgrade: Rebooting system...
umount: can't unmount /dev: Resource busy
umount: can't unmount /tmp: Resource busy
[   52.656049] sd 1:0:0:0: [sda] Synchronizing SCSI cache
[   52.766537] reboot: Restarting system
[   52.770214] reboot: machine restart

Why again states the wiki that this is not recommended? Yes, I have to resize my root-partition [1], but it will write the boot- and root-partition while running the system and even performs an automatic reboot.

Someone (tm) should definitely review and fix guide-user/installation/openwrt_x86

[1] Or just set the size accordingly when building with i.e. the image-builder

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