Successfully tested on Ubuntu Server 10.04 LTS 64-bit

Running a Linux server without taking care of possible power failures is not a good idea. A power outage can be disastrous for your valuable data if the server is not connected to an emergency power system, notified of the outage and able to properly shutdown the system while on battery power. With an Ubuntu home server, this kind of situations can be handled using a UPS (Uninterruptible Power Supply) and Network UPS Tools (NUT).

First, install NUT:

apt-get install nut

Next, declare your UPS in /etc/nut/ups.conf (I use an MGE Protection Center 675 so don’t forget to modify the driver value according to your own UPS model, as found in NUT documentation):

	driver = usbhid-ups
	port = auto
	desc = "MGE UPS SYSTEMS Protection Center 675"

In /etc/nut/nut.conf, set NUT daemon to run in standalone mode. It’s the mode to use on the machine to which the UPS is connected and when this same machine also monitors the UPS:

MODE = standalone

In /etc/nut/upsd.conf, bind a listening port to the LAN interface if you want to allow other LAN hosts to monitor the UPS through upsd, the UPS network daemon. If not, just keep the first line:


Set the permissions for upsd in /etc/nut/upsd.users. Only the users (one section = one user) listed in this file will be allowed to read the UPS state:

	password = password1
	upsmon master

        password = password2
        upsmon slave

(the [monuser] section is optional and only added here to allow a LAN host to monitor the UPS state over the network)
Now, configure the upsmon daemon. Its role is to communicate with upsd to know the UPS status and send specific commands when some events occur. Modify /etc/nut/upsmon.conf as follows:

MONITOR ups@localhost 1 upsmonitor password1 master

Finally, make sure to modify the permissions of all NUT configuration files:

chown root:nut /etc/nut/*
chmod 640 /etc/nut/*

Now that everything is setup, let see some useful commands.

To start NUT manually (upsd and upsmon daemons simultaneously):

service nut start

To check both daemons status:

service nut status

To launch the UPS driver:

upsdrvctl start

To know the UPS status:

upsc ups

(modify ups according to the section name you used in /etc/nut/ups.conf)
To test the server behavior in case of power outage, use the following command:

upsmon -c fsd

If the UPS is connected to mains, the server will stop and then restart (don’t forget to set your BIOS power management to “Always on”). If the UPS is unplugged, the server will restart only after reconnection to mains.
One last thing: If you have a “BUS= will be removed in a future udev version” error at system boot, see for a solution.
That’s all Folks!

For further reading, see NUT website.