On occasion, my laptop has become stuck so I've used the magic key combination of Alt + SysRq + REISUB to perform a safe reboot. However, it doesn't seem to work for me as when I press the B key to complete the magic key command it simply says, "resetting..." and doesn't do anything.
All of the other keys seem to work fine as it resets the keyboard layout, kills all tasks etc., but it doesn't seem to complete with a reboot.
I was under the impression that my laptop should reboot after the magic keys have all been pressed in the order of REISUB.
Alt+SysRq has been disabled to fix a bug. The disabling of Magic-SysRq was considered a bug itself and it has since been re-enabled (#1025467). If it is still disabled for you, you can re-enable it:
Ubuntu 12.04 and older
Edit the file /etc/sysctl.conf to include the line
Ubuntu 12.10 and newer
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 #194676).
Keyboards are the issue here!
Tip: try out hitting Shift + Alt + SysRq to see a 'help' output on a virtual terminal. This is useful to see if it's working without doing any harm:
In all cases I've come across it didn't work, swapping the keyboard worked perfectly and showed that nothing was wrong with any kernel setting.
ATTRIBUTIONS:
https://fedoraproject.org/wiki/QA/Sysrq#How_do_I_use_the_magic_SysRq_key which was based on the original work by
Credits
Written by Mydraal
Updated by Adam Sulmicki
Updated by Jeremy M. Dolan 2001/01/28 10:15:59
Added to by Crutcher Dunnavant
https://askubuntu.com/a/11194/102029 mneiss provided links for LaunchPad.
Contents
What is sysrq?
Why does RESIUB(O) not work?
1 How do I get sysrq to behave the way I want?
1.1 What is the magic SysRq key?
1.2 How do I enable the magic SysRq key?
1.3 How do I use the magic SysRq key?
1.4 What are the 'command' keys?
1.5 Okay, so what can I use them for?
1.6 Troubleshoot
1.6.1 Hanging before initscripts get run
1.6.2 Sometimes SysRq seems to get 'stuck' after using it, what can I do?
1.6.3 I hit SysRq, but nothing seems to happen, what's wrong?
1.6.4 I want to add SysRQ key events to a module, how does it work?
1.6.5 Conclusion
1.6.6 APPENDIX
Note.
You may find using Ctrl + F to use the Table of Contents helpful.
What is SysRq?
A common well known and used method of regaining use of machine after it freezing or locking with limitising the risk of disk corruption leading to system file damage or loss of data is to use
Alt + SysRq + r and then s and then e and then i and then u and then b and/or if needed (o)
This has not been working as expected for many (ie myself and James) through all flavours from >= 8.04LTS to current 13.04 release.
Why does RESIUB(O) not work?
Consider this bug description found at LaunchPad Bug 194676:
Ubuntu Developers saw the need to do something about this and the best solution considering the possible complications of the mentioned observation is to apply bitmask 176 sysrq by default creating the need for user input to set sysrq as they desire. Bitmask 176 only allows S, U, B which is sync, remount mounted partitions and reboot.
Reading the full bug report and comments will highlight some options that may be applicable to your system.
The accumulative affect of different hardware, kernels, keyboards and bitmasks mean sysrq is behaving differently for different people.
One method of getting txt output regarding how your system is using sysrq is to apply sysrq commands from tty (when system not suffering from locks/freezes). Doing this may indicate sysrq has not been completely disabled but is using bitmask 176.
Searching for /proc/sys/kernel/sysrq on a 13.04 Desktop amd64 liveDVD and an 13.04 Desktop amd64 install confirms the default is currently to leave sysrq at bitmask 176.
If sysrq does work for you; it may be worth asking, "If i did not change 10-magic-sysrq settings then; Who did.?"
1 How do I get sysrq to behave the way I want?
What follows is an edited copy and paste of https://fedoraproject.org/wiki/QA/Sysrq.
1.1 What is the magic SysRq key?
It is a 'magical' key combo you can hit which the kernel will respond to regardless of whatever else it is doing, unless it is completely locked up.
1.2 How do I enable the magic SysRq key?
sysrq is built into Ubuntu kernel but is disabled at boot time, by default, using 10-magic-sysrq.conf.
To re-enable it at boot time, you have to edit /etc/sysctl.d/10-magic-sysrq.conf file. ie uncommenting this line will enable all functions of sysrq:
When running a kernel with SysRq compiled in, /proc/sys/kernel/sysrq controls the functions allowed to be invoked via the SysRq key. Here is the list of possible values in /proc/sys/kernel/sysrq:
You can set the value in the file by the following command.
So to fully enable it would be.
Or also can enable it by doing.
Note.
The value of /proc/sys/kernel/sysrq influences only the invocation via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always allowed (by a user with admin privileges-see below).
1.3 How do I use the magic SysRq key?
Ubuntu Desktop
You press the key combo Alt + SysRq + command key.
N.B.- See the notes in this section and in the Troubleshooting section for other possible default settings for other systems and keyboards.
It is possible to set any character of your choosing:All Architectures
Write a character to /proc/sysrq-trigger:
would set the T behave as SysRq
Note.
Some keyboards may not have a key labeled SysRq. The SysRq key is also known as the Print Screen key. Also some keyboards cannot handle so many keys being pressed at the same time, so you might have better luck with Alt + SysRq - SysRq then press command key then release everything. See the full writing of QA which this guide is based on https://fedoraproject.org/wiki/QA/Sysrq#How_do_I_use_the_magic_SysRq_key.3F for more information regarding this.
1.4 What are the 'command' keys?
Note.
See important comments below in SAK section.
1.5 Okay, so what can I use them for?
Unraw is very handy when your X server or a svgalib program crashes.
Sak (Secure Access Key) is useful when you want to be sure there is no trojan program running at console which could grab your password when you would try to login. It will kill all programs on given console, thus letting you make sure that the login prompt you see is actually the one from init, not some trojan program. Others find it useful as (System Attention Key) which is useful when you want to exit a program that will not let you switch consoles. (For example, X or a svgalib program.)
Note.
In its true form it is not a true SAK like the one in a c2 compliant system, and it should not be mistaken as such.
Reboot is good when you're unable to shut down.
Note.
It's general considered a good practice to umount first
Crashdump can be used to manually trigger a crashdump when the system is hung.
Note.
The kernel needs to have been built with CONFIG_KEXEC enabled!
Sync is great when your system is locked up, it allows you to sync your disks and will certainly lessen the chance of data loss and fscking.
Warning
The sync hasn't taken place until you see the "OK" and "Done" appear on the screen. (If the kernel is really in strife, you may not ever get the OK or Done message.
Umount is basically useful in the same ways as Sync.
The loglevels 0-9 are useful when your console is being flooded with kernel messages you do not want to see. Selecting 0 will prevent all but the most urgent kernel messages from reaching your console.
Note.
They will still be logged if syslogd/klogd are alive
Term and kill are useful if you have some sort of runaway process you are unable to kill any other way, especially if it's spawning other processes.
Note.
When experiencing bad kernel panic do Alt+Sysrq+e then Alt+Sysrq+u then Alt+Sysrq+i and finally Alt+Sysrq+b
1.6 Troubleshoot
1.6.1 Hanging before initscripts get run
If the machine is hanging before the initscripts get to run, boot with
sysrq_always_enabled=1
1.6.2 Sometimes SysRq seems to get 'stuck' after using it, what can I do?
Tapping shift, alt, and control on both sides of the keyboard, and hitting an invalid sysrq sequence again will fix the problem. (i.e., something like alt+sysrq+z).
Switching to another virtual console (Ctrl+Alt+Fn1-Fn6) and then back again Ctrl+Alt+Fn7 should also help.
1.6.3 I hit SysRq, but nothing seems to happen, what's wrong?
There are some keyboards that send different scancodes for SysRq than the pre-defined 0x54. So if SysRq doesn't work out of the box for a certain keyboard, run
showkey -s
to find out the proper scancode sequence. Then usesetkeycodes <sequence> 84
to define this sequence to the usual SysRq code (84 is decimal for 0x54). It's probably best to put this command in a boot script.Warning
You exit
showkey
by not typing anything for ten seconds.1.6.4 I want to add SysRq key events to a module, how does it work?
In order to register a basic function with the table, you must first include the header
include/linux/sysrq.h
, this will define everything else you need. Next, you must create a sysrq_key_op struct, and populate it with...The key handler function you will use.
A help_msg string, that will print when SysRQ prints help
An action_msg string, that will print right before your handler is called. Your handler must conform to the prototype in 'sysrq.h'
After the sysrq_key_op is created, you can call the kernel function register_sysrq_key(int key, struct sysrq_key_op *op_p); this will register the operation pointed to by 'op_p' at table key 'key', if that slot in the table is blank. At module unload time, you must call the function unregister_sysrq_key(int key, struct sysrq_key_op *op_p), which will remove the key op pointed to by 'op_p' from the key 'key', if and only if it is currently registered in that slot. This is in case the slot has been overwritten since you registered it.
The Magic SysRq system works by registering key operations against a key op lookup table, which is defined in 'drivers/char/sysrq.c'. This key table has a number of operations registered into it at compile time, but is mutable, and 2 functions are exported for interface to it the register_sysrq_key and unregister_sysrq_key. Of course, never ever leave an invalid pointer in the table. ie; when your module that called register_sysrq_key() exits, it must call unregister_sysrq_key() to clean up the sysrq key table entry that it used.
Note.
Null pointers in the table are always safe.
If for some reason you feel the need to call the handle_sysrq function from within a function called by handle_sysrq, you must be aware that you are in a lock (you are also in an interrupt handler, which means don't sleep!), so you must call __handle_sysrq_nolock instead.
1.6.5 Conclusion
Use Alt + SysRq + S and then U and then B to sync, attempt to remount all mounted filesystems and then reboot if needed. Without changing a thing to system files.
If Alt + SysRq + B does not reboot system it may be necessary to edit /etc/sysctl.d/10-magic-sysrq.conf in order to allow the attempt of applying Alt + SysRq + B (or/and O after editing /proc/sys/kernel/sysrq bitmask to enable the reboot and shutting down of the system by use of sysrq. You could do this by any of the methods described above.
1.6.6 APPENDIX: See also - http://ubuntuforums.org/showthread.php?t=617349 and https://www.kernel.org/doc/Documentation/sysrq.txt
For those with Apple MacBook keyboard troubles regarding sysrq see: https://help.ubuntu.com/community/AppleKeyboard and https://bugs.launchpad.net/mactel-support/+bug/262408
Relative interesting info-After watching 17 08 2013 episode of the BBC programme "Click" and the "cyberwarfare" article really caught my attention. The programme also have their own website Click if you can not watch the programme. FAWC
I ran into this the other day and it took a few seconds to work. I may have even done the entire REISUB sequence twice.
Also, make sure you're using the sysrq key (most laptops will require you to hold down function, so you're really holding down 4 keys at once)
A few years back I used to use Alt+SysRq+S,U,B,O to reboot or power off a stuck machine, because like for you, Alt+SysRq+B sometimes didn't want to work.
(Also, I need to get into the habit of using Alt+SysRq+E,I first. I don't see much point of using Alt+SysRq+R, since why does keyboard mode matter if it's going to reboot and reset it anyway?)
Make sure you are holding
alt
while pressingprint screen
+reisub
. In my computer, if I pressalt
+print screen
and release all buttons, then pressreisub
, it doesn'treboot
my computer. Pressingalt
and hold it, then press the other keys works. Hope it helps others.