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
Best Answer
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:
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 withe0
. Press the key you're interested in, then wait 10 seconds andshowkey
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, ifshowkey -s
prints0xe0 0x6f 0xe0 0xef
for the key you've chosen, runsetkeycodes 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.