diff options
author | Daniel Golle <daniel@makrotopia.org> | 2021-05-01 20:21:54 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2021-05-05 13:18:43 +0100 |
commit | a2b9ec0231707378e7e9ccaa140c5ebe664abd70 (patch) | |
tree | cb629e59b969e53dc19717bdbd94d903e26ca672 /package/base-files/files/lib/upgrade | |
parent | 3980daffa4e284377cd1ae803fba78331c1fc40b (diff) | |
download | upstream-a2b9ec0231707378e7e9ccaa140c5ebe664abd70.tar.gz upstream-a2b9ec0231707378e7e9ccaa140c5ebe664abd70.tar.bz2 upstream-a2b9ec0231707378e7e9ccaa140c5ebe664abd70.zip |
base-files: upgrade: take down loop and LVM before upgrade
Users of devices with large block storage may choose to have an LVM
partition on the same device which is used for booting OpenWrt.
The presents a problem during sysupgrade as the root device is then
still busy and changing partitions will not work as desired,
leading to data corruption in case the newly flashed image is larger
than the currently installed one.
Having loop devices setup causes similar havoc.
Make sure all volume groups are offline and all loop devices have been
released before sysupgrade.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/base-files/files/lib/upgrade')
-rwxr-xr-x | package/base-files/files/lib/upgrade/stage2 | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index 23d356a447..e2259e3472 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -33,6 +33,9 @@ supivot() { # <new_root> <old_root> } switch_to_ramfs() { + RAMFS_COPY_LOSETUP="$(command -v losetup)" + RAMFS_COPY_LVM="$(command -v lvm)" + for binary in \ /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \ pivot_root mount_root reboot sync kill sleep \ @@ -43,6 +46,7 @@ switch_to_ramfs() { ubiupdatevol ubiattach ubiblock ubiformat \ ubidetach ubirsvol ubirmvol ubimkvol \ snapshot snapshot_tool date \ + $RAMFS_COPY_LOSETUP $RAMFS_COPY_LVM \ $RAMFS_COPY_BIN do local file="$(command -v "$binary" 2>/dev/null)" @@ -60,6 +64,12 @@ switch_to_ramfs() { /bin/mount -o remount,ro /mnt /bin/umount -l /mnt + [ "$RAMFS_COPY_LOSETUP" ] && losetup -D + [ "$RAMFS_COPY_LVM" ] && { + mkdir -p /tmp/lvm/cache + $RAMFS_COPY_LVM vgchange -aln --ignorelockingfailure + } + grep /overlay /proc/mounts > /dev/null && { /bin/mount -o noatime,remount,ro /overlay /bin/umount -l /overlay |