Using Linux's Magic Sysrq on modern keyboards without a dedicated Syrq key
In the old days, more or less all PC keyboards had a dedicated 'Print Screen/Sysrq' key and using Linux's Magic Sysrq was easy: you held down Alt, PrintScrn/Sysrq, and an appropriate key at the same time. However, this is becoming less and less common all the time, and in particular my current keyboard doesn't have a dedicated Sysrq key. Instead SysRq is overloaded on F9, and you get it by holding the keyboard's Fn key down when you push F9/PrintScrn. This presents a small difficulty in hitting Sysrq key combos, because holding that Fn key down while you hit regular keys often produces absolutely nothing. So if you just press, say, Fn + Alt + F9 + s to try to force a sync, nothing happens.
After some flailing around and unpredictable, intermittent successes, I think I have finally figured out how to use magic SysRq reliably on my keyboard and on similar keyboards without dedicated SysRq keys. The trick is this:
- press and hold Fn + Alt + your SysRq key
- release your SysRq key and Fn, while still holding Alt
- press your desired SysRq action key, such as
The entire sequence has proven to be important. Releasing Fn while
still holding SysRq/F9 down has had a tendency to make the kernel
see an Alt+F9 sequence (which switches virtual consoles and in the
process wipes away a bunch of the messages I want to keep seeing,
and which obviously aborts entering magic Sysrq stuff). Releasing
all three keys ends the whole magic SysRq sequence, which means my
s does nothing.
This turns out to be the suggested approach in the kernel.org guide to magic Sysrq, although their advice is about keyboards that don't like having too many keys down at once. My keyboard specifically appears to do nothing even with just Fn + s, so I don't think it's an issue of the number of keys held down at once. And yes, I used usbmon to verify that my keyboard sends no USB events for Fn + s.
(This is perhaps trivial but I want to documented it for my own future use, because I'm sure I'm going to forget it at some point.)