HN
Today

Configure a UPS on Linux with NUT

This guide meticulously walks through configuring Network UPS Tools (NUT) on Linux, ensuring your system gracefully shuts down during power outages. It's a fundamental step for anyone running a home lab or small server, preventing data loss and hardware damage. HN readers appreciate such practical, step-by-step documentation for robust system administration.

5
Score
0
Comments
#22
Highest Rank
3h
on Front Page
First Seen
Oct 31, 6:00 AM
Last Seen
Oct 31, 8:00 AM
Rank Over Time
232227

The Lowdown

Power outages are an inevitable reality, and while a UPS provides physical battery backup, intelligent software is required to ensure a clean system shutdown before the battery completely drains. This guide introduces Network UPS Tools (NUT), an open-source solution that communicates with hundreds of UPS models to monitor battery status and initiate timely shutdowns. It focuses on a single-machine setup, ideal for personal servers and home labs.

  • NUT Components: The guide first breaks down NUT into its core daemons: upsd (reads UPS data), upsmon (monitors state and triggers shutdowns), and driver (hardware-specific communication). These typically run on the same host for a single-machine setup.
  • Installation: It provides clear installation instructions for Debian/Ubuntu, Fedora/RHEL/Rocky Linux, and Arch Linux, ensuring users can get NUT installed on their preferred distribution.
  • UPS Detection: Users are shown how to use nut-scanner -U to detect their connected UPS via USB, outputting crucial configuration details like driver, vendor, and product IDs.
  • Configuration Files: The guide systematically covers the necessary configuration files:
    • ups.conf: Defines the UPS, its driver, and port.
    • nut.conf: Sets the operating mode to standalone for a single machine.
    • upsd.conf: Configures upsd to listen on localhost.
    • upsd.users: Sets up a local admin user for upsmon with appropriate file permissions.
    • upsmon.conf: Configures upsmon to monitor the UPS, defines shutdown commands, and sets notification flags.
  • Service Management: It provides systemctl commands to enable and start the necessary NUT services across different Linux families.
  • Verification and Troubleshooting: Finally, the guide details how to verify the setup using upsc to query live UPS data and systemctl to check service status. A dedicated troubleshooting section addresses common issues like driver startup failures, communication errors, and unexpected shutdowns.

By following this comprehensive guide, users can establish a reliable power management system, safeguarding their Linux machines from abrupt power loss and ensuring operational continuity.