[HOWTO] Magic SysRq keys - more than just REISUB

Post tutorials, HOWTO's and other useful resources here.
User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[HOWTO] Magic SysRq keys - more than just REISUB

Post#1 by Rava » 04 Feb 2020, 16:38

Magic SysRq key
A common use of the magic SysRq key is to perform a safe reboot of a Linux computer which has otherwise locked up (abbr. REISUB).
[…]
● unRaw (take control of keyboard back from X),
● tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
● kIll (send SIGKILL to all processes except init, forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
● reBoot.
Of special interest, especially even prior a system freeze, might be the command "Print a summary of available magic SysRq keys"

To access it only by itself (without any reboot and such), first you need to switch to a Virtual Console (VT), e.g. by pressing Ctrl+Alt+Fn (n could be anything from 1 to the configured numbers of VTs, in Porteus that is usually 6, but that can be adjusted via settings in /etc/inittab.
Cave! Changing the setting via /etc/inittab requires a reboot to take effect.)

Cave! VT7 / dev/tty7 is usually reserved for the X session. When you are in any VT, you can move to other VTs by either press Alt+Fn, e.g. return to X by pressing Alt+F7, or cycle through all available VTs by pressing Alt+{right arrow key} or Alt+{left arrow key} to move up one VT or move down one VT.

Cave! Once you reached VT7 you will switch back to your X Session: any Alt+{right arrow key} or Alt+{left arrow key} will no longer move you between VTs since the keyboard is returned back to the X session. That is also the reason why the reisub command always starts with the "r" command aka "take control of keyboard back from X".

When you have left your X session and entered the VT, you can either log into an unused VT, best as normal user, to not disrupt the tty1 which is in standard config the VT that auto-started the X session, or just use another VT for displaying the info.
Cave! Disrupting the session in /dev/tty1 could - worst case scenario - end in killing the X session, which would result in all X programs to crash, and none of the X programs would be given the chance to auto-save any changes. You have been warned! Therefore I advise you to not play around on VT1 aka /dev/tty1.

I recommend you log into another VT but tty1 as normal non-root user, e.g. by moving to VT2 via Ctrl+Alt+F2, log in e.g. as guest at the VT login, and then press the Magic SysRq key for "Print a summary of available magic SysRq keys", that is "space" by pressing Alt+SysRq+{Space}

Then the kernel will print onto the current VT the info. E.g. for 5.0rc1 Porteus it would print this:

Code: Select all

sysrq: HELP : loglevel(0-9) reboot(b) crash(c) terminate-all-tasks(e) memory-full-oom-kill(f) kill-all-tasks(i) thaw-filesystems(j) sak(k) show-backtrace-all-active-cpus(l) show-memory-usage(m) nice-all-RT-tasks(n) poweroff(o) show-registers(p) show-all-timers(q) unraw(r) sync(s) show-task-states(t) unmount(u) force-fb(V) show-blocked-tasks(w)
(As you can see, all single commands that make up reisub are listed, as should be.)

HTH!
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[HOWTO] Magic SysRq keys - more than just REISUB

Post#2 by Rava » 30 Oct 2020, 22:12

Silly me managed to crash my system just now, and only after applying REISUB the Scroll Lock LED on my keyboard started flashing, but only the Scroll Lock LED - not the Num Lock LED. (Prior to REISUB the system froze and was unresponsive)
I tried to duckduckgo that matter and only found forum posts and one on https://unix.stackexchange.com/question ... -is-frozen - and all these only reported that Scroll Lock LED and Num Lock LED blinking means a kernel crash. Has anyone info what it means when only the Scroll Lock LED was blinking?

Not that it really matters since I had to make a hard reboot anyway, but I love to know.
Cheers!
Yours Rava

Post Reply