Move dev to chroot
authorPeter Hjalmarsson <xake@rymdraket.net>
Tue, 1 Feb 2011 18:34:54 +0000 (19:34 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Mon, 7 Feb 2011 03:07:08 +0000 (04:07 +0100)
This can be considered good practice, likely less chance that nodes
created in the ramdisk disapperes when switching root.
Some applications (mostly debugging/benchmarking) also needs this to
survive the switch_root.

defaults/linuxrc

index ee33a355d137f7111e6e43dfd97ab658730abb3f..88eed003786f09426afdb0b1e0d5daae87fe6ed0 100755 (executable)
@@ -725,10 +725,14 @@ cd "${CHROOT}"
 mkdir "${CHROOT}/proc" "${CHROOT}/sys" 2>/dev/null
 echo -ne "${BOLD}.${NORMAL}"
 
-# If devtmpfs is mounted assume genkernel mounted it at /dev and try unmounting it
+# 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
 if grep -qs devtmpfs /proc/mounts
 then
-       umount /dev || echo '*: Failed to unmount the devtmpfs /dev!'
+       if ! mount --move /dev "${CHROOT}"/dev
+       then
+               umount -a -t devtmpfs || echo '*: Failed to move and unmount the devtmpfs /dev!'
+       fi
 fi
 
 umount /sys || echo '*: Failed to unmount the ramdisk /sys!'