Difficulty: ★★☆☆☆
This tutorial was created because people are using a hard power off during freezes, so this will teach you how to turn off your computer when everything is frozen using softer means.
So whenever you see someone saying they had to “Power Off” or “Hard Reset” their system without doing a REISUB, please send them here!
If you’re reading this in response to a question, please click the green link above this text to bring you to the full unabridged text of the tutorial.
If you can read this line, you’re all set, and you already are where you need to be!
Please click the ►to expand that section below:
REISUB (reboot)
REISUB (also known as the magic SysRq key ) is a mnemonic for:
-
Rise up (from the dead) if you’re inclined to Zombie movies, like me …
- R eboot E ven I f S ystem U tterly B roken
- R aising E lephants I s S o U tterly B oring
and is a gentle way of rebooting your system by doing the following:
- Switch the keyboard from R aw mode, used by programs such as X11 and SVGALib, to XLATE (translate) mode
- Send an E nd signal (SIGTERM) to all processes, except the boot process, allowing all processes to end gracefully
- Send an I nstant kill (SIGKILL) to all processes, except the boot process, forcing all processes to end .
- S ync all mounted filesystems, allowing them to write all data to disk.
- U nmount and remount all mounted filesystems in read-only mode.
- Re B oot the system
In fact, the only data you lose is since your last [auto]save as the system is shut down gracefully.
Before you read any further, ensure all your work is saved!
How to invoke the REISUB procedure?
First we have to unlock the SysRq key so:
- Add to your grub
GRUB_CMDLINE_LINUX_DEFAULT
thesysrq_always_enabled=1
variable.
OR - Execute
echo kernel.sysrq=1 | sudo tee --append /etc/sysctl.d/99-sysctl.conf
AND - Execute
sudo update-grub
AND - Reboot normally if you had to add one of these parameters and come back here to read the rest of the blurb…
There is a special Sys tem R e q uest key on most keyboards called SysRq on all English language and most international keyboards.
Expand this for the translation for some International keyboards
Stamp (or Stampa on old Olivetti keyboards)
S-Abf
PetSis (maybe also other
keyboards, please confirm)
Feed back in a comment below if you have found yours that is not mentioned here.
- On full-size keyboards, it’s called by pressing Alt+SysRq
- On most laptop keyboards it’s called by pressing Fn+Alt+PrtSc
- On some keyboards, if none of the above Alt combinations work or the SysRq key is missing, please also try:
- Alt+PrtSc
- Alt Gr+PrtSc
- Ctrl+Alt+PrtSc
Once you’ve located your SysRq key, please keep the Alt key pressed.
Now lightly tap these keys waiting between 1 second (fast, new machines) and 6 seconds (older or resource-starved machines¹) in-between keypresses : R E I S U B
There! If you actually followed the above instructions, your system just rebooted gracefully and you did not damage your HDD (if you still have one) by forcing it into PARK mode forcefully nor was your EXT4 or NTFS transaction journal rolled back.
Congratulations!
- For even more info, Read the Fine Manual here
- If a REISUB just restarts your DE just do a REISUO after the REISUB as per feedback from gan. (See next section how to perform a REISUO)
REISUO (Turn off)
- Read the REISUB section above and then you’ll know what this means:
- R E I S U O will turn your machine O ff instead of re B ooting it…
Light tap on power button (<5 seconds)
- Sometimes (If only the UI is frozen), you can still switch to one of the TTYs by pressing Ctrl+Alt+F2 or F3, … and gently tap the power button there.
- To do the same from within your Desktop Environment (DE) this has to be set up beforehand!
So to ensure that your power button effectively shuts down your computer instead of going to sleep / Hibernate / … in the future , follow these steps for your DE:
-
In Gnome:
Details
- Execute the following command:
gsettings set org.gnome.settings-daemon.plugins.power button-power 'shutdown'
-
In KDE:
-
In XFCE:
Details
- Go to the Applications menu or System settings
- Clock Power Manager
- From When Power Button is pressed: select Shutdown.
That’s it! If all of your data is saved, just press the power button lightly and your system will shut down gracefully from now on!
Keep power button suppressed (>5 seconds)
See section “Pull circuit breaker on House / Street / Block” below…
Yank power cord from a laptop without battery or a PC without UPS
See section “Pull circuit breaker on House / Street / Block” below…
Pull circuit breaker on House / Street / Block
Please! Do not do this!
Unless you’re using ZFS or BTRFS and have ensured they use redundancy, you will lose data!
Maybe not the first time, maybe not the second time, but eventually, you will!
Use REISUB, REISUO or a light tap instead!
Happy safe computing!
Note 1: How long you have to wait in-between keystrokes is a function of your hardware speed and how busy a system is. For my laptop it’s 1 second, for servers, I wait 3 seconds but we have been notified that on some resource-starved machines it can take up to 10 6 seconds.