Use of halt to safely shutdown IPfire without powering off

My IPFire box is a thin client, and despite its BIOS showing a setting which should power the box back on after a controlled shutdown, and then power failure (UPS run out of charge), this does not seem to function correctly. What it actually does is only power back on if the thin client was on when the UPS ran out of juice.

I dont really want to let IPfire hard power off to fix the fact when the power returns, my internet doesnt return. I was thinking I could put the thin client into a halt state instead of power off. This would be safe, and allow it to remain powered so the BIOS would restart the thin client after power returns.

This however seems harder then expect. Unlike my debian box, which when I /sbin/halt it, it shuts down cleanly and just sits at a black screen, IPfire seems to actually poweroff the box, and not just halt. I think this has to do with sysvinit which differs to the behaviour of systemd. Not having a lot of luck with Google as everyone wants their PC to turn off automatically, whereas I want the reverse.

I could disable ACPI I guess to remove IPFires ability to power off the thin client, but I guess there might be other issues with doing this? Any suggestions on how to get a true halt?

Model of the thin client?
Do your UPS have any data connection?

Question? When power goes out. And IPfire shut down.
Does the UPS turn off power to the Ipfire?
If it doesn’t than IPfire will not restart.

My understanding is that when power goes out.
UPS tells IPfire to shutdown at some set point.
Then the UPS must shut down power and hibernate. Until power is restored.
Then it re energizes the IPfire. And it should re start.
Depending on UPS configuration.

Not sure if your using apcupsd?
Would think nut similar?

When you shut down IPFire, it transitions to init level 0. The final script executed during this transition is /etc/init.d/halt. This script calls the system utility with the following flags: halt -d -f -i -p. The -p flag is what powers off your machine.

The flags have the following meanings:

  • -d: Writes debugging information.
  • -f: Forces the halt action, bypassing the init system.
  • -i: Disables all network interfaces.
  • -p: Powers off the system.

If removing the flag -p solves your problem this is what you could consider doing to change the system behavior:

  1. Copy the original halt script to a new location: cp /etc/init.d/halt /home/mydir/custom_halt.
  2. Edit /home/mydir/custom_halt to remove the -p flag; make sure the script is executable.
  3. Change the symlink in /etc/rc.d/rc0.d/ to point to the new script: ln -sf /home/mydir/custom_halt /etc/rc.d/rc0.d/S99halt.

Note: This change could be undone by system updates. Consider creating a script to reapply these changes after updates.

1 Like

The problem I see is how does the unit know the power is back on? If the power never shutdown.

BIOS showing a setting which should power the box back on after a controlled shutdown, and then power failure (UPS run out of charge)

I have only see BIOS setting to restart after power failure.
So this is true.
The UPS must shutdown or hibernate to turn off power.
If power returns befor UPS shutdown.
Then your stuck with all your equipment off.
Not sure how to fix that.

Model of the thin client?
Do your UPS have any data connection?

Its a HP T730. The UPS is connected via USB and the whole shutdown routine is already working with nut. Basically power goes off, IPFire waits until LB, and then shuts down. IPFire tells the UPS to turn off. UPS turns off.

When power returns UPS comes back on, and powers up everything including switches and Access Points.
IPfire box does not return. It looks like because the box was off when the power was cut, it does not return. I’ve sorta confimed this by testing powering it off when it is still running (ick) and it does turn itself back on. BIOS’s power behaviour is set to ‘Power state when power returned’ = ‘On’. Looks to be a crap implementation in the BIOS, however there are no updates to fix this behaviour and its EOL now.

Question? When power goes out. And IPfire shut down.
Does the UPS turn off power to the Ipfire?
If it doesn’t than IPfire will not restart.
My understanding is that when power goes out.
UPS tells IPfire to shutdown at some set point.
Then the UPS must shut down power and hibernate. Until power is restored.
Then it re energizes the IPfire. And it should re start.
Depending on UPS configuration.

Yeah so this is all good and running, as my above post.; Power definitely goes out, it kills everything in my cupboard. However when it returns, if IPfire was safely shutdown before power is cut, the thin client does not restart.

  1. Copy the original halt script to a new location: cp /etc/init.d/halt /home/mydir/custom_halt.
  2. Edit /home/mydir/custom_halt to remove the -p flag; make sure the script is executable.
  3. Change the symlink in /etc/rc.d/rc0.d/ to point to the new script: ln -sf /home/mydir/custom_halt /etc/rc.d/rc0.d/S99halt.

Will give this a go tonight when I can thanks. If this change is going to be undone by updates, any reason I can’t just modify the original file?

Latest bios available for this hardware is 00.01.16 Rev.A,dated august 2021 according to HP site.
You already have installed latest bios for this Thin client?

I am not certain the update will revert modifications of the init scripts. Of course you can modify directly the halt script.

What are the values of these BIOS settings?

Power-On Options (Power on)
S5 Wake on LAN (Enable)
S5 Maximum Power Savings (Disabled)

Recommended values in brackets.

halt comes in the sysvinit package. If that package is updated then its files will be overwritten in the update.

I have just noticed that currently we have version 3.00 and there is version 3.08 available so I will do a patch submission for that.

In version 3.08 it mentions the following:-

floppym provided patch which causes the halt command to call “shutdown -h -H” instead of “shutdown -h” when halt is invoked without parameters. This forces the shutdown command to set the INIT_HALT variable and assume, unless other conditions apply, that the “halt” call really wants to halt the machine and INIT_HALT should be set. In other words we assume halt wants to halt unless told otherwise.
Addresses downstream Gentoo bug ID 911257.

From the gentoo bug it looks like halt doing a poweroff if run without any parameters has been a bug for quite some time.

3 Likes

From reading the Gentoo bug info it looks like halt calls the shutdown command behind the scenes.

It is just that currently it calls the shutdown command with just the -h argument.

So @callifo could just use the command

shutdown -h -H

as from what I have read that does what the halt command was intended to call behind the scenes and should do again when sysvinit-3.0.8 is installed with the bug fix.

The above command could just be tested out from the command line to see if it gives the result intended.

Once the bug fixed version of sysvinit is available then the halt command should be able to be used on its own again.

3 Likes

Latest bios available for this hardware is 00.01.16 Rev.A,dated august 2021 according to HP site.
You already have installed latest bios for this Thin client?

I am running 1.15, the change notes only show a CVE fix in the bios updater tool as the only change. I’ve attempted to install it, however the creation of the update USB key doesnt work on Windows 11, and I can’t even open it on Windows 10. I dont know how much luck I’m going to have with it, I’ve been struggling for the last hour with the tool.

Power-On Options (Power on)
S5 Wake on LAN (Enable)
S5 Maximum Power Savings (Disabled)

The first two yes, the last one is still on enabled. Will try turning it off.

Edit: sorry was incorrect, they are all as per the recommended settings.

So @callifo could just use the command

shutdown -h -H

Will try that later tonight when we are not using the internet. Downsides on attempting to run shut-down tests on the internet device :slight_smile:

So I tried

shutdown -h -H

It does still shutdown the host, the last thing I see before it turns off the monitor (and the system’s power LED turns off) is ‘powering off’. Interestingly though, if I test cutting power after its off, and turn it back on again, it does start up. Tried it a few times and it did the samething. Will need to do a proper nut UPS LB simulation and test it fully, will do so this weekend.

2 Likes

Ended up removing the -p in the

/etc/init.d/halt

Just to be sure, this stopped the thin client turning off. Also managed to add another script to observe the /etc/killpower file that nut creates on shutdown, so the UPS also dies with IPfire rather then running completely flat.

Thanks for all the help :slight_smile:

1 Like