mirror of
git://git.yoctoproject.org/poky
synced 2026-08-14 13:18:39 +00:00
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. (From OE-Core rev: 999883990235251127b65f2277dcb40004e7f657) Signed-off-by: Justin Bronder <jsbronder@cold-front.org> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 4dc7af6d25597ea10ea43e76c7c3d7251462c0e5) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> (cherry picked from commit 991631492f4fafc1852113a34a60b025342518b6) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
40 lines
1.1 KiB
Bash
Executable File
40 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright (C) 2011 O.S. Systems Software LTDA.
|
|
# Licensed on MIT
|
|
|
|
finish_enabled() {
|
|
return 0
|
|
}
|
|
|
|
finish_run() {
|
|
if [ -n "$ROOTFS_DIR" ]; then
|
|
if [ ! -d $ROOTFS_DIR/dev ]; then
|
|
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..."
|
|
mount --move /dev $ROOTFS_DIR/dev
|
|
mount --move /proc $ROOTFS_DIR/proc
|
|
mount --move /sys $ROOTFS_DIR/sys
|
|
|
|
cd $ROOTFS_DIR
|
|
exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init}
|
|
else
|
|
debug "No rootfs has been set"
|
|
fi
|
|
}
|