[RFC] Writing sysupgrade.tgz directly to overlay for block-device sysupgrade

David Woodhouse dwmw2 at infradead.org
Fri Jul 24 05:29:52 EDT 2020


We were playing on IRC with a way to write the backup file directly out
alongside the root file system for block devices, similar to the way
that it happens with 'mtd write -j sysupgrade.tgz'.

A lot of devices currently put it in a FAT "recovery" partition but
it's not clear that will always be big enough for large backups.

Doing this in platform_copy_config() seems to work...

RAMFS_COPY_BIN="mount_root ln mkfs.f2fs"

platform_copy_config() {
               rmdir /tmp/overlay # Or mount_root bails out
               mkdir -p /rom
               mount $rootdev /rom
               PREINIT=1 mount_root
               # 'mount_root done', if it worked, would just do this
               ln -sf 2 /overlay/.fs_state
               cp -af "$UPGRADE_BACKUP" "/$BACKUP_FILE"
               sync # We should unmount it properly
               echo done

We got that working but I'm slightly reticent about it — it limits the
things we can change from one version of OpenWrt to the next... and
indeed to all future versions.

After all, we don't *know* that OpenWrt 21.xx will still be using f2fs
for its overlay, and we'd be making that part of the defined ABI for
sysupgrade.

Instead of using the overlay filesystem du jour, perhaps it makes more
sense to simply put the tarball itself, raw, on the loop device
immediately after the end of the squashfs? Or if the rootfs is a
writeable file system, then we write it directly to the root of the new
file system just like 'mtd -j' does?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20200724/11b869d1/attachment.bin>


More information about the openwrt-devel mailing list