summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initrdscripts/initramfs-framework/finish
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/initrdscripts/initramfs-framework/finish')
-rwxr-xr-xmeta/recipes-core/initrdscripts/initramfs-framework/finish23
1 files changed, 22 insertions, 1 deletions
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index 717383ebac..716c2f44af 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -12,15 +12,36 @@ finish_run() {
12 fatal "ERROR: There's no '/dev' on rootfs." 12 fatal "ERROR: There's no '/dev' on rootfs."
13 fi 13 fi
14 14
15 # Unmount anything that was automounted by busybox via mdev-mount.sh.
16 # We're about to switch_root, and leaving anything mounted will prevent
17 # the next rootfs from modifying the block device. Ignore ROOT_DISK,
18 # if it was set by setup-live, because it'll be mounted over loopback
19 # to ROOTFS_DIR.
20 local dev
21 for dev in /run/media/*; do
22 if mountpoint -q "${dev}" && [ "${dev##*/}" != "${ROOT_DISK}" ]; then
23 umount -f "${dev}" || debug "Failed to unmount ${dev}"
24 fi
25 done
26
15 info "Switching root to '$ROOTFS_DIR'..." 27 info "Switching root to '$ROOTFS_DIR'..."
16 28
29 debug "Moving basic mounts onto rootfs"
30 for dir in `awk '/\/dev.* \/run\/media/{print $2}' /proc/mounts`; do
31 # Parse any OCT or HEX encoded chars such as spaces
32 # in the mount points to actual ASCII chars
33 dir=`printf $dir`
34 mkdir -p "${ROOTFS_DIR}/media/${dir##*/}"
35 mount -n --move "$dir" "${ROOTFS_DIR}/media/${dir##*/}"
36 done
37
17 debug "Moving /dev, /proc and /sys onto rootfs..." 38 debug "Moving /dev, /proc and /sys onto rootfs..."
18 mount --move /dev $ROOTFS_DIR/dev 39 mount --move /dev $ROOTFS_DIR/dev
19 mount --move /proc $ROOTFS_DIR/proc 40 mount --move /proc $ROOTFS_DIR/proc
20 mount --move /sys $ROOTFS_DIR/sys 41 mount --move /sys $ROOTFS_DIR/sys
21 42
22 cd $ROOTFS_DIR 43 cd $ROOTFS_DIR
23 exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init} 44 exec switch_root $ROOTFS_DIR ${bootparam_init:-/sbin/init}
24 else 45 else
25 debug "No rootfs has been set" 46 debug "No rootfs has been set"
26 fi 47 fi