40

Ever since I started using Linux in dualboot with Windows I noticed that when I rebooted the machine, the time on the other OS was wrong, e.g. it was 12:00 on Linux, then I rebooted and on Windows it was 18:00, and when I checked the BIOS, the RTC was set to 18:00. Since my timezone is -06:00 CST I assume Linux just sets the RTC’s time to UTC and re-calculates the time based on the timezone, whereas Windows just sets the RTC to the local time. Both use the same NTP server to sync the time.

The question is, which one is doing the right thing? On which one should I set the timezone setting to UTC in order to have the right time on both?

16

Neither is wrong, but using UTC is more right. The RTC doesn't have a time zone; it's just a dumb wall clock. If your local time zone honors DST (of which there are many flavors, and rules change arbitrarily), then twice a year, you have to go and change it. The OS will do it for you, but if the RTC is UTC, the OS does the UTC->local translation anyway -- why fiddle with the clock? Furthermore, during the DST "fall back" transition, the RTC can't tell you what time it is! Is it 1:30am CDT or CST?

Apparently, Windows 8 supports UTC for the RTC. Windows 7 also did, but there were issues.

There was a better argument against this back when people set their BIOS clocks manually, but server-based time is much more prevalent now.

68

I recently faced the same problem and this is how I fixed it. You need to do a little change in both OS.

I started with Linux first. Run these following commands as root.

ntpdate pool.ntp.org

This will update your time if not set correctly.

Now set the hardware clock to UTC with this command.

hwclock --systohc --utc

Source

Now boot to Windows and add the following registry. Just simply create a .reg file using the code below in Notepad. Save it and run it.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001

Source

From next boot onward both OS will show you the correct time.

  • 6
    Best documented answer with concrete instructions! +1. – agtoever Mar 2 '15 at 5:53
  • 1
    Should include what editions of Windows the registry tweak applies to. – Tanath Mar 2 '15 at 18:15
  • 2
    When did Windows gain the ability to understand a system clock that keeps a time other than local? – Mark Mar 2 '15 at 22:14
  • 1
    This registry tweak works for Windows XP/Vista/7/8/8.1. @Tanath – Ayan Mar 3 '15 at 1:06
  • 3
    @Mark In Windows XP. – Michael Hampton Mar 3 '15 at 12:35
4

The normal case is that Linux systems have the RTC (real-time clock) set to UTC, and the conversion to local time is done in userspace based on time zone data and the TZ environment variable. This is "less bad" because it keeps the system RTC monotonically increasing, and applies any time zone magic later, ensuring for example that no files will normally have a timestamp in the future (which can easily happen at least once a year, if the system RTC is set to local time). As Ken pointed out, the RTC itself has no concept of a time zone, only time.

As you have found, this causes issues when dual-booting with a system that does not normally operate that way, like the Microsoft family of operating systems which generally expect the RTC to be set to local time. Yes, Windows NT (I think going all the way back to NT 4, actually) can work with the RTC set to UTC, but at least last I looked it wasn't really a supported configuration and there were a number of caveats.

The easy solution in your case is probably to set the RTC to local time, tell your Linux system that the RTC is set to local time (the exact mechanics of doing this varies by distribution and release version, but apparently in Ubuntu you set UTC=no in /etc/default/rcS), and then configure the operating systems such that only one of them (preferably the one you use the most, since the time displayed in all others will be incorrect twice a year until it has been booted and had a chance to correct it) handles daylight saving time changes. And live with the downsides, which should be managable on a single-user system.

You could also set the Windows side to use UTC as a time zone and turn off automatic daylight saving time changes in Windows, and keep Linux set to have the RTC in UTC and display the time converted according to its practices. However, this will cause Windows to display the date and time in UTC, which might not be what you really want. It's not a big issue for us Europeans, who are at most something like three hours off from UTC, but might be more of an issue in the US. This is likely more realistic an option if you only use Windows occasionally, and your primary OS is Linux or some other RTC-UTC-aware OS.

  • Do you have any information about "it wasn't really a supported configuration and there were a number of caveats."? – Random832 Mar 2 '15 at 18:31
  • @Random832 Let me see if I can find that. I know I've seen it before, but now can't seem to find it with a quick google search at least. – a CVn Mar 3 '15 at 8:27
2

If you dual boot and there are time conflicts between Windows and Ubuntu, this occurs because Ubuntu store the time on the hardware clock as UTC by default while Microsoft Windows stores the time as local time, thus causing conflicting times between Ubuntu and Windows.

You need to set your Linux system to use local time as explained here in this guide for Ubuntu.

  • It IS using local time, and I am aware that it indeed stores the time as UTC (if you at least read the question), and I know what can I do to fix this, the question is which one actually does the right thing to change the other instead. – arielnmz Mar 2 '15 at 1:08
  • By default, Windows uses localtime, Mac OS uses UTC, and UNIX-like operating systems vary. An OS that uses the UTC standard, generally, will consider CMOS (hardware clock) time a UTC time (GMT, Greenwich time) and make an adjustment to it while setting the System time on boot according to your time zone. – user423645 Mar 2 '15 at 1:18
  • Again, I am aware of that, I just want to know which OS do it right so I can e.g. set windows timezone to UTC and fix this, or just the other way around. – arielnmz Mar 2 '15 at 1:21
  • @MagomedSegaIsmailov Does Mac OS run on any systems that use BIOS RTC? I'd have assumed that EFI provided some sanity. – Random832 Mar 3 '15 at 22:21
0

I'm dual booting windows 10 and remix os and simply following only the guide for windows has worked for me both times are correct. I used the command line to add you script also as it was easier

  • Please don't add "thanks" as answers. Invest some time in the site and you will gain sufficient privileges to upvote answers you like, which is the Super User way of saying thank you. – DavidPostill May 17 '16 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.