linuxrc: move mountpoints move code to move_mounts_to_chroot

master
Fabio Erculiani 12 years ago
parent afea330cb1
commit 5e96e6f7dc

@ -2112,3 +2112,20 @@ rootdev_init() {
fi
done
}
# If devtmpfs is mounted, try move it to the new root
# If that fails, try to unmount all possible mounts of devtmpfs as
# stuff breaks otherwise
move_mounts_to_chroot() {
for fs in /run /dev /sys /proc; do
if grep -qs "$fs" /proc/mounts; then
local chroot_dir="${CHROOT}${fs}"
mkdir -p "${chroot_dir}"
if ! mount --move $fs "${chroot_dir}"
then
umount $fs || \
bad_msg "Failed to move and umount $fs!"
fi
fi
done
}

@ -323,22 +323,8 @@ devmgr_terminate
good_msg "Booting (initramfs)"
cd "${CHROOT}"
mkdir -p "${CHROOT}/proc" "${CHROOT}/sys" "${CHROOT}/run"
# If devtmpfs is mounted, try move it to the new root
# If that fails, try to unmount all possible mounts of devtmpfs as
# stuff breaks otherwise
for fs in /run /dev /sys /proc
do
if grep -qs "$fs" /proc/mounts
then
if ! mount --move $fs "${CHROOT}"$fs
then
umount $fs || \
bad_msg "Failed to move and unmount the ramdisk $fs!"
fi
fi
done
move_mounts_to_chroot
if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ]
then

Loading…
Cancel
Save