Linux – sysrq won’t reboot with a keystroke, but will with echo “b” > /proc/sysrq-trigger

keyboardlaptoplinuxmagic-sysrq

CentOS 6.2, 2.6.32-220.el6.x86_64 laptop. SysRQ is enabled for keyboard input, as is witnessed by:

$ cat /proc/sys/kernel/sysrq 
1

Common Magic SysRQ Keys are working such as altsysrqh. However, other keystrokes do not appear to be working. Most notably, altsysrqb for rebooting. However, I can get the reboot SysRQ option to work via echo "b" > /proc/sysrq-trigger

I realize that /proc/sys/kernel/sysrq does not need to be enabled in order for echoing options to sysrq-trigger to work, so I'm assuming that there's some problem with the Magic SysRQ key combination actually being signaled.

What would be causing the inability for some SysRQ keystrokes to work, but others not? And yet manually sending the option to sysrq-triggers will work?

EDIT 1

Shamefully, I left out some information in the above question. Yes, I'm using a laptop, but I'm also using an external keyboard. I don't think I've used the built-in keyboard on my Dell XPS 1530 for years so it didn't even register in my mind that the keyboard situation could be part of the issue.

On the Dell XPS 1530's built-in keyboard, the SysRQ key is technically a function key. "SysRQ" is printed in blue to signal that a person, theoretically, should press the Fn key to access it. However, when using the built-in keyboard, you merely have to press the standard altsysrqb combination to cause a reboot! No function key required.

My external keyboard is a Logitech Illuminated Keyboard, and it has its own FN key on it. However, SysRQ is not apparently mapped as an alternate key. I say "apparently" because SysRQ isn't actually printed on any of the keys. Instead, I assumed that Print Screen was the SysRQ key because that's what SysRQ has shared a key with in recent years. That seems to have been a fair assumption because, as I tested things out, most Magic SysRQ key combinations work using that key as SysRQ.

Nevertheless, I've tried a plethora of combinations using the external keyboard, and none of them seem to work with the re[B]oot Magic SysRQ key. I know alt works and I know print screen works as the SysRQ key without need for the function key on the external keyboard. It just appears, at this moment anyway, that the b key is not being sent as be. Is there any way that I can see what key code is being sent to my terminal as I type on a keyboard?

Best Answer

On a typical laptop, you need to press the Fn key to press SysRq. If you also press the letter in the same movement, you end up pressing Fn+Alt+SysRq+letter. But several letters are mapped to numeric keypad keys when combined with Fn. For example, if you try to press Alt+SysRq+U, you end up pressing Alt+SysRq+Num4 instead.

To avoid this pitfall, press and hold Alt, then a press and release SysRq (using Fn if necessary), then press and release the magic SysRq function letter, and finally release Alt. For example: hold Alt, hold Fn, press and release Del, release Fn, press and release U, release Alt.

I'm not sure if that's your problem, as B is typically not a numpad key on laptops. It may be a vendor-specific key; if Fn+B is not equivalent to plain B, then you need to release Fn mid-sequence.

Related Question