in Linux

Linux gets frozen, what do you do?

Somehow, you crashed your Linux. It’s completely frozen. You try pressing Ctrl + Alt + Backspace, but doesn’t help.

What to do? Someone would press the power button and restart or shut down the system. You shouldn’t do this. This can make you a lot of problems.

 

What you can do, is to perform a gentle Linux restart.  This is much safer way to restart your frozen Linux.  To do this, you need to press:

Ctrl + Alt + PrtSc (SysRq) + reisub

Just to make it clear. You need to press and hold Ctrl, Alt and PrtSc(SysRq) buttons, and while holding them, you need to press r, e, i, s, u, b

This will restart your Linux safely.

It’s possible that you’ll have problem to reach all the buttons you need to press. I’ve seen people type reisub with their nose :)

So, here’s my suggestion: With your smallest finger on the left hand, press Ctrl. With your thumb on left hand, press Alt. With the smallest finger on your right hand press PrtSc(SysRq) button. This way, you’ll be able to access to reisub buttons with your other fingers.

Okay, but what this REISUB means? 

  • R: Switch the keyboard from raw mode to XLATE mode
  • 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
  • U: Remount all mounted filesystems in read-only mode
  • B: Immediately reboot the system, without unmounting partitions or syncing

You can find the complete list here. There you can see that shuts down the system. So, if you want to turn off your PC when your Linux crash, you can use this combination:

Ctrl + Alt + PrtSc (SysRq) + reisuo


If you liked the post, we should get connected - follow me on Twitter

Write a Comment

Comment

35 Comments

  1. Note that you should wait a couple seconds after each step (at least after syncing). Also, if you need help remembering the reisub sequence, it’s “busier” backwards :)

  2. It is for real–but the kernel has to be compiled with , “Magic SysRq” support (I think most stock kernels nowadays are), and then it actually needs to be turned on. I think GNOME/Ubuntu have an option for it in the keyboard layout preferences; otherwise there’s a device file in /proc/ you can write to enable it. See http://en.wikipedia.org/wiki/Magic_SysRq_key for more information.

  3. You can do rk instead of reisub, it will kill all thing on the current vt, you can then do ctrl+alt+f1 and change to the vt1 where you have a shell and can fix all the things without a reboot

    • I agree with Aleksander. The first thing I would do is switch to a different virtual terminal to see if I can just restart X. If my machine is still accepting keyboard inputs, then it’s a lot cleaner to just Ctrl+Alt+F1 over and kill/restart xorg.

  4. Note that the “magic sys-rq keys” do not take your keyboard layout into account. Dvorak users, for example, need “p.cogx” instead of “reisub”

    Also, your system might have this disabled. Check the contents of /proc/sys/kernel/sysrq to see (should be either a 1 or a 0).

    • FreeBSD does crash. But it takes so long to do anything, you don’t realize that its crashing. In FreeBSD’s case, the best thing to do would be to use the Windows technique of pressing the restart button. Do this after FreeBSD has finally booted up into XWindows, which can take a looong time. You’ll be fine after that. :p

  5. Install Windows instead. Linux freezes a lot. Unless you don’t install anything at all. Then it freezes a bit less.

  6. Or, just tap the power button.

    If your box is less than ~10 years old and your Linux flavor isn’t strangely configured, it’s a soft power button which will tell the system to initiate a clean shutdown, and bypasses whatever X did to mess up the video and keyboard.

    Some systems have that button configured to initiate a hibernation. Probably a better idea to spend your time changing that from hibernation to shutdown than to do the SysRq enabling stuff.

  7. Linux gets frozen? Are we talking the GUI here? How about launch a tty session, ctl+alt+F1? But then, I’ve never had my Linux frozen, must be an Ubuntu thing. Not with my Slackware. :)

  8. Yikes. Why would you tolerate an OS that requires restarting?

    I am spoiled by WinNT technology (which today’s Windows gets its stability from) as well as Mac OSX. They run for days without crashing.

    I remember Windows ME crashing a lot.

  9. Holding down control is optional, but generally helps prevent you taking a screenshot after hitting the “Print Screen” hey.

    For hitting the keys, I find using my thumb for alt, the edge of my pinky for control, and my middle finger for Print Screen lets me hit all the keys without stretching too hard. (I do this with my right hand… why would you use your left? Keyboard twister? :D)

    You will want to wait 10 seconds after sending the SIGTERM before sending SIGKILL, otherwise you are doing no better than just resetting the power. SIGTERM asks a process to shut down safely by allowing it to do any required housekeeping (like saving files to disk) before exiting. SIGKILL terminates a process immediately. Sending SIGTERM and then immediately SIGKILL can really mess things up as you have basically just told a process to go ahead and do things like writing to disk before then saying “No never mind, die this instant and you are not allowed to do so safely”.

    You also want to wait a few seconds between the kill, sync, unmount, and reboot commands too.

  10. To the people saying to use another operating system… The Linux KERNEL never crashes unless there is a serious hardware problem. Generally when a Linux system “freezes”, It’s generally a driver issue. This is every bit true on FreeBSD and Windows as it is Linux. The main difference with Windows is that there are built-in mechanisms for resetting (or even changing to a generic driver) to make things work again. This does not always succeed either…

    While it would be great if Linux detected this and recovered in a similar way… you can generally do so yourself by switching to a console. (And then doing something like killing X11 and possibly reloading the kernel module if required.)