My /proc/sys/kernel/sysrq contains the number 502, but Alt+SysRq+... seems not to work on my HP Pavilion laptop. How can I fix that?

Update 1: By the way: neither my print-screen-key nor any other key has an additional label like "SysRq".

Update 2:

  • Hardware model: HP Pavilion 17 Notebook PC
  • Keyboard layout: German, QWERTZ
  • Seems not to work. – Al Klimov Aug 27 '15 at 20:00
  • What exact laptop model do you have, and what keyboard layout? Which keys have you tried? – Gilles Aug 28 '15 at 20:20
  • I've tried the print-screen-key with and without Fn and with and without CapsLock. – Al Klimov Aug 29 '15 at 14:48

Most laptops require pressing Fn to get the SysRq key. Pressing Fn usually doesn't affect the Alt key (at least the left one) but may affect the letter that you press after SysRq. Fortunately, you don't need to press SysRq and the third key together, it's enough to hold Alt down. The following sequence works on all the laptops I've seen:

  1. Press and hold Alt.
  2. Press Fn, press the SysRq key, and release both.
  3. Briefly the letter or punctuation key, e.g. S to sync.
  4. Release Alt.

The SysRq key is usually the same key as PrintScreen. If your keyboard doesn't have a key labeled SysRq or PrintScreen, it may not have a key that sends the scan code that Linux expects. For the purpose of magic SysRq, the SysRq key is whichever key sends the scan code 99.

With a PS/2 keyboard (including a laptop's internal keyboard), to find out what scan code a key sends, log into a text console (press Ctrl+Alt+F1 to switch to a text console, and usually Ctrl+Alt+F7 to go back to the GUI), and run the command showkey -s. showkey -s displays the scan code of each key as you type it. That's usually one byte (two hexadecimal digits) for a key press, then another byte for the key release. For a few keys, you'll get a byte sequence consisting of two bytes starting with e0. Press the key you're interested in, then wait 10 seconds and showkey will exit.

Now that you've identified a scan code, run setkeycodes … 99 as root to assign that scan code to key code 99. For example, if showkey -s prints 0xe0 0x6f 0xe0 0xef for the key you've chosen, run setkeycodes e06f 99.

To make this change permanent, either add the setkeycodes command to /etc/rc.local, or configure udev to change the keycode mappings. Configuring udev is the only solution for a USB keyboard, setkeycodes doesn't affect USB keyboards.

  • Seems not to work. – Al Klimov Aug 28 '15 at 19:04
  • @AlKlimov You need to press the SysRq key. If your keyboard doesn't have a SysRq key, that's obviously a problem. See my edited answer. – Gilles Aug 31 '15 at 0:11
  • I couldn't turn my PrintScreen key, but I could turn e.g. my F12 key. Strange, strange.. – Al Klimov Aug 31 '15 at 16:17
  • Genius! I tried with and without the fn keys so many times, but never thought to hybrid it up with your approach. Thanks! – Adam Plocher Oct 23 '16 at 16:54

I've been using a newer HP pavilion Laptop, same issue. What worked for me, was pressing the AltGr key with the printscreen key

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.