mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-09-11 15:08:33 +01:00
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:
parent
aa445933a7
commit
483ee6219e
|
@ -97,17 +97,21 @@ with pkgs.lib;
|
||||||
device=$(getDevice $mp)
|
device=$(getDevice $mp)
|
||||||
echo "unmounting $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.
|
# Note: don't use `umount -f'; it's very buggy.
|
||||||
# (For instance, when applied to a bind-mount it
|
# (For instance, when applied to a bind-mount it
|
||||||
# unmounts the target of the bind-mount.) !!! But
|
# unmounts the target of the bind-mount.) !!! But
|
||||||
# we should use `-f' for NFS.
|
# we should use `-f' for NFS.
|
||||||
if umount -n "$mp"; then
|
if umount -n "$mp"; then
|
||||||
if test "$mp" != /; then tryAgain=1; fi
|
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
|
fi
|
||||||
|
|
||||||
# Hack: work around a bug in mount (mount -o remount on a
|
# Hack: work around a bug in mount (mount -o remount on a
|
||||||
|
@ -138,4 +142,4 @@ with pkgs.lib;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue