Skip to content

Commit

Permalink
armsr: preserve configuration during sysupgrade
Browse files Browse the repository at this point in the history
Copy configuration to boot partition (partition 1) instead of root
partition (partition 2) because the root partition is not writable if
it's a suqashfs image.
Move configuration back to root during preinit.

Fixes: openwrt#13695
Signed-off-by: Christian Buschau <cbuschau@d00t.de>
  • Loading branch information
Kistelini authored and Ansuel committed Oct 19, 2023
1 parent 3e1ac00 commit 67ce60c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions target/linux/armsr/base-files/lib/preinit/79_move_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: GPL-2.0-only

move_config() {
local partdev parttype=ext4

. /lib/upgrade/common.sh

if export_bootdevice && export_partdevice partdev 1; then
part_magic_fat "/dev/$partdev" && parttype=vfat
if mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt; then
if [ -f "/mnt/$BACKUP_FILE" ]; then
mv -f "/mnt/$BACKUP_FILE" /
fi
umount /mnt
fi
fi
}

boot_hook_add preinit_mount_root move_config
3 changes: 2 additions & 1 deletion target/linux/armsr/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ platform_check_image() {
platform_copy_config() {
local partdev parttype=ext4

if export_partdevice partdev 2; then
if export_partdevice partdev 1; then
part_magic_fat "/dev/$partdev" && parttype=vfat
mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
Expand Down

0 comments on commit 67ce60c

Please sign in to comment.