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.
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), anddriver(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 -Uto 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 tostandalonefor a single machine.upsd.conf: Configuresupsdto listen on localhost.upsd.users: Sets up a localadminuser forupsmonwith appropriate file permissions.upsmon.conf: Configuresupsmonto monitor the UPS, defines shutdown commands, and sets notification flags.
- Service Management: It provides
systemctlcommands 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
upscto query live UPS data andsystemctlto 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.