Ubuntu 22.04 与 Windows 11 双系统时间不一致

理解 RTC 的 UTC 与本地时间解释差异,并在 Ubuntu 22.04 / Windows 11 双系统中选择一种一致策略。

适用环境:Ubuntu 22.04 LTS + Windows 11 双系统。以下设置会影响主板 RTC 的解释方式;修改后请分别进入两套系统核对时区与自动校时。

双系统时间相差数小时,通常不是网络校时失败,而是两套系统对主板硬件时钟(RTC)的理解不同:Linux 通常把 RTC 视为 UTC,Windows 默认倾向把 RTC 当本地时间。

更适合双系统的做法:让 Ubuntu 使用本地 RTC

在保留 Windows 默认行为的情况下,可在 Ubuntu 执行:

1
2
sudo timedatectl set-local-rtc 1 --adjust-system-clock
timedatectl

看到 RTC in local TZ: yes 即表示设置生效。--adjust-system-clock 会根据当前 RTC 重新调整系统时钟;执行前确认 Ubuntu 的时区已设为正确的地区,例如:

1
timedatectl set-timezone Asia/Shanghai

另一种策略:让 Windows 使用 UTC

也可以通过 Windows 注册表让 Windows 使用 UTC。不过这会影响 Windows 恢复、休眠、与某些设备工具的兼容性,且变更应由熟悉 Windows 注册表的用户完成。对于普通的 Ubuntu + Windows 双系统,优先选择上面的 Ubuntu 侧设置,改动更集中、回退也更简单:

1
sudo timedatectl set-local-rtc 0 --adjust-system-clock

验证清单

  1. 在 Ubuntu 执行 timedatectl,确认时区与 NTP 同步状态。
  2. 重启进 Windows 11,确认时区自动设置正确。
  3. 再重启回 Ubuntu,核对时间没有偏移。

若时间每次开机都随机跳变,还应检查 BIOS 时间与主板 CMOS 电池,而不是反复修改系统设置。

出处

本文将原始 Windows 10 场景更新为 Windows 11,并采用 Ubuntu 22.04 可用的 timedatectl 方式。