Systemd

筆記型電腦經常掛起

  • August 25, 2021

我在使用新的 Debian 11 筆記型電腦時遇到了問題,它有些日子可以正常工作,但有時它會在起床約 30 秒後反復進入睡眠狀態。

stew@simswe28:~$ sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
● sleep.target - Sleep
    Loaded: loaded (/lib/systemd/system/sleep.target; static)
    Active: inactive (dead)
      Docs: man:systemd.special(7)

Aug 24 08:18:36 simswe28 systemd[1]: Reached target Sleep.
Aug 24 08:18:46 simswe28 systemd[1]: Stopped target Sleep.
Aug 24 08:19:14 simswe28 systemd[1]: Reached target Sleep.
Aug 24 08:22:14 simswe28 systemd[1]: Stopped target Sleep.
Aug 24 08:22:42 simswe28 systemd[1]: Reached target Sleep.
Aug 24 08:25:40 simswe28 systemd[1]: Stopped target Sleep.
Aug 24 08:26:10 simswe28 systemd[1]: Reached target Sleep.
Aug 24 08:26:42 simswe28 systemd[1]: Stopped target Sleep.
Aug 24 08:27:10 simswe28 systemd[1]: Reached target Sleep.
Aug 24 08:27:19 simswe28 systemd[1]: Stopped target Sleep.

● suspend.target - Suspend
    Loaded: loaded (/lib/systemd/system/suspend.target; static)
    Active: inactive (dead)
      Docs: man:systemd.special(7)

Aug 24 08:18:46 simswe28 systemd[1]: Reached target Suspend.
Aug 24 08:18:46 simswe28 systemd[1]: Stopped target Suspend.
Aug 24 08:22:14 simswe28 systemd[1]: Reached target Suspend.
Aug 24 08:22:14 simswe28 systemd[1]: Stopped target Suspend.
Aug 24 08:25:40 simswe28 systemd[1]: Reached target Suspend.
Aug 24 08:25:40 simswe28 systemd[1]: Stopped target Suspend.
Aug 24 08:26:42 simswe28 systemd[1]: Reached target Suspend.
Aug 24 08:26:42 simswe28 systemd[1]: Stopped target Suspend.
Aug 24 08:27:19 simswe28 systemd[1]: Reached target Suspend.
Aug 24 08:27:19 simswe28 systemd[1]: Stopped target Suspend.

● hibernate.target - Hibernate
    Loaded: loaded (/lib/systemd/system/hibernate.target; static)
    Active: inactive (dead)
      Docs: man:systemd.special(7)

● hybrid-sleep.target - Hybrid Suspend+Hibernate
    Loaded: loaded (/lib/systemd/system/hybrid-sleep.target; static)
    Active: inactive (dead)
      Docs: man:systemd.special(7)

對於確認硬體問題或隔離配置問題,我可以提供一些想法嗎?想提高suspend.target什麼?

您可以使用sudo systemctl mask suspend.target. 這將阻止您的機器不斷掛起。然而,根本原因仍然存在。

達到穩定狀態後,環顧四周,找出導致暫停的原因。一種選擇可能是電源按鈕鬆動。acpi_listen通過從 package執行來確認acpid。如果看到電源按鈕事件或筆記型電腦蓋開關關閉,您將看到以下類型的消息:

~$ acpi_listen 
button/power PBTN 00000080 00000000
button/power LNXPWRBN:00 00000080 00000001
button/lid LID open
button/lid LID close
button/lid LID open

如果它執行了一段時間沒有消息,那麼這不是你的問題。

如果您注意到任何程序佔用了大量資源,那麼這些都值得檢查。就我而言,我的粉絲聲音很大,並註意到systemd-{logind,journal}使用以下命令佔用了大量資源top

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                                                     
   724 root      20   0  515012   8348   6880 R  87.5   0.1   7:15.06 systemd-logind                                                                                                                              
   321 root      20   0  482776 306700 304868 S  12.5   1.9   0:55.29 systemd-journal   

journalctl -f將有助於隔離這些過程的原因。就我而言,這不斷重複:

Aug 24 08:44:42 simswe28 systemd-logind[724]: Suspending...
Aug 24 08:44:42 simswe28 systemd-logind[724]: Unit suspend.target is masked, refusing operation.
Aug 24 08:44:42 simswe28 systemd-logind[724]: Failed to execute suspend operation: Permission denied
Aug 24 08:44:42 simswe28 systemd-logind[724]: Suspending...
Aug 24 08:44:42 simswe28 systemd-logind[724]: Unit suspend.target is masked, refusing operation.
Aug 24 08:44:42 simswe28 systemd-logind[724]: Failed to execute suspend operation: Permission denied
Aug 24 08:44:42 simswe28 systemd-logind[724]: Suspending...
Aug 24 08:44:42 simswe28 systemd-logind[724]: Unit suspend.target is masked, refusing operation.
Aug 24 08:44:42 simswe28 systemd-logind[724]: Failed to execute suspend operation: Permission denied

在這種情況下,systemd-logind是對某個信號作出反應。可以通過 隔離和抑制信號/etc/systemd/logind.conf

就我而言,我一次將多個選項設置為ignore,然後systemctl unmask suspend.target && systemctl restart systemd-logind。我發現HandleLidSwitch=從改變suspendignore解決問題(即使acpi_listen沒有記錄蓋子開關事件)。

引用自:https://unix.stackexchange.com/questions/666009