Home

UPS and clean shutdown: the forgotten link in every homelab

Linux 5 min read

A UPS with ten minutes of runtime is worth nothing if nobody triggers the shutdown. How to orchestrate powering down several machines in the right order, and why the NAS has to go last.

Key takeaways

  • Without monitoring software, a UPS merely postpones the hard power loss by a few minutes.
  • You need a monitoring service that triggers the shutdown at a threshold, not when the battery runs flat.
  • Shutdown order matters: the machines that consume storage go first, the storage goes last.
  • The classic trap: shutting down the server that drives the UPS before the others, which then lose their source of information.
  • A battery has to be tested: it ages, and it can end up holding for a few seconds with no indicator light saying so.

The UPS is often the last piece of equipment bought and the least configured. You plug it in, the LED is green, and the subject is closed.

Then a forty-minute outage arrives. The UPS holds for eight minutes, nobody triggers anything, and everything dies hard, exactly as if it were not there.

What a UPS does without software

On its own, a UPS protects against three things: momentary outages, voltage fluctuations, and surges. That is already worth having, and it is enough to justify the purchase.

But faced with a long outage, all it does is postpone the hard shutdown. When the battery empties, everything drops at once, in the middle of whatever writes were in flight.

Real protection comes from the monitoring service: software that talks to the UPS, watches the state of the battery, and triggers an ordered shutdown while there is runtime left.

Without that piece, you bought a delay, not protection.

The trigger: a duration, not a percentage

The first question is: at what point do we start shutting down?

The reflex is to settle on a battery percentage. The right criterion is a different one: it is the time your installation needs to shut down completely.

That duration is measured, not estimated. Time how long your slowest machine takes to power down. A hypervisor cleanly stopping a dozen virtual machines often takes several minutes. Add a margin, and trigger at a level that guarantees that window.

The classic mistake is a threshold set too low, chosen to "get the most out of the battery." The shutdown starts, the battery runs out before it finishes, and the machines die mid-write. You end up with the worst of both worlds: the complexity of a shutdown sequence and the corruption of a hard power loss.

Shutdown order

With several machines, the order is not a matter of indifference. The rule: storage consumers first, storage last.

If your NAS powers off while a hypervisor is still writing to it, you cause precisely the corruption you set out to avoid, and you make it worse, since the writes are cut short by a disconnection rather than by a power loss.

The sane sequence:

  1. Virtual machines and containers, stopped by their hypervisor.
  2. The hypervisors themselves.
  3. Shared storage.
  4. Network equipment, if it is on the UPS.

Each step needs a delay before the next, calibrated on the real shutdown time of the previous tier. Here again: measure rather than estimate.

The most common trap: shutting down the machine wired to the UPS first. The others then lose their source of information about the state of the battery, at the worst possible moment. The driving machine has to shut down last.

What to plug in, and what not to

Two cabling mistakes come up again and again.

Forgetting the network. A UPS that powers the servers but not the switch produces an absurd situation: the machines are running, the monitoring wants to trigger the shutdown, but nothing can talk to anything. The switch and the router draw very little; they belong on the UPS.

Plugging in things that have no business being there. A laser printer can pull a considerable amount of power at start-up, well beyond what a consumer UPS can take. It has no place on the protected outlets: it eats into usable runtime and can trip a protective cutoff at the worst possible moment.

The battery ages in silence

This is the most neglected point. A battery loses capacity with time and heat, and that degradation is invisible.

A UPS can report a perfectly normal state and in reality hold for only a few seconds under load. You find out at the next outage, which is too late.

An annual discharge test, under real conditions and timed, is the only way to know your effective runtime. It is also your chance to verify that your shutdown sequence behaves as designed: in what order, in how long, and whether everything comes back up correctly afterwards.

Do it at a moment of your choosing, with fresh backups. A test that uncovers a problem is a successful test.

Startup, the forgotten half of the problem

Shutdown is the visible part; the return of power raises its own questions.

Do your machines restart automatically? The relevant setting lives in the firmware and often defaults to "stay off", which for a server is rarely the behavior you want.

Do they restart in the right order? A hypervisor that boots before its storage finds its volumes missing and may flag machines as failed. Staggered power-on delays settle the question.

And above all: what happens if power comes back during the shutdown sequence? That disconcerting case, where the outage was brief but the shutdown was already under way, has to be planned for, or you end up with an installation half powered down and half started up.

Key takeaways

A UPS without monitoring is a delay, not a protection. The software, the shutdown order, a threshold computed from measured durations and the annual battery test are what turn a purchase into a guarantee. It is very little work, and it is the difference between an outage with no consequences and a full restore on a Sunday night.

Frequently asked questions

Is a UPS enough to protect my data?
Only against very brief outages. Faced with a long one, it merely postpones the hard shutdown by a few minutes: when the battery empties, everything dies at once, exactly as it would without a UPS. Real protection comes from the monitoring service that watches the state of the UPS and triggers a clean shutdown while there is runtime left. Without that software, you bought a delay, not protection.
At what battery level should the shutdown be triggered?
The right criterion is not a percentage but the real shutdown time of your machines, measured rather than estimated. Time how long your slowest piece of equipment takes to power down completely, add a comfortable margin, and trigger at a level that guarantees that window. A frequent mistake is picking a threshold that is too low: the shutdown starts, the battery empties before it finishes, and the machines die mid-write, which is the worst possible scenario.
In what order should the machines be shut down?
Storage consumers first, storage last. If your NAS powers off while a hypervisor is still writing to it, you get precisely the corruption you were trying to avoid. The sane order is: virtual machines and containers, then hypervisors, then shared storage. That implies delays between the steps, calibrated on the real shutdown time of each tier.
What is the most common trap in this kind of setup?
Shutting down the machine that drives the UPS first. In a typical configuration, one server is wired to the UPS and tells the others about the state of the battery. If it goes down at the start of the sequence, all the others lose their source of information at the worst possible moment: they no longer know the battery is draining, and they wait for an instruction that will never come. The driving machine has to shut down last, or after handing the role over.
Should the battery be tested, and how often?
Yes, because a battery ages and loses capacity with no indicator light saying so. A UPS reporting a healthy state may hold for only a few seconds under real load. An annual discharge test, under real conditions and timed, is the only way to know. Run it at a moment of your choosing, with fresh backups. It is also your chance to verify that your shutdown sequence actually works.

Did you enjoy this article?

Was this article helpful?

Thanks for your feedback!

Comments

MR
Morgann Riu

Cybersecurity and Linux administration expert. I help companies secure and optimize their critical infrastructures.

UPS battery backup NUT clean shutdown homelab reliability power

Recommended for you

Related tutorial

Back to the blog