Linux kernel: Difference between revisions
→Configuration: Add info about SysRq |
|||
Line 86: | Line 86: | ||
} | } | ||
</nowiki>}} | </nowiki>}} | ||
=== Enable SysRq === | |||
The Linux kernel is known<ref>https://github.com/hakavlad/nohang?tab=readme-ov-file#what-is-the-problem</ref> to not handle out-of-memory situation properly and can freeze for a long time, often leaving no option but doing a hard reboot. The [https://en.wikipedia.org/wiki/Magic_SysRq_key SysRq shortcuts] can be used to trigger a more graceful reboot. However, most keys are disabled by default on NixOS. To enable: | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | |||
{ | |||
boot.kernel.sysctl."kernel.sysrq" = 1; | |||
} | |||
</nowiki>}} | |||
Useful shortcuts, triggered using {{ic|Alt+SysRq+<key>}}: | |||
* {{ic|h}}: Print help to the system log. | |||
* {{ic|f}}: Trigger the kernel oom killer. | |||
* {{ic|s}}: Sync data to disk. | |||
* {{ic|e}}: SIGTERM all processes except PID 0. | |||
* {{ic|i}}: SIGKILL all processes except PID 0. | |||
Check {{journalclt}} to see if you are triggering the shortcuts correctly, which might be different for your keyboard, as noted in the Wikipedia page. | |||
Also see {{nixos:config|services.earlyoom.enable}} and {{nixos:config|systemd.oomd.enable}}. | |||
=== Custom configuration === | === Custom configuration === |