From cb3a0f55e8e37c4f7db239ce27491fd66c9503cc Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Wed, 20 Oct 2021 22:09:16 +0200 Subject: [PATCH] stage2: use atomic bind mounts --- nixos/modules/system/boot/stage-2-init.sh | 8 +++++--- 1 file 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 50ee0b8841e5..afaca2e4158d 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