[Tip] Enable Magic SysRq Key (REISUB)

The Linux kernel authors have provided a very nice feature of issuing low-level commands to the kernel directly, regardless of the state the system is in. This is called the “Magic SysRq Key”, because these commands are issued by pressing the SysRq key on the keyboard (if you can’t find it, typically, it shares the same physical key as the Print Screen key, but on some laptops it can be elsewhere).

A common use is to reboot when the computer freezes and becomes unresponsive due to some software or hardware exception, without having to push the hardware reset button or to cut power to the computer, which runs the risk of corrupting the filesystem and does not give the chance to processes which are still responsive to terminate gracefully. The magic SysRq key lets us do this elegantly and safely.

On EndeavourOS, like on vanilla Arch, this functionality is disabled by default, because it is a potential security concern (however, since it requires physical access to the keyboard, it’s not a big security concern). This is how you enable it:

  • Run this command in the terminal:

    echo 'kernel.sysrq=1' | sudo tee /etc/sysctl.d/99-reisub.conf 
    

    This will create the file /etc/sysctl.d/99-reisub.conf, containing the single line kernel.sysrq=1 (it does not have to be named 99-reisub.conf, but the name is good because you’ll know what it does, it is the location of the file and its contents that are important). Alternatively, you can create this file using a terminal-based text editor, like vim or nano with sudo.

  • Reboot for the change to take place.

  • If you want to disable this functionality, just remove the file created in the first step (sudo rm /etc/sysctl.d/99-reisub.conf)

Now, when you want to hard-reboot the computer, perform the following key combination:
press and hold the Alt key the entire time. Now, one after another, with about a second in between, press (tap) the following keys: SysRq, R, E, I, S, U, B. Your computer should reboot if everything was done correctly (you can let go of the Alt key now :wink: ).

This sequence issues the following low-level commands to the kernel:

  • R = Switch the keyboard from raw mode to XLATE mode
  • E = Send the signal SIGTERM to gracefully terminate all processes (except PID 1)
  • I = Send the signal SIGKILL to kill all processes that didn’t terminate gracefully
  • S = Sync data to disk (flush)
  • U = Unmount the filesystem (and remount as read-only)
  • B = Reboot

Just remember that the letters spell REISUB (a good mnemonic is “Reboot Even If System Utterly Broken”).

For more info, see:
https://wiki.archlinux.org/index.php/Keyboard_shortcuts#Kernel

https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html

99 Likes
[root] Update your system the smart way
KDE Plasma - System freezes
Is there a "safe shutdown" like on Windows?
Complete freezes .... Serious problem
System not freeing up memory/Programs continually using up more and more memory
Warning: The root device is not configured to be mounted read-write!
KDE keeps freezing
Continuous system freezes
Endeavour OS ISO download?
Optimising Stability
Successful conversion to Pipewire (finally)
No sound after forced reboot
System doesn't reboot or shutdown, just hangs instead
[SOLVED] Random reboot
The notebook does not run very stable and robust: on console no reaction with yay - what to do now?
The notebook does not run very stable and robust: on console no reaction with yay - what to do now?
How can I kill a process when ram reaches 100% and renders the system unresponsive?
Live no internet unable to install
System Freezes, no CTR+ALT+F*
EndeavourOS boot stuck after forcefully shutting it down
Stuck on default screen, desktop didnt display enter pass
When left idle, Endeavour shuts down and have to unplug computer to restart/
Your "Plan B" Backup System?
Freeze again and again - Update Notifier?
Screen freezes / unable to input
KDE interactions freeze entire system
Budgie Broken Login Screen
Serious Error - Twice
Unbootable OS, long error list
Problem while going into suspension mode in my Desktop computer
Black Screen issue (similar to Win blue screen but without text)
OS crashed. Must I install other kernel?
System locks up
Maple syrup, smoked maple thickcut bacon, and coffeecrisps, mmm! Oh, sorry, and howdy ya'll! I'm from Canada, eh?!
After updating the Gnome boxes, the crashes are constant
Can't mount my external hdd
Input lag on desktop
System randomly freezes
Problem with blizzard games
How to open the task manager and how to prevent EndeavourOS from getting stuck/freezing
Laptop "freezes" randomly
How to set up cron job for auto update?
Freeze after hibernation with LUKS & XFS -> corrupted partition
Not shutdown on Dell XPS 9315
No wifi (again) after a hard crash
Trying to enable oom_killer
Restarting -> stop job for user running!
Black screen, but cursor is still there, plus tty access
How come it takes more than a minute to shutdown or reboot the system?
How come it takes more than a minute to shutdown or reboot the system?
How come it takes more than a minute to shutdown or reboot the system?
Black Screen Resuming from Suspend AMD 6850U
Crash after sleep or suspend
Sudden Blackscreen - How to debug?
Stuck at systemd-boot
EOS completely freezing up and having to reboot using power switch
Sometimes Left mouse click doesn't work
Wifi card not registered after boot
System does not load after sleep
Kernel oops while "multitasking"
System becomes unresponsive shortly after boot
Why then I try to see a video on full sceen the screen freezes and I can't do anything forcing me to do an "hard reboot"?
System wont boot, stuck at "Notify about reboot on special conditions"
Two Games Crash My System Forcing Me To Shutdown
Libreoffice causes my System to freeze?!
A weird XFCE desktop disappear when return from tty2
Laptop occasionaly fails to wake from sleep
Sometimes, Endeavour OS stops opening new applications
Black screen of doom after reboot. Failed to mount /sysroot
[SOLVED]Two Questions About Acer Swift X Computer
Easily restart KDE!
RX 7800 XT issues after updating to kernel 6.7
Sleep function works, no Graphics Waking Up
Testing Plasma 6 (Beta) on Endeavour OS - is this approach any good?
How to run a stress-free EndeavourOS
System doesn't start after interrupted update
Blank screen after force shutdown
Lost sound then stuck to console with mouse cursor
Freeze on shutdown
Can't terminate a process except by a full system shutdown
Am I missing something? Talk me out of EndeavourOS if I am!
Xorg Blocking on EndeavourOS Linux
High settings freeze all the pc
Do I need to constantly maintain EndeavourOS?
Is it normal for endeavouros to crash so much?
Reisub 'enabled' in Welcome what next?
Dolphin freezes when changing theme
For those seeking help - SYSTEM LOGS, please
Cannot locate recently installed program
System/Computer won't fully shutdown
Wake from Sleep/Standby/Hibernate - Blank Screen
Kernel Panic!
Shut down issues
Desktop is freezing and I cannot pinpoint the issue
Black screen during boot, stuck cursor + having sounds in the black screen
Wake from Sleep/Standby/Hibernate - Blank Screen
Xmonad won't start after hard shut down
Is it okay to shutdown the laptop using poweroff button while it is booting? will it bring any damages to the file system/files?
What are you listening to right now?
Lock screen frozen
Programing app Gtk in plasma using C VSCODE Compile errors
Task kworker blocked (cannot use system)
Poweroff gets stuck with "A stop job is running for ..." messages
KDE Plasma gets stuck sometimes
General Tips & Advice For New Users
Bootloader gone after EndeavourOS update

That’s some low-level right there! :frog:

3 Likes

Or, as I learned many, many years ago: REISUB = Raising Elephants Is So Utterly Boring. :elephant:

13 Likes

Great hint and thanks for the link to the wiki.

I found there other possibility, just:

add sysrq_always_enabled=1 to your kernel parameters.

Looks even more easy and reliable to me. Any reason why you prefer the other way?

You guys are looking at it all wrong… it’s just what you do when the system is BUSIER than you want. Or maybe I’m just backward…

13 Likes

Thank you for this! I’ve been meaning to enable this on all my computers because occasionally I eat up all my ram and swap space leaving a frozen system.

1 Like

You can do it like that, too. It makes little difference in practice. The way I explained it in the OP is how I did it for many years on all of my computers. It works fine and I can instantly know whether I have it enabled or not, by looking if this file exists.

Also, just creating a new file is much easier and shorter for a tutorial (and easy to automate in one command), rather than explaining how to edit GRUB config to add a kernel parameter (and much less prone to mistakes).

Besides, I don’t see any benefit from enabling SysRq via kernel parameter. Yes, it allows you to reboot your computer before drives have been mounted, but if your drives fail to mount, you can just power off the computer using the power button like a complete savage, since there is no risk of corrupting your filesystem (since it isn’t mounted anyway).

7 Likes

For a more complete overview, you could add the link to the kernel documentation: https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html

4 Likes

Thanks for the link, added it to the OP.

2 Likes

One passing thought about adding kernel parameters… some of us don’t use grub - so editing to add a kernel parameter is just as easy as adding a file - and more easily found :grin:

1 Like

Well, do what you like, it’s your system. Nothing wrong with enabling it via kernel parameter. I don’t see a benefit to it, but there is also no downside. :man_shrugging:t3:

2 Likes

No downside - and the upside that I don’t have to remember where to put it! /boot is always easily found… :grin:

Appreciate the reminder of how to access it - although the key to activate it can be hard to figure out these days. I THINK it’s the Pause/Break key on my system, but I haven’t had to REISUB for a long time (btw, I use…)

3 Likes

It would be a good idea to test it, to make sure it works and that you know how to use it. I’d first log out of the GUI session and do it on the login screen. Or in the TTY.

1 Like

Yup - probably should do that. Especially as this case I built into doesn’t even have a reset button! (hijacked for RGB control). Maybe on the reboot after updating - I see the count for updates has just reached 25…

Great post…unfortunately my workhorse (Asus 531GT ROG STRIX) hasn’t even got the SysRq key! I suppose I could plug a USB one in to try though :slight_smile:

It should be the same as Print Screen (PrtSc)

1 Like

Strangely enough - that works for my desktop too (PrintSc) - just tested it! Now there’s a way to get out of Xubuntu Rolling Rhino too (without leaning on the power button for 5 secs or so)!

Yes, precisely as it is stated in the first paragraph in the OP.

1 Like

I hear you…but it doesn’t do anything other than fire off a screenshot. Tried with FN+PrtSC, and Ctrl+prtsc, no difference. Oh well…

I guess I have to add more :grin:s to my posts… I meant to be laughing at my out-of-date assumption of pause/break having that function.