tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

shutdown sequence and UPS poweroff



Currently, pkgsrc/sysutils/ups-nut works well on NetBSD (somewhat shaky
testing on some points, but my current belief):

  UPS is monitored and data is available
  configuration of UPS params
  messages on loss of comms and restore
  messages on transition to battery and return
  initiation of shutdown on low battery

What is missing is

  during shutdown due to low battery, at some point run `upsdrvctl
  shutdown` to tell the UPS to turn off power (and thus preserve battery
  life) until power is back

Most UPS units can be set up to e.g. wait 20s after the command to turn
off power, and then to power on some delay after power returns.

The question is how to add this in as an rc.d script.

It should be as late as possible in shutdown so that the system is
overwhelmingly likely to be in an ok state (filesystems unmounted or
mounted ro) before power goes away.

To run `upsdrvctl shutdown`, guarded by `upsmon -K` to find out if we
should, then /usr/pkg or whatever needs to be available.

rcorder * shows the following, with '/ -' noting what happens on shutdown

  root / -
  DISKS
  swap1 / also unmounts tmpfs without device nodes
  mountcritlocal / -
  NETWORKING
  mountcritremote / -
  mountall / "umount -a" !!
  swap2
  SERVERS
  DAEMONS
  LOGIN
  upsd

It seems the ups files should have some BEFORE/AFTER to put them
between SERVERS and DAEMONS, so let's assume I've done that -- but
that's a separable issue.

(It also seems that things like nfsd, that aren't needed to get *this*
machine up should REQUIRE: DAEMONS but that's off point and not
important.)


I think the right place to kill power, as things stand now, is (on
shutdown) after swap2 and before mountall, because mountall might
unmount /usr.

It seems like a bug that mountall unmounts critlocal/critremote.  With
that fixed, it seems like just before mountcritlocal is the right place.

Does it seem reasonably safe that mountall through root will be fast, < 10s?


Home | Main Index | Thread Index | Old Index