From 5e96e6f7dca2f6d70613d1232bcc3497eddb5f7d Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 11 Aug 2013 11:12:30 +0200 Subject: [PATCH] linuxrc: move mountpoints move code to move_mounts_to_chroot --- defaults/initrd.scripts | 17 +++++++++++++++++ defaults/linuxrc | 16 +--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 671ab98..a21f52b 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -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 +} diff --git a/defaults/linuxrc b/defaults/linuxrc index 533e0c0..6058f1d 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -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