Linux与Windows双系统共存时,由于两者的时间计算策略不同,导致两者时间相差8h。

问题描述:

主板BIOS中有一个时间,Windows会认为它就是当地的时间,而Linux则会认为它是UTC世界时间,会在此基础上+8h(时区不同结果不同)作为最终结果。Windows进行时间同步时会将当前时间直接存入BIOS,而Linux会在此基础上-8h后再存入BIOS。这时启动Windows,Windows会认为当前BIOS时间为当地时间,就会出现比真实时间慢8h的情况。

解决方案:

以Kali Linux为例:

完整:

┌──(nancy㉿Nancy-Kali)-[~]
└─$ timedatectl status
Local time: 六 2023-10-21 09:24:02 CST
Universal time: 六 2023-10-21 01:24:02 UTC
RTC time: 六 2023-10-21 01:24:02
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
NTP service: active
RTC in local TZ: no


┌──(nancy㉿Nancy-Kali)-[~]
└─$ timedatectl set-local-rtc 1

┌──(nancy㉿Nancy-Kali)-[~]
└─$ timedatectl status
Local time: 六 2023-10-21 09:24:31 CST
Universal time: 六 2023-10-21 01:24:31 UTC
RTC time: 六 2023-10-21 09:24:31
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
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'.

┌──(nancy㉿Nancy-Kali)-[~]
└─$


仅命令:

┌──(nancy㉿Nancy-Kali)-[~]
└─$ timedatectl status

┌──(nancy㉿Nancy-Kali)-[~]
└─$ timedatectl set-local-rtc 1

┌──(nancy㉿Nancy-Kali)-[~]
└─$ timedatectl status