• How to properly restart a frozen Linux: SysRq

    I know that Linux works very well on your machine, but when your work is to provide support you’ll probably see some frozen Linux…

    The biggest problem is when a frozen, full screen X application took control over your mouse and keyboard and it seems that the only way to regain access to the system is to force a shutdown.

    This is obviously not an optimal way to get around the problem, as you may suffer serious data loss.

    The first thing to try is to kill just the frozen application. There are normally six text consoles sessions available and one graphics session.
    You can access the consoles by pressing CTRL + ALT + Fx (where Fx is a function key on the keyboard from F1 to F6).
    Once you enter one console, you will be prompted for user name and password. Enter them and then you’ll reach a command prompt.
    Now you can kill the offending process using the kill command.
    To switch back to the graphic session, just click CTRL + ALT + F7.

    If for some reason you cannot access any of the consoles or you simply cannot control the pc anymore, you should try as last resort to perform a “safe reboot” of your OS.

    Since linux kernel 2.1.43 the feature CONFIG_MAGIC_SYSRQ has been added. When the kernel is compiled with this option enabled, it will be able to understand some low level commands that will work most of the times even if you have unresponsive applications that are freezing your machine.
    To send a low level command you must press ALT + SysRq + Command (where “Command” is one of the commands listed at: http://lxr.linux.no/linux/Documentation/sysrq.txt).

    The SysRq/Print Screen key

    To actually reboot the machine there is a well know key sequence to follow: REISUB (or REISUO if you want to turn off the pc instead of reboot).
    Basically, if you keep pressed ALT + SysRq + R and then while you keep pressed ALT + SysRq you press E, I, S, U, B.
    Here you can see an explanation of each one of those commands:

    R: Switch the keyboard from RAW to XLATE mode (take back the control of the keyboard)
    E: Send the SIGTERM signal to all processes except init
    I: Send the SIGKILL signal to all processes except init
    S: Sync all mounted filesystems (this will help avoiding loss of data)
    U: Remount all mounted filesystems in read-only mode
    B: Immediately reboot the system, without unmounting partitions or syncing

    Sometimes the first command “R” doesn’t work at the first time so you’ll have to press it a few times. And it happened once to me that the REISUB didn’t work until I went to a console (as described before, using the CTRL + ALT + Fx combination).

    Hopefully this information will help you!

    Incoming search terms:

    • alt sysrq r restar graphic