Jump to content

Halting instead of powering off


Recommended Posts

Hi there.

 

I'm looking to have my Unraid server halt cleanly, instead of powering off.

 

We're having scheduled power outages, and I'd like to halt my machine before an outage happens, so that when power is restored, my server will turn itself back on and function normally.

 

However, looking at the last few lines of `/etc/rc.d/rc.0`, it looks like the server can either be powered off or rebooted. Executing `shutdown -hH now` yields the same result - my server is powered off instead of halting. Running `halt` also powers off. Running `halt -f -h` halts it correctly, but the raid array isn't cleanly shut down.

 

Is there a way to halt my server cleanly, instead of powering off?

Link to comment

The ideal state is that all processes have been stopped and all disks unmounted, as if the server was about to power off - the only difference being that the power is not actually turned off.

 

It's similar to the old way of shutting down Windows 95, where you'd be told "It's now safe to turn off your PC".

 

I've configured my BIOS to turn the server on when restoring after an AC power loss. However, I'm trying to prevent an unclean shutdown from happening. So I'm trying to perform all the steps involved in powering off, just without actually powering off.

 

I  hope that makes it a bit clearer?

Link to comment
5 minutes ago, garbetjie said:

The ideal state is that all processes have been stopped and all disks unmounted, as if the server was about to power off - the only difference being that the power is not actually turned off.

 

It's similar to the old way of shutting down Windows 95, where you'd be told "It's now safe to turn off your PC".

 

I've configured my BIOS to turn the server on when restoring after an AC power loss. However, I'm trying to prevent an unclean shutdown from happening. So I'm trying to perform all the steps involved in powering off, just without actually powering off.

 

I  hope that makes it a bit clearer?

I would have thought that this was the state you are in when you tidily stop the array?

Link to comment

Oh, I think a (fairly significant) part of what I forgot to mention was that I needed to automate this (as the power could go off when I'm at work, and not available to manually shut it down) 🙈

 

ie: 30 minutes before a power outage is scheduled to happen, halt the server. Then, when power is restored the BIOS will bring it online and because everything was shut down cleanly, everything should start up cleanly too.

 

Are you suggesting that instead of trying to halt the whole server, just bring down the array of devices? So that Unraid is still running when the power goes off, but the disks are at least unmounted and the array is stopped?

 

If that is the case, do you have any suggestions on how to do that? I can't seem to find any available API for Unraid.

Link to comment
16 minutes ago, garbetjie said:

Are you suggesting that instead of trying to halt the whole server, just bring down the array of devices? So that Unraid is still running when the power goes off, but the disks are at least unmounted and the array is stopped?

Yes.   In addition to all drives being unmounted at that point the Docker and VM services will also have been shut down, and the User Share sub-system stopped.   Certain system level services such as networking will still be running but it should not matter if power is lost while these are running.   I guess one thing that is still mounted is the flash drive - and whether losing power suddenly san cause a glitch in that area I do not know :(

Link to comment
37 minutes ago, itimpi said:

Yes.   In addition to all drives being unmounted at that point the Docker and VM services will also have been shut down, and the User Share sub-system stopped.   Certain system level services such as networking will still be running but it should not matter if power is lost while these are running.   I guess one thing that is still mounted is the flash drive - and whether losing power suddenly san cause a glitch in that area I do not know :(

That's a way of doing it that I hadn't thought about. Thanks for suggesting that. I think I'll play around with doing it like that - as I don't think I really have another option.

 

Thank you so much for the help :)

Link to comment

Maybe I didn't see it, but have you actually tried in the BIOS in the Power section if you have an option "Restore AC Power Loss" that you could change to [Power On] ? (Instead of [Last State] or [Power Off])

Shutdown the system as needed and when the power cycles the system should turn back on automatically.

 

(I do not know the details of what's happening but personally I would consider putting a UPS in between your Server and the grid, as switching on the grid can be a messy affair electrically speaking with voltage spikes and instability at the beginning. I believe decent UPS can be configured on how long they wait after power has been restored before sending that to your machine. Or maybe you can find some delayed start power strip. If your are electrically inclined you could also build something like that.)

Edited by TobiRh
Grammar
Link to comment

Yeah, @TobiRh. That's what I currently have in the BIOS. The starting up of the server was never really the issue - it was the clean shutdown of it (but without powering off). I found that if I powered it off, the BIOS wouldn't bring the server back up. However, if the server was still on, the BIOS brings it back up.

 

I agree - a UPS would be the best (and I do have one). However, the server is currently in my garage, which doubles as a massage studio for my wife. So I can't have the UPS in there, as it's quite noisy. I may look at some kind of voltage regulator/stabiliser to minimize the potential instability when the power comes back on.

 

It's not ideal, but this is my way of trying to create a starting point that gives me a working server, which can be powered off cleanly and brought back online automatically. 🤷‍♂️

Link to comment
2 hours ago, garbetjie said:

Yeah, @TobiRh. That's what I currently have in the BIOS. The starting up of the server was never really the issue - it was the clean shutdown of it (but without powering off). I found that if I powered it off, the BIOS wouldn't bring the server back up. However, if the server was still on, the BIOS brings it back up.

Okay, that is unfortunate. I pretty sure this is supposed to work like that. Guess not. 🤔

 

A low cost solution might be a Arduino Nano or maybe a delay timer kit from China powered from 5V USB-StandBy.

Put a reed relay in parallel to the power button and also use the power LED as an Input signal.

When 5V come on, a timer starts, and after the set time AND if the power-LED is still OFF then activate the reed relay for 0,5 sec.

Something along this line.

 

As a no-cost-solution, maybe you can do something with Wake-on-LAN from another machine.

If it has to be totally independent, get some el-cheapo router you can put something like OpenWRT on and put it together with the server power. I am pretty sure it can not be to hard to send a Magic Paket from the Router to the server after Router Startup. Instead of the router maybe use some Pi.

Link to comment

I've tested the solution from @itimpi (linked below), and it works perfectly for my needs. I did consider the WakeOnLan solution (using a Raspberry Pi), but this way has fewer dependencies).

 

I first spin down the disks, and then I unmount the array. When power is lost, and then restored, everything starts up fine - no unclean shutdowns, and I can continue using the server just fine :).

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...