From fbde5e027e71f75b47946202951c7a9bd6ffe700 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 28 Mar 2013 16:11:54 +0100 Subject: [PATCH] Sync after installing the boot loader Previously we synced just before calling switch-to-configuration. That prevents corruption of the Nix store, but it can leave the boot loader configuration and kernel files in /boot corrupted. So do the sync after installing the boot loader. --- modules/installer/tools/nixos-rebuild.sh | 3 --- modules/system/activation/switch-to-configuration.pl | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/installer/tools/nixos-rebuild.sh b/modules/installer/tools/nixos-rebuild.sh index 255c8150bdd..fb26279e7c7 100644 --- a/modules/installer/tools/nixos-rebuild.sh +++ b/modules/installer/tools/nixos-rebuild.sh @@ -191,9 +191,6 @@ fi # If we're not just building, then make the new configuration the boot # default and/or activate it now. if [ "$action" = switch -o "$action" = boot -o "$action" = test ]; then - # Just in case the new configuration hangs the system, do a sync now. - sync - $pathToConfig/bin/switch-to-configuration "$action" fi diff --git a/modules/system/activation/switch-to-configuration.pl b/modules/system/activation/switch-to-configuration.pl index a95ebcaba24..4db53c9043e 100644 --- a/modules/system/activation/switch-to-configuration.pl +++ b/modules/system/activation/switch-to-configuration.pl @@ -33,9 +33,13 @@ openlog("nixos", "", LOG_USER); # Install or update the bootloader. if ($action eq "switch" || $action eq "boot") { system("@installBootLoader@ $out") == 0 or exit 1; - exit 0 if $action eq "boot"; } +# Just in case the new configuration hangs the system, do a sync now. +system("sync") unless ($ENV{"NIXOS_NO_SYNC"} // "") eq "1"; + +exit 0 if $action eq "boot"; + # Check if we can activate the new configuration. my $oldVersion = read_file("/run/current-system/init-interface-version", err_mode => 'quiet') // ""; my $newVersion = read_file("$out/init-interface-version");