Files
nexus/wiki/sources/ubuntu禁用合盖休眠.md
2026-04-27 00:02:56 +08:00

46 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Ubuntu禁用合盖休眠"
type: source
tags: [ubuntu, systemd, 服务器配置]
date: 2026-04-26
---
## Source File
- [[Home Office/Ubuntu禁用合盖休眠]]
## Summary用中文描述
- 核心主题Ubuntu 24.04 笔记本合盖休眠行为配置
- 问题域:服务器场景下笔记本合盖后不应进入休眠状态
- 方法/机制:通过修改 `systemd-logind``logind.conf` 配置文件,将 `HandleLidSwitch` 系列参数设为 `ignore`;进阶方法通过 `systemctl mask` 彻底禁用所有休眠目标
- 结论/价值:提供两步完成服务器场景下笔记本合盖持续运行的生产级方案
## Key Claims用中文描述
- systemd-logind 是 Ubuntu 24.04 控制笔记本合盖行为的登录管理器
- 通过 `HandleLidSwitch``HandleLidSwitchExternalPower``HandleLidSwitchDocked` 三个配置项可覆盖不同场景
- 将配置值设为 `ignore` 后系统合盖不执行任何操作,继续运行
- 修改配置后需执行 `systemctl restart systemd-logind` 重启服务才能生效
- 可通过 `systemctl mask` 从内核级别彻底禁止待机sleep/suspend/hibernate/hybrid-sleep
- `mask``unmask` 可逆,恢复时将 mask 改为 unmask 即可
## Key Quotes
> "在执行此命令时,你的当前会话(包括图形界面或当前的 SSH 连接)可能会短暂断开或重新加载。" — 重启 systemd-logind 服务的注意事项
## Key Concepts
- [[systemd-logind]]Linux 系统登录管理器,负责管理用户会话、电源管理和设备访问权限,合盖行为由其控制
- [[HandleLidSwitch]]systemd-logind 配置项,定义笔记本合盖时的电源行为
- [[sleep.target suspend.target hibernate.target hybrid-sleep.target]]Linux 休眠相关系统目标,通过 `systemctl mask` 可从内核级别彻底禁用
## Key Entities
- [[Ubuntu 24.04]]Canonical 发布的长期支持版 Ubuntu本配置方法的适用系统
- [[systemd]]Linux 系统和服务管理器systemd-logind 为其组件之一
## Connections
- [[Ubuntu禁用合盖休眠]] ← relates_to ← [[Ubuntu服务器通过rsync实现日常增量备份]]
- [[Ubuntu禁用合盖休眠]] ← related_topic ← [[Mac Mini 服务器配置:防止自动锁屏与睡眠]](不同 OS方法不同无冲突
## Contradictions
- 与 [[Mac Mini 服务器配置:防止自动锁屏与睡眠]] 无冲突:
- 冲突点macOS 使用 `pmset` 命令,与 Ubuntu systemd 配置完全不同)
- 当前观点Ubuntu 通过 systemd-logind 配置
- 对方观点macOS 通过 pmset 命令配置