Tuesday, December 16, 2008

Reboot or Shutdown Ubuntu Safely When Your System Freezes

Just like any operating system, Ubuntu can freeze up and crash. This does not mean there is something wrong with your system, it just happens. You just need to safely reboot or shut down your machine, in attempt to keep data loss or damage to a minimum.

To safely reboot or shut down Linux when your system freezes use the magic SysRq keys. The magic SysRq keys are a key combination which allows you to perform various low level commands regardless of the system's state. This should prevent a fsck from being required on reboot; it also gives some programs a chance to save emergency backups of unsaved work. You should never just cut the power or remove the battery when your system freezes, these actions can cause unnecessary data loss or the file system to become corrupted.

On most Linux system as well as when using Ubuntu the magic SysRq keys are the Alt and PrintScreen keys. When your system stalls first give your Mini 9 a second to catch up, remember it's a sub $400 netbook and not a super computer. If your computer is frozen and you are unable to regain control of the system:

1. Hold down the Alt and Printscreen keys
2. Enter these keys: R E I S U B, you do not need to capitalize the letters and shift should not be held down
3. The keystrokes should be entered a few seconds apart, 2-4 seconds, allowing for each process to end before starting the next.

REISUB allows you to:
R - unRaw (take control of keyboard back from X),
E - tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
I - kIll (send SIGKILL to all processes, forcing them to terminate immediately),
S - Sync (flush data to disk),
U- Unmount (remount all filesystems read-only),
B - reBoot.

You can replace B with O to shutdown the system.

This article was researched using the Magic SysRq Wikipedia page.

Have a question or problem that this article doesn't cover?
Ask our Ubuntu Mini 9 Google Group for help.


Derek said...

Wow. Thanks for the useful tip. I'm new to the Linux environment, so this could have saved me a headache if I would have known about this about three days ago! Great blog.

Anonymous said...

redDEAD, one can use two more keys:

Alt + Print + K sends all programs of a virtual terminal (normally X) the SIGKILL command to end these programs enforced.

Instead of using Alt + Print + B one can use Alt + Print + O to not restart but shutdown the system.

So the sequence could be: R E I K S U B/O

See http://wiki.ubuntuusers.de/Notfall#Das-System-neu-starten (german) for details.

Kind Regards, FLO

redDEAD said...


There are many commands available when using the magic SysRq keys. To learn more follow the wikipedia link at the end of the article. That one is in english.

Anonymous said...

Most of the time, a ctrl + alt + backspace is enough : you just need to restart X

Pkshields said...

You learn something new everyday. Thanks RedDEAD

ScottC said...

VERY helpful post... Thanks!

John said...

I'm having some trouble using these commands. On the Mini 9, the Prnt Scrn button can only be accessed via first using the fn key. However, when I try out these keyboard commands, the save screenshot window comes up, and leaving the Alt+fn+Prnt Scrn (which is the 7 button) buttons depressed continues to open up numerous more and eats up the physical ram and cpu by opening several of these screens at once.

I have also tried just the Alt+7+..., but this combo does not seem to work either. Which buttons should I be using to enter the R E I S U B commands?


Anonymous said...

Same issue as John above, Hold down Alt, Fn AND 7? I also tried both ways in 8.10 with no response from the Mini 9.

Cobra said...

I really like this blog, but this time you got carried away by your own enthusiasm:

"Just like any operating system, Ubuntu can freeze up and crash. This does not mean there is something wrong with your system, it just happens."

I beg to disagree. The system lock-ups of the Mini (documented, for example, here: http://mydellmini.com/forum/ubuntu-mini-freezes-t969.html) are definitely _not_ something you could just shrug off as being normal. This is not Windows 95, you know? ;) Crashes of applications are one thing, but a complete freeze of your system is quite something else and is always a sign of things going seriously wrong. It's most often caused by faulty hardware such as corrupt RAM, but in the case of the Mini, the freezes completely disappear when upgrading to Intrepid, showing that the problem is related to Dell's original installation. An upgrade to Intrepid seems thus to be highly recommendable (also for other reasons, as you can read in my blog: http://pdes-net.org/cobra/) ;)

That aside, it's certainly nice that people are introduced to the magic sysrq. However, when the screenshot utility appears upon pressing alt-print, it is clear that the keyboard is still functioning. In this case, the magic sysrq is nothing but an overkill, and a simple ctrl-alt-del or ctrl-alt-backspace should suffice.

Anyway: merry chrismas :)

redDEAD said...


I'll say it again in case people haven't figured it out. This blog is about running Ubuntu on the Dell Mini 9 not Mini OS. When your PC crashes you move on. It does it multiple times then you have a problem. Linux is the perfect operating system.

I will agree that ctrl-alt-del or ctrl-alt-backspace is a good option but the article isn't about that.

Derek said...

so to clarify, My system froze recently with no ability to respond to user input such as mouse or keyboard. When I tried the commands, they did not seem to work. Curious if I could even get the commands to work at all, I tried again with a fresh boot when the OS functioned as it should, and the screen capture app was the only response I could get from my mini. Comments or suggestions would be a big help.

Anonymous said...

I prefer the simple mnemonic Raising Skinny Elephants Is Utterly Boring -> R S E I U B

Anonymous said...

I've had the same experience as Derek. An alt + Print Screen does not = SysRq on my Dell Mini 9 with the latest bios. Is there a way to map it to another key?

Anonymous said...

I echo several of the above complaints -- it doesn't work. Did the author even try this on the mini? Would someone who is able please offer a working solution or tell us why it won't work...thanks.

redDEAD said...

The minis key binding conflict with magic SysRq keys. Remove the keybinding in gnome keyboard layout for taking screenshots and it will work.

James said...

Thanks, redDEAD. How exactly do I do that?

Felix said...

You can remove the [Alt]+[Fn]+7(PrntScrn) keybinding by doing the following:

1. Click on Preferences->Keyboard Shortcuts
2. Keyboard Shortcuts window pops up. Scroll down to "Desktop" and find "Take a screenshot of a window."
3. Either disable "Take a screenshot of a window" or change the shortcut (I changed it to Cntl+Print).

[Alt]+[Fn]+7+REISUB worked for me after that on my Dell Mini.

However, it seemed to result in an unclean shutdown (a manual fsck even needed to be performed afterwards) so right now I'm not sure how it's any better than doing a hard reset with the power button?