brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: calculate the Unraid shutdown time-out instead of keeping 90 seconds

Unraid

Unraid gives your server a fixed amount of time to shut down cleanly. When that time runs out it forces the shutdown, and the next boot reports an unclean shutdown, which can start a parity check. The default is 90 seconds, and with a few VMs that can be too short.

The setting is Settings, Disk Settings, Shutdown time-out (seconds). Click the label and Unraid explains it on the spot: how long to wait for a graceful shutdown before forcing it.

Unraid Disk Settings with the Shutdown time-out field at 90 seconds and its help text
Disk Settings: the time-out that covers the whole shutdown.

Add up what has to stop

The docs give a formula based on how a shutdown runs. VMs go through three stages (resume paused, hibernate, shut down) and each stage can take the full VM timeout. Docker containers stop in parallel, so they count as one Docker timeout. Then come other services and finally the array, which needs 15 to 30 seconds to unmount and sync.

(VM timeout x 3) + Docker timeout + other services + 15-30 seconds

Say you have one VM on the 60 second default, raised the Docker timeout to 30 seconds because a database container needed it, and allow 10 seconds for other services: 60 x 3 + 30 + 10 + 30 gives 250 seconds. That is far above 90. The docs’ own example uses a 300 second VM timeout and lands on 970 seconds, more than 16 minutes.

They recommend at least 180 seconds in any case, and 300 or more with several VMs or complex containers. I’d round up. A shutdown that finishes early doesn’t wait for the timer, so a high value costs nothing on a normal day. If you use plugins with their own stop timers, like the LXC plugin, add those to the sum too.

Where the other two timers live

The VM timer is under Settings, VM Manager. Switch to Advanced view and look for VM shutdown time-out, 60 seconds by default. Right above it, Upon host shutdown decides what happens to running VMs. With Hibernate VMs, Unraid asks the VM to hibernate if it supports that, and otherwise tries a normal shutdown.

Unraid VM Manager with Upon host shutdown and VM shutdown time-out set to 60
VM Manager in Advanced view: shut down or hibernate, and how long to wait.

The docs call hibernation the most important step, because saving the state is far quicker than waiting for a guest to close everything. It needs the QEMU Guest Agent inside the VM. Without the agent the VM may fall back to a shutdown and use up the whole timeout. Windows guests are the usual trouble: a “save this document?” dialog or a running update can hold a shutdown for a long time, and a forced stop at that moment can damage files.

The Docker timer is Docker Stop Timeout under Settings, Docker, 10 seconds by default. The docs place it under Advanced view; on 7.4.1 I see it in Basic view. They suggest 30 seconds if containers crash when stopped.

Unraid Docker settings with Docker Stop Timeout at 10 seconds
Docker settings: seconds a container gets before it is forced to stop.

One more thing that eats the timer: an open terminal or SSH session. Unraid waits for those to close, and if one is still open when time is up, the shutdown is forced. Close them before you reboot, or look at the Dynamix Stop Shell plugin.

Check it against your UPS

During a power cut the whole sequence has to finish on battery. Under Settings, UPS Settings you choose when the shutdown starts: at a battery level, at a remaining runtime or after a set time on battery. The screen below shows 10 percent and 10 minutes. A 970 second shutdown does not fit in 10 minutes, so raise the threshold or shorten the timers. For a UPS the built-in support can’t talk to, the docs point to the NUT plugin.

Unraid UPS Settings with battery level and runtime thresholds for shutdown
UPS Settings: the three fields that decide when a shutdown starts.

Then test it by simulating an outage. If the next boot still reports an unclean shutdown, turn on persistent logging under Settings, Syslog Server, so the log from before the reboot is still there to read.

Further reading: Unraid docs: Unclean shutdowns

Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it

More Unraid tips Change the RAID profile of a Unraid BTRFS pool with Balance Replace a disk in a redundant Unraid pool from the Main tab Test every Unraid drive with the DiskSpeed container See the XML behind a VM with the inline XML view in Unraid 7 Choose where a new VM's disk image is created with Unraid's storage override All Unraid tips (77) All topics

Link