diff --git a/defaults/initrd.d/00-fsdev.sh b/defaults/initrd.d/00-fsdev.sh index 0696d0b..08bab63 100755 --- a/defaults/initrd.d/00-fsdev.sh +++ b/defaults/initrd.d/00-fsdev.sh @@ -9,6 +9,23 @@ mount_sysfs() { bad_msg "Failed to mount /sys!" } +# 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 +} + find_real_device() { local device="${1}" local out= diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index ac9ea1c..024230b 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -14,20 +14,3 @@ . /etc/initrd.d/00-suspend.sh . /etc/initrd.d/00-iscsi.sh . /etc/initrd.d/00-rootdev.sh - -# 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 -}