How do I use REISUB with an Apple slim aluminum keyboard?
I'm using the Apple slim aluminum keyboard, which doesn't have the SysRq key:
What key(s) should I press for the magic SysRq key when I need to type REISUB?
Solution 1:
This answer also posted here.
After 3 or 4 hrs of hard searching, reading, and trial and error, here's a more thorough and generic answer which should work for any Apple/Mac laptop or keyboard, not just the "Apple slim aluminum keyboard." In my particular case, however, I'm using this solution for a 2008 MacBook white running Xubuntu 16.04 LTS.
Many thanks to Bengt Olsson for his excellent instructions here which gave me the necessary start to figure out the missing details.
This solution is done in the user space, and does NOT require recompiling the kernel like some suggestions.
-
Download source for keyfuzz, and extract it (I can right-click it and go to "Extract Here" to extract it in my GUI file manager, for instance). To read more about keyfuzz, see here. It is released under the GNU GPL 2.0 or later open source license (yaaay open source!).
- Dont' use a directory too deep (or with spaces possibly) or else the
./configure
command below will fail.
- Dont' use a directory too deep (or with spaces possibly) or else the
-
Install dependencies, or else running
./configure
below may spit out some errors:sudo apt-get update sudo apt-get install lynx xmltoman gengetopt
-
Compile and install keyfuzz with the usual commands:
./configure make sudo make install
-
Navigate to
/dev/input/by-id
and find your Apple keyboard that ends in-event-kbd
:cd /dev/input/by-id ls
For me it's:
usb-Apple_Computer_Apple_Internal_Keyboard___Trackpad-event-kbd
-
Add the following line to your
/etc/rc.local
file, to cause this command to run each time your computer boots up and loads this user. Notice we are using the Apple keyboard entry we just found above. This command uses keyfuzz to map F12 or F13 on your Apple keyboard or laptop to the system "Magic SysRq key", for soft reboots.- To map F12 to SysRq:
458821 99
. Many thanks to "pjjjv" for figuring that out here! - To map F13 to SysRq:
458856 99
. - Since my MacBook 2008 does not have F13, I am using the F12 option above. Also remember to use your proper keyboard entry we found above. The command I added to
rc.local
for my case is:echo "458821 99" | keyfuzz -s -d /dev/input/by-id/usb-Apple_Computer_Apple_Internal_Keyboard___Trackpad-event-kbd
- Here is my entire
/etc/rc.local
file, with the appropriate entry:#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. echo "458821 99" | keyfuzz -s -d /dev/input/by-id/usb-Apple_Computer_Apple_Internal_Keyboard___Trackpad-event-kbd exit 0
- To map F12 to SysRq:
-
Reboot.
Now I can press Alt+F12 (or you can use Alt+F13 as described above) and issue REISUB to soft-reboot your computer. Works perfectly on my MacBook 2008 laptop running Xubuntu 16.04 LTS.
Note that you can see the results returned by issuing REISUB as you press each key by first jumping to an alternate session with Ctrl+Alt+F1 (F1 through F6 work actually) before issuing the command. To get back to your main X Window session use Ctrl+Alt+F7.
If you get a result that says
This sysrq operation is disabled
that's normal for several of the commands, as they pose a potential security risk. The Boot one should still work, however, allowing you to soft-reboot your computer. Here is some more information on this, from mniess here:
Starting with Ubuntu 12.10 a more fine-grained control of which Magic- SysRq features are enabled is possible. Just edit the file /etc/sysctl.d/10-magic-sysrq.conf.
The file is well documented and tells you exactly how to enable which features. The current default was picked for security purposes and should only be changed if you know why you need to (for security implications see bug #194676).
Solution 2:
Just did this. If you don't want to recompile the kernel like suggested in the first link of the first answer, there is a simpler way. It's kind of outlined in the second link of the first answer, but here is the actual procedure:
Download source for keyfuzz
-
Compile and install with the usual commands
./configure make sudo make install
-
Add the following line to your /etc/rc.local file:
echo "458856 99" | sudo /usr/local/sbin/keyfuzz -s -d /dev/input/by-id/usb-Apple__Inc_Apple_Keyboard-event-kbd
Now it should be possible to press Alt+F13 and issue REISUB. Worked on my Xubuntu 15.10.
Solution 3:
I don't have an alu keyboard on hand to test this, but: