From 483ee6219ecb610c45aff24a2277cf71ce04c25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Wed, 16 Dec 2009 23:59:05 +0000 Subject: [PATCH] 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 --- modules/system/upstart-events/shutdown.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/system/upstart-events/shutdown.nix b/modules/system/upstart-events/shutdown.nix index fa264979c6c..ff208a80b5a 100644 --- a/modules/system/upstart-events/shutdown.nix +++ b/modules/system/upstart-events/shutdown.nix @@ -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; ''; }; -} \ No newline at end of file +}