設置 | 登錄 | 註冊

目前共有8篇帖子。

【解決方案】Fedora43有個奇怪的bug:只要筆記本合蓋休眠,打開電腦之後系統必定出現8個小時時差。

1樓 巨大八爪鱼 2026-1-7 15:55
https://weibo.com/1649763572/PpvgGsC19
Incorrect system time after suspending
Apr 2023
when i start my system (hp spectre x360) after suspension. the system time is usually incorrect. i』ve recently reinstalled my system, after this reinstall it started showing this behaviour which it didnt before.
If i run sudo hwclock -s the time gets corrected until i suspend again. if automatic time sync and automatic timezone are on this behaviour still occurs.
edit: i』m not 100% certain this only happens after a system suspends or if it always happens. but but after a start after suspension is usually when i notice it
https://discussion.fedoraproject.org/t/incorrect-system-time-after-suspending/81056

執行sudo hwclock -s命令也可以模擬筆記本合上蓋子再打開的過程,可立即復現該bug。
sudo hwclock -s命令用於將硬體時鐘RTC的時間同步到系統時鐘,即讀取主板上的硬體時鐘時間並設置為作業系統的時間。該命令等價於sudo hwclock --hctosys。
oct1158@fedora:~/Documents$ timedatectl
               Local time: Wed 2026-01-07 14:47:19 CST
           Universal time: Wed 2026-01-07 06:47:19 UTC
                 RTC time: Wed 2026-01-07 14:47:19
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no
oct1158@fedora:~/Documents$ sudo hwclock -s
oct1158@fedora:~/Documents$ timedatectl
               Local time: Wed 2026-01-07 22:47:26 CST
           Universal time: Wed 2026-01-07 14:47:26 UTC
                 RTC time: Wed 2026-01-07 14:47:26
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no
oct1158@fedora:~/Documents$ sudo hwclock -r
2026-01-07 22:49:16.122097+08:00
oct1158@fedora:~/Documents$
2樓 巨大八爪鱼 2026-1-7 15:56
【問題原因】
這是因為fedora43系統自動獲取網絡時間的功能有bug。
自動獲取網絡時間後,能正確設置系統時間,卻不能正確設置bios硬體時間(RTC)。
date命令顯示的系統時間是正確的(UTC+8),而sudo hwclock -r命令顯示的bios時間是錯誤的(UTC+16)。
巨大八爪鱼合上筆記本蓋子前,系統時間是正確的,bios硬體時間是錯誤的。
合上筆記本蓋子後再打開,fedora會自動將bios硬體時間讀回系統,所以系統時間就出錯了。
3樓 巨大八爪鱼 2026-1-7 15:57
【解決辦法】
(1)首先,bios硬體時間的時區一定要設置成UTC時區,不能設置成UTC+8時區。
如果bios硬體時間沒有設置成標準的UTC時區的話,執行timedatectl命令會看到醒目的黃色警告。
oct1158@fedora:~/Documents$ timedatectl
               Local time: Tue 2026-01-06 16:11:03 CST
           Universal time: Tue 2026-01-06 08:11:03 UTC
                 RTC time: Tue 2026-01-06 16:11:03
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: yes
 
Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.
        
此時需要執行sudo timedatectl set-local-rtc 0命令,將bios硬體時間的時區設置成UTC時區。
oct1158@fedora:~/Documents$ sudo timedatectl set-local-rtc 0
[sudo] password for oct1158:
這樣再次執行timedatectl命令,黃色警告就消失了。
oct1158@fedora:~/Documents$ timedatectl
               Local time: Tue 2026-01-06 16:11:49 CST
           Universal time: Tue 2026-01-06 08:11:49 UTC
                 RTC time: Tue 2026-01-06 08:11:49
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

oct1158@fedora:~/Documents$

4樓 巨大八爪鱼 2026-1-7 15:58
(2)開啟一下fedora系統的自動獲取網絡時間和時區的功能,等待系統時間(date)變成正確的UTC+8時間,系統時區變成正確的UTC+8時區。與此同時bios硬體時間(sudo hwclock -r)會變成錯誤的時間。
oct1158@fedora:~/Documents$ date
Wed  7 Jan 14:58:09 CST 2026
oct1158@fedora:~/Documents$ sudo hwclock -r
2026-01-07 22:58:11.948348+08:00
oct1158@fedora:~/Documents$

此時,立即關閉fedora系統的自動獲取網絡時間和時區的功能,以後不要再開了。

5樓 巨大八爪鱼 2026-1-7 15:59
(3)將系統時間寫入bios硬體時間,使bios硬體時間變成正確的時間。
oct1158@fedora:~/Documents$ sudo hwclock -r
2026-01-07 23:00:39.841509+08:00
oct1158@fedora:~/Documents$ sudo hwclock --systohc
oct1158@fedora:~/Documents$ sudo hwclock -r
2026-01-07 15:00:45.725250+08:00
oct1158@fedora:~/Documents$
這樣一來,問題就解決了。
巨大八爪鱼現在再執行sudo hwclock -s命令從硬體時間設置系統時間,就不再出問題了。
6樓 巨大八爪鱼 2026-1-8 20:03
https://zhuanlan.zhihu.com/p/1992686405210624448

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張