NUT, set iPfire "on hold", then automatic reboot and/or boot after power failure

Hi!

As I am a noob about UPS stuff, I may now come with silly questions. So take a deep breath :slightly_smiling_face:

Background
On my Qnap NAS the manual tells I have two options for what happens when the UPS tells the NAS that there is a power failure:

  1. Power off: If the NAS is powered off, it will remain off after the power is on again.

  2. Auto-protection mode: If the NAS is in auto-protection mode, all normal service’s gets disabled and it stops writing to the disc, then it will resume to normal operation after the power is on again.

Auto-protection mode

  • a) If it has not yet been powered off, the UPS batteries have not run out of charge, the system automatically resumes to its previous state (or reboots, it seem to be different depending on the Qnap model). On my both NAS in the GUI it say “*Auto-protection: the NAS will stop all running services and unmount all volumes to protect your data. When the power restores, the NAS will reboot and resume to its previous state.”

  • b) If the UPS batteries run out of charge and cuts power to the NAS, the BIOS setting (or system settings) automatically resumes the system to its previous state, eg. it boots up again, when power is restored (if BIOS is set up to resume previous state, eg. turned on, in this case).

I was thinking I would use the NAS as the Primary (connected with USB to the UPS) and my main and backup iPfires as secondaries that get info from the NAS.

Problem
When i read the Wiki * Network UPS Tools (NUT)

  • Detailed NUT Configuration I believe there is in upsmon.conf the setting SHUTDOWNCMD “/sbin/shutdown -h +0” that the wiki say “this command will be triggered if UPS sends the BL (Battery Low) flag.” and as I understand it will shutdown the system and turn it off.

When power is on again, it will stay off as that was the last state after power loss as I willfully turned it off. I have not found a BIOS settings on my iPfire PC to always turn on when AC power is resumed, but my BIOS is set up to resume previous state. Even if I could in BIOS set it to “always turn on when AC power is resumed”, it would not work it it turns it self off and power failure resolves before the UPS batteries have run out of charge.

What I would like
Somehow replace “/sbin/shutdown -h +0” with something that puts the system “on hold”, disables services (maybe only one process that monitors NAS and reboots?) and stops reading/writing to hard drive, and if the UPS via the NAS says power is on again it reboots the system (or resumes to normal state if that is possible).

If the UPS batteries run out of charge and cuts power, the BIOS setting “Restore previous state on AC/Power Loss” will boot the system.

So even if there is a short or long power failure, the iPfire will be safe and always boot up again.

Is that possible somehow?

Shutdown + WOL when power come back?

1 Like

Blockquote Pikepike_it Shutdown + WOL when power come back?

Yes, that or just push the power button works, when I am at home. But when I am not home, which is quite often, I need iPfire to VPN in to do the WOL.

My solution right now is to shut down the primary iPfire and all NAS etc, but keep my secondary iPfire on. If the UPS don’t run out of battery it is still on, and if the power was cut to it, it starts up when it has power again. Then I use it to VPN in and WOL all other devices to life.

But, I feel the secondary iPfires eyes on me, and know that it does not understand why I am willing to sacrifice it so that the others may live on. So for us to continue to have a good relationship, where its life is not in danger, a solution would feel good.

I have today tried to figure out how the auto-protection works on Qnap NAS, and I guess QNAPs in auto-protection mode are in single-user mode and can still talk to the UPS and each other. But I don´t really know if it uses single-user mode, or understand how that mode works, or if it could be a solution on iPfire.

EDIT: On my secondary NAS with the setting auto-protection (not connceted with USB, but via network to the primary NAS UPS) In /etc/config/uLinux.conf I found this
[UPS]
Support = TRUE
Serial UPS = FALSE
Snmp UPS = TRUE
Daemon Type = 3
UPS IP = 192.168.0.1
Enable = TRUE
UPS Type =
Shutdown System In = 2
ValidCOM = 1
AC Power = OK
Battery Power = OK
Server Mode = FALSE
Power Loss Mode = Standby
Standby System In = 2
Enable Network UPS Server = FALSE

The other NAS with the setting Shutdown has this
[UPS]
Support = TRUE
Serial UPS = FALSE
Snmp UPS = TRUE
Daemon Type = 1
UPS IP = 0.0.0.0
Enable = TRUE
UPS Type = PhxTec-A1000
Shutdown System In = 3
ValidCOM = 1
AC Power = OK
Battery Power = OK
Server Mode = TRUE
Power Loss Mode = Shutdown
Standby System In = 2
Client1_IP = 192.168.0.2
Enable Network UPS Server = TRUE

What “Power Loss Mode = Standby” means when in auto-protection means in reality I don´t know yet, but I keep looking…

Is not possible to create conditioned (from NUT) instruction/batches on QNAP?

I run APCUPSD on my Ipfire and it is setup as a net server.
So my NAS uses the net server as its UPS.
So nas shut down after 2 minutes.
Ipfire After 10 minutes.

Blockquote Is not possible to create conditioned (from NUT) instruction/batches on QNAP?

I have tried to find out, but I have still not found the answer. Will check some more.

I run APCUPSD on my Ipfire and it is setup as a net server.
So my NAS uses the net server as its UPS.
So nas shut down after 2 minutes.
Ipfire After 10 minutes.

I have the similar setup, but my NAS as NUT server and iPfire as NUT user and my devices also shut down. But after they have shut down, if the power failure resolves before the UPS batteries have run out of charge, my iPfire don´t start up again automatically. Have you got that working?

Is the Ipfire bios set to start on power up?

Shaun HVAC hvacguy. Is the Ipfire bios set to start on power up?

As I wrote above:

I suppose that is why I have APC server on ipfire.
and server shuts down and not IPfire.

Hi @raffe

I am using APCUPSD on IPFire as the master. In APCUPSD you can put an “apccontrol killpower” command into your shutdown scripts so that when the master shutsdown it commands the APS to shutdown.
In the NUT manual I see that you can configure the shutdown process to create a POWERDOWNFLAG file which will subsequently cause the UPS to be shutdown.

With the APCUPSD system with an APC UPS, this works for me. I have tested it out as part of my installation process.
Pulled the plug (very nerve wracking) and waited for the UPS to go below its set battery limits, which I set higher so the test occurred quicker. The slave shutdown, followed a bit later by the IPFire master and then shortly after the UPS turned off.
When the power came back then the UPS restarted and that caused the PC’s to restart.

Unfortunately, if your bios does not allow your system to “turn on when power resumes” you may be stuck with your current approach.

2 Likes

R R Your Master is NAS.