From ad62247800a10654ab7a3d94ea9c6b43a834f301 Mon Sep 17 00:00:00 2001 From: Klaus Kudielka Date: Wed, 8 May 2019 20:40:50 +0200 Subject: base-files: improve lib/upgrade/common.sh Recently, upgrade device autodetection has been added to the mvebu target. This exposes some shortcomings of the generic export_bootdevice function, e.g. on the Turris Omnia: export_bootdevice silently reports the root partition to be the boot device. This makes the sysupgrade process fail at several places. Fix this by clearly distinguishing between /proc/cmdline arguments which specify the boot disk, and those which specify the root partition. Only in the latter case, strip off the partition, and do it consistently. root=PARTUUID= (any partition) and root=/dev/* (any partition) are accepted. The root of the problem is that the *existing* export_bootdevice in /lib/upgrade/common.sh behaves differently, if the kernel is booted with root=/dev/..., or if it is booted with root=PARTUUID=... In the former case, it reports back major/minor of the root partition, in the latter case it reports back major/minor of the complete boot disk. Targets, which boot with root=/dev/... *and* use export_bootdevice / export_partdevice, have added workarounds to this behaviour, by specifying *negative* increments to the export_partdevice function. Consequently, those targets have to be adapted to use positive increments, otherwise they are broken by the change to export_bootdevice. Fixes: 4e8345ff68 ("mvebu: base-files: autodetect upgrade device") Signed-off-by: Klaus Kudielka Tested-by: Tomasz Maciej Nowak --- target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh') diff --git a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh index 2287e0619d..c191271149 100644 --- a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh +++ b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh @@ -7,7 +7,7 @@ mbl_do_platform_check() { [ "$#" -gt 1 ] && return 1 - export_bootdevice && export_partdevice diskdev -2 || { + export_bootdevice && export_partdevice diskdev 0 || { echo "Unable to determine upgrade device" return 1 } @@ -36,7 +36,7 @@ mbl_do_platform_check() { mbl_do_upgrade() { local diskdev partdev diff - export_bootdevice && export_partdevice diskdev -2 || { + export_bootdevice && export_partdevice diskdev 0 || { echo "Unable to determine upgrade device" return 1 } @@ -70,10 +70,6 @@ mbl_do_upgrade() { #iterate over each partition from the image and write it to the boot disk while read part start size; do - # root is /dev/sd[a|b]2 and not /dev/sd[a|b] this causes some problem - # one of which is this offset, I'm not sure what's the best fix, so - # here's a WA. - let part=$((part - 2)) if export_partdevice partdev $part; then echo "Writing image to /dev/$partdev..." get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync @@ -90,8 +86,7 @@ mbl_do_upgrade() { mbl_copy_config() { local partdev - # Same as above /dev/sd[a|b]2 is root, so /boot is -1 - if export_partdevice partdev -1; then + if export_partdevice partdev 1; then mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt cp -af "$CONF_TAR" /mnt/ umount /mnt -- cgit v1.2.3