From f2c2b7ace9afebbf85fbd7b4dc99c924c97e1041 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 21 Jan 2013 21:01:48 +0100 Subject: [PATCH] Don't start emergency mode on EC2 instances EC2 instances don't have a console, so it's pointless to start emergency mode if a mount fails. (This happened to me with an encrypted filesystem where the key wasn't sent on time using "charon send-keys".) Better to cross fingers and continue booting. --- modules/profiles/headless.nix | 3 +++ modules/system/boot/systemd.nix | 22 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/profiles/headless.nix b/modules/profiles/headless.nix index 0a2bfa80c47c..9693e36d9ebd 100644 --- a/modules/profiles/headless.nix +++ b/modules/profiles/headless.nix @@ -17,4 +17,7 @@ with pkgs.lib; # Since we can't manually respond to a panic, just reboot. boot.kernelParams = [ "panic=1" "boot.panic_on_fail" ]; + + # Don't allow emergency mode, because we don't have a console. + systemd.enableEmergencyMode = false; } diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index b76367021206..d33409880922 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -36,11 +36,9 @@ let #"cryptsetup.target" "sigpwr.target" - # Rescue/emergency. + # Rescue mode. "rescue.target" "rescue.service" - "emergency.target" - "emergency.service" # Udev. "systemd-udevd-control.socket" @@ -133,6 +131,11 @@ let "systemd-ask-password-console.service" "systemd-ask-password-wall.path" "systemd-ask-password-wall.service" + ] + + ++ optionals cfg.enableEmergencyMode [ + "emergency.target" + "emergency.service" ]; upstreamWants = @@ -456,6 +459,19 @@ in ''; }; + systemd.enableEmergencyMode = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable emergency mode, which is an + sulogin shell started on the console if + mounting a filesystem fails. Since some machines (like EC2 + instances) have no console of any kind, emergency mode doesn't + make sense, and it's better to continue with the boot insofar + as possible. + ''; + }; + };