stage-1: mount /proc, /sys, /dev in the target root

The switch_root in BusyBox doesn't do this (while the one in
util-linux does).  So we have to do this ourselves.
This commit is contained in:
Eelco Dolstra 2012-06-22 13:51:42 -04:00
parent 598adfee3e
commit 980ba4d5a5

View file

@ -336,8 +336,7 @@ echo /sbin/modprobe > /proc/sys/kernel/modprobe
# Start stage 2. `switch_root' deletes all files in the ramfs on the
# current root. It also moves the /proc, /sys and /dev mounts over to
# the new root. Note that $stage2Init might be an absolute symlink,
# current root. Note that $stage2Init might be an absolute symlink,
# in which case "-e" won't work because we're not in the chroot yet.
if ! test -e "$targetRoot/$stage2Init" -o -L "$targetRoot/$stage2Init"; then
echo "stage 2 init script ($targetRoot/$stage2Init) not found"
@ -346,7 +345,9 @@ fi
mkdir -m 0755 -p $targetRoot/proc $targetRoot/sys $targetRoot/dev $targetRoot/run
# `switch_root' doesn't move /run yet, so we have to do it ourselves.
mount --bind /proc $targetRoot/proc
mount --bind /sys $targetRoot/sys
mount --bind /dev $targetRoot/dev
mount --bind /run $targetRoot/run
exec switch_root "$targetRoot" "$stage2Init"