NUT (Network UPS Tools) on Ubuntu Precise

Installing nut (Network UPS Tools) on Ubuntu Precise with a USB connected UPS (such as the CyberPower AVR series) may produce an error similar to the following:

Can’t connect to UPS [UPS] (cyberpower-ups): No such file or directory

The problem involves the fact that Ubuntu mounts the device as owned by root, but the nut daemon drops to an unprivileged account that doesn’t have the necessary access. The simple fix is to use udev to adjust the device permissions.

Connect the device and (as root) run lsusb and locate it. Note the Bus and Device IDs as well as the Vendor:Product ID pair.

Bus 001 Device 009: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS

You can check the current permissions in /dev.

File: ‘/dev/bus/usb/001/009′
Size: 0 Blocks: 0 IO Block: 4096 character special file
Device: 5h/5d Inode: 28437 Links: 1 Device type: bd,8
Access: (0664/crw-rw-r–) Uid: ( 0/ root) Gid: ( 0/ root)

Now we just create a udev rule that controls the mount behavior.

/etc/udev/rules.d/90-nut-ups.rules:

ACTION==”add”, \
SUBSYSTEM==”usb”, \
ATTR{idVendor}==”0764“, ATTR{idProduct}==”0501“, \
MODE=”0660″, GROUP=”nut”

The rule watches for USB device additions with a vendor and product that match the UPS. It then sets the mode to 0660 and the group to nut instead of the default root. Reload udev, then disconnect and reconnect the device and test that the new permissions are correct. Now that the nut user group has read and write on the device, it should be able to start successfully.

Leave a Reply