thinking out loud [...]by @robertodecurnex

REISUB to the rescue

Since Ubunut 12.04 most of us have been having problems with our machines, they got completely tilt randomly, all the time for some of us, once in a while for others. Everything was so fucked up that not even Ctrl + Alt + F1 (or the FX you like the most) was working, nor the power button associated action (reboot or shutdown).

Common solution: Hold your power button for ~7 seconds, look how your machine power goes off and how everything got violently halt. “Oh no, poor processes! Oh god, protect my hard drives! The buffer… My services… What a mess!”

Do not panic, REISUB came to the rescue.

What is it?

REISUB can be described as a gentle reboot process. It’s name represent the keys involved and the order in which they must be pressed.

There’s a rule to remember these letters, “Raising Skinny Elephants Is Utterly Boring”. Personally, I find easier to remember just REISUB as a weird word.

How can it be executed?

Press and hold Alt + SysRq (SysRqPrintScrn in most of the keyboards) and type REISUB.

REISUB must be typed slowly to let every signal do its work before start the next one. If you type them quickly the reboot will be done but it won’t be so gentle with your processes and hard drives.

How it works?

Alt+SysRq will open a communication channel with the kernel that let you send low-level commands regardless of the machine state.

R Switch the keyboard from raw mode to XLATE mode.

E Send the SIGTERM signal to all processes except PID 1.

I Send the SIGKILL signal to all processes except PID 1.

S Sync all mounted filesystems.

U Remount all mounted filesystems in read-only mode.

B Reboot the system, without unmounting or syncing filesystems.

See why you should do that slowly? Actually you can send some combos:

RE, hold yout fingers a couple of seconds, IS, hold again, U, hold, B.

W@t?

R is “opening the gate” for the rest of the inputs, you can send the next signal right away.

E sends the SIGTERM, which is catched by every process and make, most of them, end their routins cleanly (close communication channels, write buffers, what ever…).

I sends the SIGKILL, making all the processes halt violently, leaving some of the clean up routins unfinished.
If you give enough time between E and I none (or just a few) processes will end dirty.

S will sync your filesystems, writing everything that may be taking a nap in any of the buffers.

U will remount the filesystems as read-only, preventing data loss (information from gettgin lost in the buffers, trying to get into the filesystem) at the moment that the reboot takes place.
Again, giving enough time between S and U will let the Sync process end (every buffer get flushed) before the remount process starts.

B REBOOT, regardless of the system status.
If you don’t give U the time it needs data may get lost in the buffers on their way to a read/write filesystems.

Notes

  • You can replace B with O if your need to shutdown the system instead of reboot it.
  • The complete list of available commands can be found here

Anything not working for you? Something is not very clear? Comment below ↓!

blog comments powered by Disqus

Favourite Readings