OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
        • Load Balancing
          • Build Redundant Load-Balanced Gateways
          • Load Balance Services with NAT or DSR
          • Build an HA HTTPS Load Balancer
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Inventory Power Support
        • Enable Automatic Performance Adjustment
        • Test Explicit Suspend and Resume
        • Configure the Lid Action
        • Add a Low-Battery Action Carefully
        • Diagnose Resume Failures

        Configure Laptop Power Management

        Synopsis #

        OpenBSD exposes battery state and sleep controls through apm(8) and coordinates power events through apmd(8) . Hardware and firmware determine which power states work. This guide establishes automatic performance adjustment, tests suspend and resume, and adds lid or low-battery actions only after the basic path is reliable.

        Complete this work with a local console available. Suspend and hibernate failures can leave a system unreachable or require a forced power cycle. Save work and check that backups are up to date before testing.

        Inventory Power Support #

        Display battery, AC, and performance-policy information:

        apm -v
          # Display the complete power status reported by the platform
        sysctl hw.sensors
          # Inspect battery, AC adapter, temperature, and fan sensors when present
        

        Sensor availability varies by architecture and device. apmd cannot provide readings that the hardware or driver does not expose.

        Review the boot messages for the power-management and button drivers:

        dmesg | grep -Ei 'acpi|apm|battery|lid|power'
        

        On ACPI systems, acpibtn(4) reports supported lid and power-button behavior. Other architectures can expose different capabilities.

        Enable Automatic Performance Adjustment #

        Enable apmd and select automatic performance adjustment:

        doas rcctl enable apmd
          # Start apmd during future boots
        doas rcctl set apmd flags -A
          # Select automatic performance adjustment
        doas rcctl start apmd
          # Start the daemon for the current boot
        doas rcctl check apmd
          # Confirm that it remains running
        

        The automatic policy permits the system to adjust performance according to platform support and power state. Record idle and active battery behavior before adding more policy.

        Test Explicit Suspend and Resume #

        Open a text console, stop nonessential jobs, and request suspend with zzz(8) :

        doas zzz
        

        After resume, verify more than the display:

        apm -v
          # Confirm battery and AC state
        ifconfig
          # Confirm that required network interfaces recovered
        sndioctl
          # Confirm that the audio control path responds
        dmesg | tail -n 80
          # Review the end of the kernel message buffer for resume errors
        

        Repeat the test on battery and AC power, with each required external display and USB device, and after a normal lid-close event. Keep a clean-boot dmesg for comparison.

        Configure the Lid Action #

        Read the current lid action only when the platform exposes it:

        sysctl machdep.lidaction
        

        On systems supported by acpibtn(4) , value 0 ignores a lid event, 1 suspends, and 2 hibernates. Test an immediate suspend action before making it persistent:

        doas sysctl machdep.lidaction=1
        

        After several successful lid-close and resume cycles, add the setting to /etc/sysctl.conf:

        machdep.lidaction=1
        

        Do not add an unsupported machine-dependent variable to another architecture. Hibernation also requires platform support and sufficient swap space; it should be tested separately from suspend.

        OpenBSD 8.0 adds hibernation support on arm64. On supported hardware with sufficient swap, save work and test it separately with doas ZZZ. After the system resumes, repeat the device and network checks above before enabling an automatic hibernation action.

        Add a Low-Battery Action Carefully #

        The apmd -z flag requests suspend when estimated battery life reaches a selected percentage. Battery estimates can be absent, inaccurate, or delayed. Confirm stable readings over several charge cycles before enabling this action.

        For a tested threshold of 10 percent:

        doas rcctl set apmd flags "-A -z 10"
          # Retain automatic performance adjustment and add the threshold
        doas rcctl restart apmd
          # Apply the new daemon flags
        

        Do not use an automatic sleep threshold on a host whose battery estimate is unknown. Monitoring and a tested shutdown procedure are safer than an unreliable action.

        Diagnose Resume Failures #

        Classify a failure before changing settings:

        • No sleep entry indicates a daemon, permissions, or platform-support problem.
        • A machine that sleeps but does not wake indicates firmware, wake-device, or driver behavior.
        • A recovered console with failed networking, audio, USB, or graphics indicates a device-specific resume problem.
        • A graphical session failure with a working text console belongs to the X server, driver, or session layer.

        Collect the complete dmesg, the relevant /var/log/messages interval, exact hardware identity, and a reproducible sequence. Collect OpenBSD Diagnostic Evidence explains what to include in a report and how to remove sensitive data.

        Do not apply undocumented ACPI overrides or kernel patches from another operating system. Confirm any workaround against current OpenBSD documentation or a relevant developer report.

        Report a bug
        • Synopsis
        • Inventory Power Support
        • Enable Automatic Performance Adjustment
        • Test Explicit Suspend and Resume
        • Configure the Lid Action
        • Add a Low-Battery Action Carefully
        • Diagnose Resume Failures