Laptops Used as Servers Must Ignore the Lid Switch in logind
On most Linux distributions systemd-logind handles power events with desktop defaults: closing a laptop's lid suspends it. An old laptop turned into a headless server then drops off the network the moment it is closed or stacked. Setting the lid actions to ignore keeps the system running while the screen turns off.
Where the Behaviour Comes From
systemd-logind manages logins, seats and hardware power keys. It receives the lid-close event from ACPI and applies the action configured in logind.conf, suspend by default.
The Setting
# /etc/systemd/logind.conf.d/headless.conf
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
sudo systemctl restart systemd-logind
The hardware still turns the backlight off when the lid closes; only the OS reaction changes.
References
- Linux Administration MOC - hub for Linux notes.
- Kubernetes MOC - the laptops in question are Kubernetes nodes.
- systemd documentation: logind.conf -
HandleLidSwitch*and drop-in directories.
Review cards
Flashcard Which logind settings keep a laptop server running with the lid closed, and why set all of them?
HandleLidSwitch, HandleLidSwitchExternalPower and HandleLidSwitchDocked, all set to ignore: battery, AC power and docked states each have their own setting.