当前位置: 首页>>技术问答>>正文


从Ubuntu切换到Windows 10后,时钟显示错误的时间

, , ,

问题描述

我在UEFI模式下启动了双启动Windows 10和Ubuntu 16.04(安全启动关闭)。我在BIOS中的时间是正确的。

当我启动进入Ubuntu然后启动到Windows 10时,它显示错误的时间。我必须在Windows 10中手动或通过互联网进行更正,当我重新启动到Windows 10时,这不是问题。时钟将显示正确的时间。然后当我重新启动到Linux时,时钟是正确的,但切换回Windows 10,时钟再次混乱。

最佳解决方案

Multiple Boot Systems Time Conflicts

Operating systems store and retrieve the time in the hardware clock located on your motherboard so that it can keep track of the time even when the system does not have power. Most operating systems (Linux/Unix/Mac) store the time on the hardware clock as UTC by default, though some systems (notably Microsoft Windows) store the time on the hardware clock as the ‘local’ time. This causes problems in a dual boot system if both systems view the hardware clock differently.

The advantage of having the hardware clock as UTC is that you don’t need to change the hardware clock when moving between timezones or when Daylight Savings Time (DST) begins or ends as UTC does not have DST or timezone offsets.

Changing Linux to use local time is easier and more reliable than changing Windows to use UTC, so dual-boot Linux/Windows systems tend to use local time.

Since Intrepid (8.10), UTC=yes is default.

Solution 1: Make Windows use UTC

Note: This method was not initially supported on Windows Vista and Server 2008, but came back with Vista SP2, Windows 7, Server 2008 R2 and Windows 8/8.1.

To make MS Windows calculate the time from the hardware clock as UTC.

Create a file named WindowsTimeFixUTC.reg with the following contents and then double click on it to merge the contents with the registry:

Windows Registry Editor Version 5.00  [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]  "RealTimeIsUniversal"=dword:00000001 

Note: Windows Time service will still write local time to the RTC regardless of the registry setting above on shutdown, so it is handy to disable Windows Time service with this command (if time sync is still required while in Windows use any third-party time sync solution):

sc config w32time start= disabled 

Reversing the change

You can create a file with the following contents and then double-click it to merge in the original changes, as above:

Windows Registry Editor Version 5.00  [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]  "RealTimeIsUniversal"=- 

If Windows Time service was disabled, enable it again with the command:

sc config w32time start= demand 

Solution 2: Make Linux use ‘Local’ time

To tell your Ubuntu system that the hardware clock is set to ‘local’ time:

Pre-Ubuntu 15.04 systems (e.g. Ubuntu 14.04 LTS):

  1. edit /etc/default/rcS
  2. add or change the following section

    # Set UTC=yes if your hardware clock is set to UTC (GMT) UTC=no 

Ubuntu 15.04 systems and above (e.g. Ubuntu 16.04 LTS):

  1. open a terminal and execute the following command

    timedatectl set-local-rtc 1 

来源:Ubuntu Help

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/2463.html,未经允许,请勿转载。