[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

72 Likes

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:

10 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…

8 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).

6 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.