Skip to end of metadata
Go to start of metadata

ubuntuforums

The magic SysRq keys are key combinations within the Linux kernel that allows the user to perform various low level commands regardless of the system's state, except during kernel panics or freezes. It is often used to recover from X-Server freezes, or to reboot a computer without corrupting the filesystem.

You will need to keep holding the sequence keys for a small period of time before going to the next one so that their actions can be carried out properly

Restarting Ubuntu safely when it is frozen

Alt+SysRq+R+S+E+I+U+B

Raw (take control of keyboard back from X), tErminate (kill -15 programs, allowing them to terminate gracefully), kIll (kill -9 unterminated programs), Sync (flush data to disk), Unmount (remount everything read-only), reBoot.

Safely shutting down Ubuntu when it is frozen

Alt+SysRq+R+S+E+I+U+O

shutdOwn

Brief descriptions about the keys you can use in magic SysRq sequences

0 - 9 - sets the console log level, controlling which kernel messages will be printed to your console so that you don't get flooded.

B - restarts the system without making steps to ensure that the conditions are good for a safe reboot, using this key alone is like doing a cold reboot.

E - sends SIGTERM to all processes except init. This means that an attempt is done to end the current processes except init, safely, e.g. saving a document.

F - call oom_kill(Out Of Memory Killer), which will kill a process that is consuming all available memory.

H - displays help about the SysRq keys on a terminal though in actuality you can use any key except for the ones specified, to display help.

I - sends SIGKILL to all processes except init. This means that all the processes except for init are killed, any data in processes that are killed will be lost.

K - kills all processes on the current terminal. It is a bad idea to do this on a console where X is running as the GUI will stop and you can't see what you type, so you will need to switch to a tty after doing the magic SysRq.

L - sends SIGKILL to all processes, including init. This means that every process including init will be killed, using this key will render your system non-functional and no further magicSysRq keys can be used. So in this case you will have to cold reboot it.

M - dumps memory info to your console.

O - shuts down the system via ACPI or in older systems, APM. As in key "B", using this key alone is like a cold reboot(Or in this case, a cold shutdown).

P - dumps the current registers and flags to your console.

Q - dumps all timers info to your console.

R - takes keyboard and mouse control from the X server. This can be useful if the X-Server crashed, you can change to a console and kill the X-Server or check the error log.
NOTE:- The documentation refers to this key's task as "Turns off keyboard raw mode and sets it to XLATE", but I suppose it's safe enough to assume that it takes back control from X.

S - writes all data from the disc cache to the hard-discs, it is a sync and is necessary to reduce the chances of data corruption.

T - dumps a list of current tasks and info to your console.

U - remounts all mounted filesystems read-only. After using this key, you can reboot the system with Alt+SysRq+B without harming the system.

W - dumps uninterruptable (blocked) state tasks.

  • No labels