fadump-init: clean up mount points properly
When running with squash module enabled for both initramfs, /dev and /run are also mounted by squash-init, so move them to newroot as well, else they might leak. Also pass `-d` to umount so loop devices (if used) will be force freed. Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Hari Bathini <hbathini@linux.ibm.com>
This commit is contained in:
parent
bf6671b60d
commit
97930d3cca
@ -20,9 +20,13 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o
|
|||||||
done
|
done
|
||||||
exec switch_root /newroot /init
|
exec switch_root /newroot /init
|
||||||
else
|
else
|
||||||
mkdir /newroot/sys /newroot/proc /newroot/oldroot
|
mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot
|
||||||
mount --move /proc /newroot/proc
|
|
||||||
|
grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev
|
||||||
|
grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run
|
||||||
mount --move /sys /newroot/sys
|
mount --move /sys /newroot/sys
|
||||||
|
mount --move /proc /newroot/proc
|
||||||
|
|
||||||
cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/
|
cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/
|
||||||
cd /newroot && pivot_root . oldroot
|
cd /newroot && pivot_root . oldroot
|
||||||
|
|
||||||
@ -31,11 +35,11 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o
|
|||||||
unset loop
|
unset loop
|
||||||
while read -r _ mp _; do
|
while read -r _ mp _; do
|
||||||
case $mp in
|
case $mp in
|
||||||
/oldroot/*) umount "$mp" && loop=1 ;;
|
/oldroot/*) umount -d "$mp" && loop=1 ;;
|
||||||
esac
|
esac
|
||||||
done </proc/mounts
|
done </proc/mounts
|
||||||
done
|
done
|
||||||
umount -l oldroot
|
umount -d -l oldroot
|
||||||
|
|
||||||
exec /init
|
exec /init
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user