linutil
linutil copied to clipboard
[Feature request] Enable SysRq for Magic Key Sequences (ex: REISUB)
Is your feature request related to a problem? Please describe.
I often encounter situations where my system freezes, and the only option is to perform a hard reboot. Using SysRq (e.g., the REISUB sequence) allows for a safer, cleaner reboot of a frozen system compared to a hard shutdown. It would be highly beneficial if SysRq could be enabled by default, along with a small reminder or cheat sheet of possible key sequences displayed after setup.
Describe the solution you'd like
Ideally, Linutil could automatically enable SysRq and provide a simple cheat sheet of useful key sequences (e.g., REISUB) at the end of the setup process. This would help users handle system freezes in a safer, more controlled way by guiding them through the use of SysRq key combinations.
Describe alternatives you've considered
To enable SysRq, I’ve previously used the following methods depending on the bootloader and system configuration:
For GRUB-based systems:
- Modify GRUB configuration: Adding
sysrq_always_enabled=1to theGRUB_CMDLINE_LINUX_DEFAULTvariable in the/etc/default/grubfile activates SysRq on boot. This ensures SysRq is always enabled and doesn’t require manual activation after each reboot. - Update GRUB: After modifying the GRUB configuration, running
sudo update-grubapplies the changes and ensures SysRq is enabled at the next boot.
For systemd-based systems (like Arch Linux):
-
Temporarily enable SysRq by running this command as a superuser:
sudo sysctl kernel.sysrq=1 -
Permanently enable SysRq at boot by adding the following line to
/etc/sysctl.d/99-sysctl.conf:kernel.sysrq=1
Verifying SysRq is enabled:
To check if SysRq is enabled, you can press Ctrl+Alt+F2 to switch to a TTY, log in, and press Alt+SysRq+K. If the shell terminates and you return to the login prompt, SysRq is working correctly.
SysRq shortcuts on Lenovo laptops:
On Lenovo laptops, SysRq is often mapped to Fn+S. To use it, hold Alt, press Fn+S, release Fn while holding Alt, then press the desired SysRq key. You may also need to press Ctrl along with Alt, so the full combination would be Ctrl+Alt+SysRq+<command>.
Useful SysRq Commands:
REISUB (for safely rebooting a frozen system):
- R (UnRaw): Resets the keyboard to XLATE mode.
- E (tEminate): Sends the SIGTERM signal to all processes, except
init. - I (kIll): Sends the SIGKILL signal to all processes, except
init. - S (Sync): Flushes data to disk to prevent corruption.
- U (Unmount): Remounts all filesystems as read-only.
- B (reBoot): Reboots the system immediately.
To shut down instead of rebooting, use REISUO (O for shut Off instead of B for Boot).
Other useful SysRq commands:
- F (oom Kill): Triggers the Out-of-Memory killer to free up memory.
- K (saK): Kills all processes on the current terminal.
- L (show-backtrace-all-active-cpus): Displays backtraces for all CPUs.
- M (show Memory usage): Displays system memory usage for diagnostics.
- N (Nice): Lowers the priority of real-time processes.
- O (shut Off): Powers off the system immediately.
- P (show-registers): Displays current CPU register states.
- T (show Task states): Shows the state of all running tasks.
- W (unmount and shoW blocked tasks): Attempts to unmount filesystems and shows blocked tasks.
By automating this configuration through Linutil, the process would be more user-friendly and less prone to error compared to manual edits. Alternatively, a script could be provided to enable SysRq for both GRUB and systemd configurations.
Additional context
Here’s an example of a cheat sheet that could be displayed at the end of the SysRq setup:
Useful SysRq Commands/Sequences:
- REISUB: Safely reboot a frozen system.
- F: Trigger the OOM killer to free up memory.
- O: Power off the system immediately.
Thank you so much for all the hard work you've put into this project. Linutil is an amazing tool, and it’s truly making Linux more accessible and user-friendly. I’ve also suggested a few other features in separate issues that might interest you, and I’d be excited to see any of these improvements considered.
Again, I really appreciate the dedication and effort from the development team. Keep up the great work, and thanks for making the Linux experience better for everyone! 🙌
If this is added a security warning should be added with it, because it can lead to easy unauthorized access to the system from anyone with physical access
/close not planned
This could brick systems if we're not careful, we should also steer away from editing the users bootloader configuration. As this imposes risks.