当前位置: 首页>>技术教程>>正文


双启动时钟时间不可用

, , ,

问题描述

双启动系统Windows XP Pro和Ubuntu 12.04。

我已经设置了正确的时间和Ubuntu设置为美国东部时间的BIOS。 Ubuntu将会启动,时间会缩短-4小时。如果我在Ubuntu中更正时间,那么当我在Windows XP中启动时,时间将会减少+4小时。

这是12.04的全新安装。在重新安装Ubuntu之前,我没有这个问题。

最佳解决办法

https://help.ubuntu.com/community/UbuntuTime#Multiple_Boot_Systems_Time_Conflicts

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.

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 

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 

次佳解决办法

要在systemd-based版本(15.04及更高版本)中将BIOS时钟设置为本地时间而不是UTC,则必须使用timedatectl命令。根据the Arch Wiki

You can set the hardware clock time standard through the command line. You can check what you have set to use by:

$ timedatectl | grep local 

The hardware clock can be queried and set with the timedatectl command. To change the hardware clock time standard to localtime, use:

# timedatectl set-local-rtc 1 

If you want to revert to the hardware clock being in UTC, do:

# timedatectl set-local-rtc 0 

第三种解决办法

您的时区是Eastern,目前是EDT(东部夏令时)。 EDT是UTC减去四小时,与您正在经历的偏移相同。

当这发生在dual-boot系统上时,通常是因为一个操作系统认为硬件时钟跟踪本地时间,而另一个操作系统认为硬件时钟跟踪UTC。

在你的情况下,你的硬件时钟可能设置为当地时间,并且:

  • Windows设置为使用本地时间,其中(给定您的时间设置)是正确的。

  • Ubuntu设置为使用UTC,但是(给定您的时间设置)不正确。

如果您只是在Ubuntu系统中重置时间,无论是手动还是automatically,那么在Windows中都会出错,所以这不是一个好的解决方案。

相反,最好的解决方案可能是重新配置Ubuntu,将硬件时钟当作本地时间(然后可以让Windows配置和硬件时钟单独运行)。

为此,请以root用户身份编辑/etc/default/rcS,并确保它具有UTC=no

  1. Alt + F2

  2. 键入gksu gedit /etc/default/rcS并按Enter

  3. 您可能会看到:# assume that the BIOS clock is set to UTC time (recommended)
    UTC=yes

    • 如果是这样,请将UTC=yes更改为UTC=no。 (或者,您也可以通过将其更改为类似UTC=no # changed to accommodate Windows system的方式来添加评论.#字符后的所有内容都是注释,并且只是为了让您的设置更符合human-readable。)

    • 如果你不这样做,请查找任何UTC=行。如果未注释(即开始时没有#),请相应更改它。如果发表评论,请通过删除主要的#来取消注释,并确保它显示UTC=no

  4. 保存文件并退出文本编辑器。

  5. 重新启动以应用您的更改,并检查现在两个操作系统上的时间是否正常工作。

来源:https://help.ubuntu.com/community/UbuntuTime#Make_Linux_use_.27Local.27_time

(但这是非常普遍的;我已经写出了这个答案,专门适用于你的情况,这是一个比较常见的问题。)

第四种办法

/etc /rcS修补程序在我的Win7 /Ubuntu 14.04×64安装上不起作用,也没有通过时钟GUI进行修复。因为问题的根源在于BIOS时间VS UTC时间,而Windows在使用UTC时很痛苦,所以我在Map上选择了一个使用UTC + 0的点(在BIOS和UTC时间之间没有变化) 。

尝试改变你的位置到冰岛首都雷克雅未克(Reykjavik)。瞧!你的Ubuntu时间将改变,以匹配你的BIOS时间。

参考资料

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