* [PATCH] initramfs-framework: unmount automounts before switch_root
@ 2022-02-10 20:23 Justin Bronder
0 siblings, 0 replies; only message in thread
From: Justin Bronder @ 2022-02-10 20:23 UTC (permalink / raw)
To: openembedded-core; +Cc: Justin Bronder
If mounts are left lingering, then after we switch_root, attempts to
modify the block devices will result in an EBUSY with no way to unmount
them. As we're about to switch_root anyways, there isn't much use to
keep anything mounted unless it has the new rootfs.
Signed-off-by: Justin Bronder <jsbronder@cold-front.org>
---
.../initrdscripts/initramfs-framework/finish | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index 717383ebac8..f08a9208675 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -12,6 +12,18 @@ finish_run() {
fatal "ERROR: There's no '/dev' on rootfs."
fi
+ # Unmount anything that was automounted by busybox via mdev-mount.sh.
+ # We're about to switch_root, and leaving anything mounted will prevent
+ # the next rootfs from modifying the block device. Ignore ROOT_DISK,
+ # if it was set by setup-live, because it'll be mounted over loopback
+ # to ROOTFS_DIR.
+ local dev
+ for dev in /run/media/*; do
+ if mountpoint -q "${dev}" && [ "${dev##*/}" != "${ROOT_DISK}" ]; then
+ umount -f "${dev}" || debug "Failed to unmount ${dev}"
+ fi
+ done
+
info "Switching root to '$ROOTFS_DIR'..."
debug "Moving /dev, /proc and /sys onto rootfs..."
--
2.35.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-10 20:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 20:23 [PATCH] initramfs-framework: unmount automounts before switch_root Justin Bronder
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.