Fixing the shutdown script, for the not-that-strange case of having

/nix bind mounted from a fs not rootfs.

As niksnut found, if the sources of bind mounted directories are
umounted before remounting them as "ro", a "mount -o remount,ro" on the
bind targets will not leave the filesystem properly umounted, the same
way as a "-o remount,ro" would do on a usual filesystem.

So, the trick of always remounting as 'ro' before attempting an umount seems
to fix the problem.

svn path=/nixos/trunk/; revision=19008
This commit is contained in:
Lluís Batlle i Rossell 2009-12-16 23:59:05 +00:00
parent aa445933a7
commit 483ee6219e

View file

@ -97,17 +97,21 @@ with pkgs.lib;
device=$(getDevice $mp)
echo "unmounting $mp..."
# We need to remount,ro before attempting any
# umount, or bind mounts may get confused, with
# the fs not being properly flushed at the end.
# `-i' is to workaround a bug in mount.cifs (it
# doesn't recognise the `remount' option, and
# instead mounts the FS again).
mount -n -i -o remount,ro "$mp"
# Note: don't use `umount -f'; it's very buggy.
# (For instance, when applied to a bind-mount it
# unmounts the target of the bind-mount.) !!! But
# we should use `-f' for NFS.
if umount -n "$mp"; then
if test "$mp" != /; then tryAgain=1; fi
else
# `-i' is to workaround a bug in mount.cifs (it
# doesn't recognise the `remount' option, and
# instead mounts the FS again).
mount -n -i -o remount,ro "$mp"
fi
# Hack: work around a bug in mount (mount -o remount on a
@ -138,4 +142,4 @@ with pkgs.lib;
'';
};
}
}