summary refs log tree commit diff
path: root/nixos/modules/system/boot/stage-2-init.sh
diff options
context:
space:
mode:
authorMichael Fellinger <michael.fellinger@iohk.io>2021-10-20 22:09:16 +0200
committerJonathan Ringer <jonringer@users.noreply.github.com>2021-11-01 20:12:59 -0700
commitcb3a0f55e8e37c4f7db239ce27491fd66c9503cc (patch)
treec444458d63d5db957f91d20d7fd7d941849d601b /nixos/modules/system/boot/stage-2-init.sh
parent726da12d8b1201b42840cb6d05d050429d0b0525 (diff)
downloadnixpkgs-cb3a0f55e8e37c4f7db239ce27491fd66c9503cc.tar
nixpkgs-cb3a0f55e8e37c4f7db239ce27491fd66c9503cc.tar.gz
nixpkgs-cb3a0f55e8e37c4f7db239ce27491fd66c9503cc.tar.bz2
nixpkgs-cb3a0f55e8e37c4f7db239ce27491fd66c9503cc.tar.lz
nixpkgs-cb3a0f55e8e37c4f7db239ce27491fd66c9503cc.tar.xz
nixpkgs-cb3a0f55e8e37c4f7db239ce27491fd66c9503cc.tar.zst
nixpkgs-cb3a0f55e8e37c4f7db239ce27491fd66c9503cc.zip
stage2: use atomic bind mounts
Diffstat (limited to 'nixos/modules/system/boot/stage-2-init.sh')
-rw-r--r--nixos/modules/system/boot/stage-2-init.sh8
1 files changed, 5 insertions, 3 deletions
diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh
index 50ee0b8841e..afaca2e4158 100644
--- a/nixos/modules/system/boot/stage-2-init.sh
+++ b/nixos/modules/system/boot/stage-2-init.sh
@@ -62,9 +62,11 @@ chown -f 0:30000 /nix/store
 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