Sorry for the long delay...
I finally got a time to get back to this.
I have now fixed the issue, like @egc pointed out:
So, I have my settings now:
root@reititin:~# uci show attendedsysupgrade.owut
attendedsysupgrade.owut=owut
attendedsysupgrade.owut.verbosity='1'
attendedsysupgrade.owut.pre_install='/etc/owut.d/pre-install.sh'
attendedsysupgrade.owut.rootfs_size='256'
And I created an extra partition to keep my backups:
root@reititin:~# parted -l -s
Model: ShiJi 128GB M.2-NVMe (nvme)
Disk /dev/nvme0n1: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 boot legacy_boot
2 17.0MB 285MB 268MB ext4 root
3 2147MB 4295MB 2147MB ext4 backup
This works now, BUT, there is one issue:
First time you set the owut.rootfs_size, it seems to completely wipe your partition table. I was trying to create root partition with exactly 256 MiB and expanded the ext4 to that size. However, it was completetly wiped.
But now, when restored from backup, and doing owut upgrade --force, everything works. Even the extra partitions are kept.
So the attendedsysupgrade.owut.rootfs_size is the answer. But only after it wipes the partition table once.
When I was not defining the root_fs size, it uses some kind of default.
It is documented to be 104MiB.
But even when the partition is created as exactly same size, it still seem to be re-created every time, unless I manually specify the rootfs_size = <something> for owut.
So either there is something wrong on sysupgrade when it calculates the default (or current) size, or this has to be documented.
If I would have known this, I could have created the initial install image using the rootfs_size already set. But I cannot find any way to control this for OpenWrt Firmware Selctor. The value used for default build is not shown there.
So for X86 with ext4 rootfs, best way to install is to install once with default image, then define the rootfs_size that you want, then re-install with owut and finnish the setup with probably extra partitions if you prefer.
Worth mentioning here, in case someone stumbles on the same issue:
If you have a larger disk, and you plan to create extra partitions:
Leave a large gap between rootfs and your extra partition.
And try to remember where your partition started.
For example, when I created the partition, I used something like:
parted /dev/nvme0n1 mkpart backup 1024MiB 2048Mib
mkfs.ext4 /dev/nvme0n1p3
# Add this to /etc/fstab, and add /etc/fstab to a list of files to backup
/dev/nvme0n1p3 /mnt/backup ext4 defaults 0 0
# Then add this to /etc/rc.local
mkdir -p /mnt/backup
mount -a
NOTE: My /etc/owut.d/pre-install.sh does local backups into /mnt/backup.
Now, when I lost the partition table on the first install, I can recover it because I rembember it was 1024MiB from the beginning of the disk.
So booting OpenWRT in rescue mode
mount_root
parted /dev/nvme0n1 rescue 1024MiB 2048MiB
mkdir -p /mnt/backup
mount -t ext4 /dev/nvme0n1p3 /mnt/backup
# Now I can restore the local backup
sysupgrade -r /mnt/backup/backup-<timestamp>.tgz
This thread seems to be a valuable one to read… I picked up a atom-based x86_64 box - now running Openwrt with AdGuardHome and Tailscale, but I was unsure of how attendedsysupgrade interacts with the partitions, grub.
I’ll be sure to backup my settings and Tailscale statefile before tinkering.