stage2: use atomic bind mounts

Changed files
+5 -3
nixos
modules
system
+5 -3
nixos/modules/system/boot/stage-2-init.sh
···
chmod -f 1775 /nix/store
if [ -n "@readOnlyStore@" ]; then
if ! [[ "$(findmnt --noheadings --output OPTIONS /nix/store)" =~ ro(,|$) ]]; then
-
# FIXME when linux < 4.5 is EOL, switch to atomic bind mounts
-
#mount /nix/store /nix/store -o bind,remount,ro
-
mount --bind /nix/store /nix/store
+
if [ -z "$container" ]; then
+
mount --bind /nix/store /nix/store
+
else
+
mount --rbind /nix/store /nix/store
+
fi
mount -o remount,ro,bind /nix/store
fi
fi