sysupgrade: workaround 'mount -o move' fail on sysupgrade on some devices

```
mount: mounting /proc on /tmp/root/proc failed: Invalid argument
```

Can not reproduce.
This commit is contained in:
Liangbin Lian 2024-01-11 23:18:49 +08:00
parent a77ec9a64c
commit 07082df5bf
2 changed files with 11 additions and 6 deletions

View File

@ -19,17 +19,18 @@ include /lib/upgrade
supivot() { # <new_root> <old_root>
/bin/mount | grep "on $1 type" 2>&- 1>&- || /bin/mount -o bind $1 $1
mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay $1/ext_overlay && \
/bin/mount -o noatime,move /proc $1/proc && \
/bin/mount -o noatime,rbind /proc $1/proc && \
pivot_root $1 $1$2 || {
/bin/umount -l $1 $1
return 1
}
/bin/mount -o noatime,move $2/sys /sys
/bin/mount -o noatime,move $2/dev /dev
/bin/mount -o noatime,move $2/tmp /tmp
/bin/mount -o noatime,move $2/sys /sys || /bin/mount -o noatime,rbind $2/sys /sys
/bin/mount -o noatime,move $2/dev /dev || /bin/mount -o noatime,rbind $2/dev /dev
/bin/mount -o noatime,move $2/tmp /tmp || /bin/mount -o noatime,bind $2/tmp /tmp
/bin/mount -o noatime,move $2/overlay /overlay 2>&-
/bin/mount -o noatime,move $2/ext_overlay /ext_overlay 2>&-
/bin/umount -l $2/proc $2/sys $2/dev $2/tmp $2/overlay $2/ext_overlay 2>&-
return 0
}
@ -140,8 +141,6 @@ killall -9 ash
kill_remaining TERM
sleep 3
sync
/usr/bin/umount -R -d /mnt &
sleep 5
kill_remaining KILL 1
sleep 1

View File

@ -357,6 +357,12 @@ if [ $TEST -eq 1 ]; then
exit 0
fi
# In case $RAM_ROOT was mounted or a regular file
/bin/umount -l $RAM_ROOT 2>/dev/null
rm -f $RAM_ROOT
/bin/mount -o bind /tmp /tmp
mkdir $RAM_ROOT
install_bin /sbin/upgraded
v "Commencing upgrade. Closing all shell sessions."