What's so dangerous about a hard power off?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
carum carvi
Level 5
Level 5
Posts: 538
Joined: Sun Apr 16, 2017 11:44 pm

What's so dangerous about a hard power off?

Post by carum carvi » Wed Aug 08, 2018 6:22 am

Due to a mechanical button problem on my pc I cant use my fysical power button anymore. This has been the case for years now. Therefore I always do a hard poweroff of my system by cutting the powersupply off. For years windows did give warning messages that the powering off went wrong, but it started up nicely anyway. Linux doesnt give any error messages at all after a hard power off, but experienced forum members keep warning about the risk of corrupting the file system by using a hard power off.

What is the danger? And why havent I experienced it yet? Or have I and havent I noticed it yet?

I have read about several alternate key strokes that one can use as alternate for a hard power off. Which one is the best?

gm10
Level 17
Level 17
Posts: 7171
Joined: Thu Jun 21, 2018 5:11 pm

Re: What's so dangerous about a hard power off?

Post by gm10 » Wed Aug 08, 2018 6:33 am

You shouldn't use your physical power button, either. What's wrong with just shutting it down regularly via the menu?

The risk is lost and/or corrupted data. Journaling file systems can usually recover from this, that's why you may have been lucky so far, but it's not a guarantee.
Last edited by gm10 on Wed Aug 08, 2018 6:34 am, edited 1 time in total.

User avatar
Sir Charles
Level 7
Level 7
Posts: 1840
Joined: Thu Jan 04, 2018 1:00 pm

Re: What's so dangerous about a hard power off?

Post by Sir Charles » Wed Aug 08, 2018 6:34 am

I use a custom keyboard shortcut for the command linesystemctl poweroffwhich then will kill off the running processes and unmount the file system or leave it mounted read-only followed by powering off the system.
I suppose that's one of the ironies of life, doing the wrong thing at the right moment -C.C.

carum carvi
Level 5
Level 5
Posts: 538
Joined: Sun Apr 16, 2017 11:44 pm

Re: What's so dangerous about a hard power off?

Post by carum carvi » Wed Aug 08, 2018 7:16 am

I had to add that I cant use the power ON button either. Because it is defect. The fysical powerbutton is broken on my pc.

What I do is the following: I select suspend. And then I cut off the fysical powersupply cable. English is not my native tongue. Other words that are used are called powerstrip, multiple socket, plugbox. Whatever that powerconnection is called, that thing is what I disconnect fysically when powering off and fysically reconnect it again when I want to start up.

It is comparable to an sudden power outage.

It worked till now. But I wondered if there is a safer way to do it. Or is my trick of using suspend and then disconnecting the powerconnection a good compromise regarding the dangers of corrupted filesystems?

gm10
Level 17
Level 17
Posts: 7171
Joined: Thu Jun 21, 2018 5:11 pm

Re: What's so dangerous about a hard power off?

Post by gm10 » Wed Aug 08, 2018 7:28 am

carum carvi wrote:
Wed Aug 08, 2018 7:16 am
Or is my trick of using suspend and then disconnecting the powerconnection a good compromise regarding the dangers of corrupted filesystems?
It actually is, a suspend will flush the buffers to disk.

However, replacing the power button is cheap. Or just find a PC in the trash and take the button from there for free. Might even be that you just disconnected the cables accidentally - those buttons are hard to break. At the end of the day, anything that can close a circuit will do, it's just two pins on the motherboard that need to be connected to initiate a startup.

User avatar
shawnhcorey
Level 3
Level 3
Posts: 199
Joined: Thu Jun 17, 2010 11:23 am
Location: The Great White North
Contact:

Re: What's so dangerous about a hard power off?

Post by shawnhcorey » Wed Aug 08, 2018 8:39 am

In order to save write time, Linux file systems do not write the updates to the directories or i-nodes immediately. This information is located in another place on the disk than where the data is written. Time is saved because the OS does not have to wait for the heads to move back and forth when writing files. (And, of course, this is not required for SSD since they do not have heads but they still use the antiquated system anyway.)

A hard power off will not give the OS time to write the directory and i-node information. This will corrupt the file system.

BTW, when you press the power switch, it does not immediately power off. First, it updates the file system with the pending information and then powers off. But it only updates any pending changes to the i-nodes. Open files are not flushed and closed. This data will be lost.
Don't stop where the ink does.

User avatar
Pepi
Level 5
Level 5
Posts: 849
Joined: Wed Nov 18, 2009 7:47 pm

Re: What's so dangerous about a hard power off?

Post by Pepi » Wed Aug 08, 2018 8:59 am

A new switch is probably easy to find on the internet and easy to install AND in my area we have power failures all the time. I don't but should have a UPS powersupply. I have never had any corruption problems 8)

carum carvi
Level 5
Level 5
Posts: 538
Joined: Sun Apr 16, 2017 11:44 pm

Re: What's so dangerous about a hard power off?

Post by carum carvi » Wed Aug 08, 2018 10:17 am

gm10 wrote:
Wed Aug 08, 2018 7:28 am
Or is my trick of using suspend and then disconnecting the powerconnection a good compromise regarding the dangers of corrupted filesystems?


It actually is, a suspend will flush the buffers to disk.
Great news gm10. Nice to hear that I did something right without knowing it.
Your tip that the powerbutton is just a way to connect two points on the motherboard is new for me too. It sounds simple, but I have never dared to open my pc. And my powerbutton is a "designer" one. Looks very nice, because it has got a blue led light built into it. Looks difficult to me, since I have 2 left hands and will brake anything I touch. And since I am going to buy a new pc soon in the forseeable future I will manage as it goes for now.


ShawnHCorey your explanation about a corrupted file system is clear. But as gm10 stated my "suspend workaround" trick is a good compromise.
But a girlfriend of mine hasnt got suspend. She is completely computer illeterate so I told her to always do a hard power off with the button. She only emails and surfs a bit online. No programs or other valuables installed. But if I understand you correctly her filesystem could still get corrupted because only the i-nodes files are saved with a hard power off, but NOT the directory files? So it is better that I advise her to always do a power off via the menu button? Right?

Pepi too bad about those power outages. I have heard about that from another american forum member too. That is seriously not nice for having to endure. But fortunately your filesystem keeps working nicely too.

gm10
Level 17
Level 17
Posts: 7171
Joined: Thu Jun 21, 2018 5:11 pm

Re: What's so dangerous about a hard power off?

Post by gm10 » Wed Aug 08, 2018 10:29 am

carum carvi wrote:
Wed Aug 08, 2018 10:17 am
Your tip that the powerbutton is just a way to connect two points on the motherboard is new for me too. It sounds simple, but I have never dared to open my pc. And my powerbutton is a "designer" one. Looks very nice, because it has got a blue led light built into it. Looks difficult to me, since I have 2 left hands and will brake anything I touch. And since I am going to buy a new pc soon in the forseeable future I will manage as it goes for now.
It's all quite simple. According to the standard all that you need is to short two headers. Here's an example:

Image

Short 6 and 8 and your system starts. You could hold a screw driver against it for all that it matters.

You'd have to check your motherboard's layout diagram in your board's manual or installation guide to find the location of these headers, depending on the model it would also be printed on the board directly.
carum carvi wrote:
Wed Aug 08, 2018 10:17 am
But a girlfriend of mine hasnt got suspend. She is completely computer illeterate so I told her to always do a hard power off with the button. She only emails and surfs a bit online. No programs or other valuables installed. But if I understand you correctly her filesystem could still get corrupted because only the i-nodes files are saved with a hard power off, but NOT the directory files? So it is better that I advise her to always do a power off via the menu button? Right?
Definitely. A hard power off should be avoided were possible (and unless your kernel crashes it's always avoidable).

carum carvi
Level 5
Level 5
Posts: 538
Joined: Sun Apr 16, 2017 11:44 pm

Re: What's so dangerous about a hard power off?

Post by carum carvi » Wed Aug 08, 2018 10:43 am

Thanks a lot, I will use that advice.

fabien85
Level 7
Level 7
Posts: 1521
Joined: Tue Mar 11, 2014 4:30 pm

Re: What's so dangerous about a hard power off?

Post by fabien85 » Wed Aug 08, 2018 1:28 pm

gm10 wrote:
Wed Aug 08, 2018 6:33 am
What's wrong with just shutting it down regularly via the menu?
+1
This is the number one way to shutdown, and should be the only one in regular situations.

The only reason you may want to use a different method is if your system is frozen.
Then there are several possibilities, in order of the nicest to the most brutal:
- try to relaunch cinnamon (I dont know if it works in Mate and Xfce) : press alt+F2, a box should appear, type r and enter
- try to kill the X server. The shortcut is ctrl+alt+backspace by default
- try to switch to another virtual terminal with ctrl+alt+F2. That should get you to a black screen with text inviting you to login. login will get you to a terminal where you can issue

Code: Select all

sudo shutdown -h now
- if both options were unsuccessful, then your last option is the REISUB trick. (REISUB to reboot nicely, REISUO to power off)
press alt+sysrq, keep them pressed, then press one by one R, E, I, S, U and B (to reboot) or O (to power down), waiting 1 second between each key.
- keep the shutdown button pressed (it's not an option for you, I'm just putting it so that the list is complete)
- the ultimate option is what you do : cut the power supply. Only resort to this if the other options failed.

gm10
Level 17
Level 17
Posts: 7171
Joined: Thu Jun 21, 2018 5:11 pm

Re: What's so dangerous about a hard power off?

Post by gm10 » Wed Aug 08, 2018 1:55 pm

fabien85 wrote:
Wed Aug 08, 2018 1:28 pm
- try to relaunch cinnamon (I dont know if it works in Mate and Xfce) : press alt+F2, a box should appear, type r and enter
It's only Cinnamon that crashes/corrupts and thus needs the shortcut, MATE and Xfce are stable DEs. ;)

carum carvi
Level 5
Level 5
Posts: 538
Joined: Sun Apr 16, 2017 11:44 pm

Re: What's so dangerous about a hard power off?

Post by carum carvi » Wed Aug 08, 2018 1:56 pm

That list is very helpful. Thanks!

Untill now I have always resorted to fysically disconnecting the power cable.

I have just tried to use the Alt+SysRq and pressing REISUB, but maybe I paused to long or too short in between typing REISUB while simultaneously holding those other 2 keys pressed down. That is an acrobatic trick by itself. But it did nothing to my machine. I will try again later and I will post my results because I am glad to read about a less harmful way to reboot my Cinnamon system when it is frozen.

gm10
Level 17
Level 17
Posts: 7171
Joined: Thu Jun 21, 2018 5:11 pm

Re: What's so dangerous about a hard power off?

Post by gm10 » Wed Aug 08, 2018 2:05 pm

carum carvi wrote:
Wed Aug 08, 2018 1:56 pm
I have just tried to use the Alt+SysRq and pressing REISUB, but maybe I paused to long or too short in between typing REISUB while simultaneously holding those other 2 keys pressed down. That is an acrobatic trick by itself. But it did nothing to my machine. I will try again later and I will post my results because I am glad to read about a less harmful way to reboot my Cinnamon system when it is frozen.
You only need to hold Alt down.

If you just need to restart Cinnamon then do the Alt+F2 and then r thing he suggested. If cinnamon is crashed completely then run this from a terminal:

Code: Select all

pkill -HUP -f "cinnamon --replace"
If you cannot even open a terminal window anymore press Ctrl+Alt+F1 to get one, log in there and run the command, then exit and press Alt+F7 to get back to your session.

If you need this often you can place the command into a file, make it executable and place it somewhere in your path. E.g. ~/.local/bin/restart_cinnamon

User avatar
phd21
Level 18
Level 18
Posts: 8722
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: What's so dangerous about a hard power off?

Post by phd21 » Wed Aug 08, 2018 2:39 pm

HI "carum carvi",

I just read your post and the good replies to it. Here are my thoughts on this as well.

1.) There are shutdown applications available as well like "QShutdown" and "KShutDown", etc... in the Software Manager or Synaptic Package Manager SPM

2.) The "hard reset" key combinations are difficult to use but work great, hold down the "Alt" key and while holding that down hold down the "PrintScreen" Key and while holding those down type the characters "reisuo" to shutdown or "reisub" for restart reboot.

3.) Doing a "hard reset", similar to power outages, can corrupt data and file systems on any computer operating system if it was in the middle of writing to the drive(s). Not recommended unless you have no choice.


Hope this helps ...
Phd21: Mint KDE 18.3 & 19, 64-bit Awesome OS, Ancient Dell OptiPlex 780 Core2Duo E8400 3GHz,4gb Ram,256gb SDD, Video: Intel 4 Graphics, DVD Lightscribe. Why I use KDE?:https://opensource.com/life/15/4/9-reasons-to-use-kde

carum carvi
Level 5
Level 5
Posts: 538
Joined: Sun Apr 16, 2017 11:44 pm

Re: What's so dangerous about a hard power off?

Post by carum carvi » Wed Aug 08, 2018 2:46 pm

Thanks for that important detail gm10! Now Alt+SysRq REISUB works great. Now I have to wait till my system gets frozen to really test it.

The other two commands with alt F2 and alt ctrl backspace also work flawlessly, but only do a simple renewed login.

I am gonna use that alt key. keeping it pressed down and then one after the other pressing and releasing : SysRq R E I S U B for a reboot when everyting is frozen.

gm10, your latest added command looks more difficult than the REISUB command. Has it got great advantages or does it do the same trick?




Thanks Phd21 for your software tips. I will check them out. But what you and others described in pressing down both alt AND SysRq keys simultaneously didnt work for my LM19 Cinnamon system. I only had to keep pressing the Alt key down. Then one by one SysRq R E I S U B

gm10
Level 17
Level 17
Posts: 7171
Joined: Thu Jun 21, 2018 5:11 pm

Re: What's so dangerous about a hard power off?

Post by gm10 » Wed Aug 08, 2018 2:49 pm

carum carvi wrote:
Wed Aug 08, 2018 2:46 pm
gm10, your latest added command looks more difficult than the REISUB command. Has it got great advantages or does it do the same trick?
Sure, it only restarts cinnamon while leaving your open application and everything else alone.

carum carvi
Level 5
Level 5
Posts: 538
Joined: Sun Apr 16, 2017 11:44 pm

Re: What's so dangerous about a hard power off?

Post by carum carvi » Wed Aug 08, 2018 3:00 pm

That is sort of what hibernation does? You mean that latest complicated command will reboot your system or will it only do a renewed login to cinnamon?

And then when you re enter via login or when you reboot all your programs are still left untouched as they were before?

So no lost files would be the great advantage, am I right?

User avatar
AZgl1500
Level 10
Level 10
Posts: 3394
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes sweeping down the plains
Contact:

Re: What's so dangerous about a hard power off?

Post by AZgl1500 » Wed Aug 08, 2018 3:02 pm

Marziano wrote:
Wed Aug 08, 2018 6:34 am
I use a custom keyboard shortcut for the command linesystemctl poweroffwhich then will kill off the running processes and unmount the file system or leave it mounted read-only followed by powering off the system.
Would you mind showing how that is done?
I tried to create a kybd shortcut and mine did not work.

User avatar
MintBean
Level 9
Level 9
Posts: 2968
Joined: Fri Aug 07, 2015 6:54 am
Location: Blighty

Re: What's so dangerous about a hard power off?

Post by MintBean » Wed Aug 08, 2018 3:41 pm

Why not just shut down from the menu as has been suggested? That's what everyone else does.

Post Reply

Return to “Installation & Boot”