The Lenovo ThinkPad X270 secondary battery behavior on Linux is often a firmware-level power management feature rather than a systemd configuration error. When the system reports external power status incorrectly, it is usually due to how the Embedded Controller (EC) handles AC adapter detection or charging thresholds. Verifying the actual hardware state through kernel logs and adjusting BIOS settings typically resolves the discrepancy without requiring complex systemd workarounds.
Understanding the Power State Discrepancy
Users of the ThinkPad X270 may notice that the operating system behaves as if it is connected to an external power source even when running solely on the internal or secondary battery. This confusion often stems from how systemd-logind interprets power supply events. The logind service monitors changes in power states to manage user sessions, suspend policies, and screen brightness. However, if the underlying hardware reports an incorrect state, systemd will react accordingly.
It is crucial to distinguish between what the OS *thinks* is happening and what the hardware *is* doing. The ThinkPad embedded controller manages power delivery independently of the main CPU. If the EC detects a stable voltage from the AC adapter, it may signal "AC present" to the OS. Conversely, if there is a glitch in this signaling, the OS might fail to enter battery-optimized modes or might display misleading indicators in the desktop environment. Misattributing this to systemd alone leads to unnecessary troubleshooting of service files when the root cause lies in firmware communication.
Differentiating Hardware vs. Software Signals
Before modifying any system services, you must verify the raw input from the kernel. The Linux kernel exposes power supply information through the sysfs interface. By examining these virtual files, you can see exactly what the hardware is reporting. Look for entries under /sys/class/power_supply/. Specifically, check the online file for your AC adapter (often named ACAD or similar) and the status file for your batteries (BAT0, BAT1). If online returns 1 while unplugged, the hardware or driver is sending false positive signals.
Verifying Kernel Power Supply Reports
To confirm whether the issue is at the firmware level, inspect the kernel's view of the power supplies. Open a terminal and list the available power supplies using ls /sys/class/power_supply/. You will likely see entries for both AC adapters and batteries. Check the status of the AC adapter by reading /sys/class/power_supply/ACAD/online. A value of 1 indicates AC power is detected, while 0 indicates battery only.
Next, examine the battery status files. The capacity file shows the current charge percentage, while status indicates whether the battery is Charging, Discharging, or Fully Charged. If the system claims to be on AC power but the battery is discharging, there is a conflict in the reported state. This conflict is where systemd-logind gets confused, leading to unexpected behavior such as failing to suspend properly or ignoring battery thresholds.
Checking System Journal for Power Events
The systemd journal records all power supply events. Use journalctl -f | grep -i power to watch real-time events. Unplug and replug the charger while watching. If you see messages indicating a change in AC state that does not match physical reality, the issue is upstream of systemd. In many cases, the thinkpad_acpi kernel module handles these communications. Ensuring this module is loaded correctly is vital for accurate reporting.
BIOS and Firmware Settings
ThinkPad laptops have advanced power management features controlled by the BIOS. One common setting is "Battery Charge Threshold" or "Conservation Mode." These features are designed to extend battery lifespan by limiting the maximum charge level or stopping charging at certain percentages. Sometimes, enabling or disabling these modes can affect how the AC adapter state is perceived by the OS.
Enter the BIOS setup (usually by pressing F1 during boot) and navigate to the Power section. Check if Conservation Mode is enabled. If you are experiencing issues with power state detection, try toggling this setting. Additionally, ensure your BIOS is up to date. Lenovo frequently releases firmware updates that fix EC bugs related to power detection. Updating the BIOS can resolve persistent misreporting issues that older firmware versions exhibit.
Updating Embedded Controller Firmware
If the BIOS update does not resolve the issue, consider updating the Embedded Controller firmware separately. Some ThinkPad models allow EC updates via Windows utilities or specific Linux tools. Since you are migrating or managing Linux systems, refer to guides on maintaining firmware integrity. For example, learning how to handle firmware updates during OS transitions can help prevent such discrepancies. See Updating BIOS on Lenovo Laptop while Migrating from Win11 to Linux OS for best practices in managing firmware across different operating environments.
Systemd Configuration Adjustments
If the hardware reports correctly but systemd still behaves oddly, you may need to adjust logind settings. The /etc/systemd/logind.conf file contains parameters like HandleLidSwitch and IdleAction. While these do not directly fix power detection, they control how the system responds to it. Ensure that HandleLidSwitch is set appropriately for your needs. If the system is waking up unexpectedly or not suspending, this setting is a primary candidate.
After making changes to logind.conf, restart the service with sudo systemctl restart systemd-logind. Monitor the journal again to see if the behavior aligns with the new configuration. It is rare for logind to be the sole cause of power state misreporting, but it can exacerbate symptoms if the underlying hardware signal is unstable.
Related Considerations for Linux on ThinkPads
Managing power on ThinkPads involves more than just battery detection. Service ordering during shutdown can also impact power state consistency. If services do not close in the correct order, hardware states may become inconsistent. Reviewing service dependencies ensures a clean transition between power states. For insights on managing service lifecycles, consult Preserve Order of Closing Services While Shutting Down Linux.
Additionally, if you are using custom scripts or daemons to monitor battery levels, ensure they are compatible with the current kernel interfaces. Older tools may rely on deprecated sysfs attributes, leading to confusion. Always use current kernel documentation for power supply interfaces.
Frequently Asked Questions
Why does my ThinkPad show AC power when unplugged?
This is usually caused by a glitch in the Embedded Controller firmware or a loose connection in the DC-in jack. The EC may briefly detect residual voltage or experience a signal bounce that it interprets as a continuous AC presence. Restarting the laptop often clears this transient state, but persistent issues require a BIOS update.
Does systemd-control the battery charging threshold?
No, systemd does not control hardware charging thresholds. Those settings are managed by the BIOS/UEFI firmware or the thinkpad_acpi kernel module. Systemd-logind only reacts to the power state signals provided by the kernel. Changing logind settings cannot override hardware-defined charging limits.
How do I reset the embedded controller on a ThinkPad?
You can perform an EC reset by shutting down the laptop, unplugging the AC adapter, and removing the internal battery if accessible. Hold the power button for 30 seconds to drain residual capacitors. Reconnect the battery and AC adapter, then power on. This forces the EC to re-initialize its hardware sensors.
Is conservation mode bad for the battery?
Conservation mode is generally beneficial for longevity as it prevents the battery from staying at 100% charge continuously, which causes chemical degradation. It limits charging to around 55-60%. This is ideal for users who keep their laptops plugged in most of the time, such as desktop replacements.
Can outdated BIOS cause systemd errors?
An outdated BIOS can cause incorrect power supply reports, which systemd then misinterprets. This leads to logical errors in session management, such as failing to suspend or wake improperly. Updating the BIOS ensures the hardware communicates accurately with the operating system, preventing these downstream software issues.