From 728a27864164954ea1f589885cce2399b2e8ae3f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 May 2008 09:32:31 +0000 Subject: [PATCH] * Unmount only the filesystems that the installer actually mounted. So if the user mounted /mnt/boot or something, don't unmount it. svn path=/nixos/trunk/; revision=11792 --- installer/nixos-install.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/installer/nixos-install.sh b/installer/nixos-install.sh index c40558df6a8b..24ef5a512f23 100644 --- a/installer/nixos-install.sh +++ b/installer/nixos-install.sh @@ -61,26 +61,31 @@ mount --bind /sys $mountPoint/sys # Grub needs a mtab. Make a proper one.. chroot $mountPoint \ - /nix/var/nix/profiles/system/sw/bin/cat /proc/mounts > /etc/mtab - + /nix/var/nix/profiles/system/sw/bin/cat /proc/mounts > /etc/mtab + echo "/etc/mtab: " cat /mnt/etc/mtab # That could spoil mtab with litter. mount --rbind / $mountPoint/mnt -cleanup() { - # !!! don't umount anything we didn't mount ourselves - for i in $(grep -F "$mountPoint" /proc/mounts \ +umountUnder() { + local dir="$1" + for i in $(grep -F " $dir" /proc/mounts \ | @perl@/bin/perl -e 'while (<>) { /^\S+\s+(\S+)\s+/; print "$1\n"; }' \ | sort -r); do - if test "$i" != "$mountPoint" -a "$i" != / -a -e "$i"; then - umount $i || true - fi + umount $i || true done } +cleanup() { + umountUnder $mountPoint/mnt + umountUnder $mountPoint/dev + umountUnder $mountPoint/proc + umountUnder $mountPoint/sys +} + trap "cleanup" EXIT mkdir -m 01777 -p $mountPoint/tmp