mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-22 23:24:03 +01:00
feat(nixos): capture kernel lockups as panics on headless servers (#529)
Assisted-by: DeepSeek Harness (claude-opus-5-5)
This commit is contained in:
1 parent
bd2b8594f7
commit
9b1a716aa8
4 files changed
+30
No files matched your search
@@ -19,6 +19,7 @@ in
|
||||
{
|
||||
imports = [
|
||||
disko.nixosModules.default
|
||||
../../modules/nixos/headless-recovery.nix
|
||||
../../modules/nixos/power.nix
|
||||
../../modules/nixos/watchdog.nix
|
||||
# disks
|
||||
|
||||
@@ -12,6 +12,7 @@ in
|
||||
{
|
||||
# CPU policy belongs to physical hosts; guests do not control hardware frequency.
|
||||
imports = [
|
||||
../modules/nixos/headless-recovery.nix
|
||||
../modules/nixos/power.nix
|
||||
../modules/nixos/watchdog.nix
|
||||
];
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
# Headless physical servers: turn silent kernel failures into panics, so efi_pstore keeps the
|
||||
# dmesg and kernel.panic reboots. Desktops stay out: a GPU driver oops would drop the session.
|
||||
# hung_task_panic stays off: a stalled USB disk would trip it.
|
||||
# Armed 5 minutes after boot, so an oops during boot cannot loop panic-reboots before SSH is up.
|
||||
systemd.services.panic-on-lockup = {
|
||||
description = "Panic on kernel oops, lockup or RCU stall";
|
||||
path = [ pkgs.procps ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
sysctl -w kernel.panic_on_oops=1
|
||||
sysctl -w kernel.softlockup_panic=1
|
||||
sysctl -w kernel.hardlockup_panic=1
|
||||
sysctl -w kernel.panic_on_rcu_stall=1
|
||||
'';
|
||||
};
|
||||
systemd.timers.panic-on-lockup = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig.OnBootSec = "5min";
|
||||
};
|
||||
# Keep the panic text visible on an attached monitor.
|
||||
boot.kernelParams = [ "consoleblank=0" ];
|
||||
# A failed mount continues the boot with SSH instead of waiting on a console sulogin.
|
||||
systemd.enableEmergencyMode = false;
|
||||
}
|
||||
@@ -3,4 +3,6 @@
|
||||
# a host without a hardware watchdog only logs that /dev/watchdog is missing.
|
||||
systemd.settings.Manager.RuntimeWatchdogSec = "30s";
|
||||
boot.kernel.sysctl."kernel.panic" = 20; # seconds; the default 0 hangs forever
|
||||
# A hard reset keeps only what journald fsynced; the default 5min loses the lead-up to a freeze.
|
||||
services.journald.settings.Journal.SyncIntervalSec = "5s";
|
||||
}
|
||||
Reference in new issue
Block a user