Ubuntu resets windows time. The time is lost in Ubuntu and Windows. Configuring windows to work using utc

There are times when when installing a second system, this usually happens linux, the time in the systems begins to go wrong, for example, you were working under your linux and decided to move to windows, and found that the time and date are completely wrong, or vice versa, this is due to differences in the time format, these operating systems work with it differently, a little theory, and so, let's start with linux, these operating systems work with UTC
UTC- both hardware and software clocks are based on Greenwich Mean Time. That is, the clock gives universal time in the zero time zone. For example, if your time zone is GMT+3, Moscow, then the clock will be three hours behind. And users locally add to this time a correction for the time zone, for example, plus +3. Each user adds the amendment he needs. This is done on the servers so that each user can get the correct time for their time zone.
windows in turn works with localtime
localtime- in this version, the software clock also runs according to Greenwich Mean Time, but the hardware clock runs according to the time of the local time zone. There is no difference for the user; you still need to add an adjustment to your time zone. But when loading and synchronizing the time, Windows subtracts 3 hours (or some other time zone adjustment) from the hardware time so that the software time is correct.
so, we seem to have sorted out the theory, now let’s move on to practice, and so, at the beginning we’ll load up on our windows, launch the console as administrator and execute commands for a 32-bit system
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
or for 64 bit
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1
but the clock will still be synchronized with the server time; to do this, turn off the clock synchronization service
sc config w32time start= disabled
Now we reboot our system and launch linux login to the terminal under root and execute the commands
timedatectl set-local-rtc 1 --adjust-system-clock
And
sed -i "s/UTC=yes/UTC=no/" /etc/default/rcS
look at the status of the hardware clock
sudo timedatectl
Now we reboot again, enter bios and set the date and time, check...
if for some reason we need to disable all this, then we execute the commands in Linux
timedatectl set-local-rtc 0
And
sed -i "s/UTC=no/UTC=yes/" /etc/default/rcS
in windows, console as administrator
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 0
And
sc config w32time start= demand
Another option would be the following, in linux debian and derivatives
run the command to set the local time
sudo hwclock --localtime --adjust
if we want to return it back
sudo hwclock --utc --adjust
now let's check
timedatectl | grep local
if the answer
RTC in local TZ: no
then our time is ticking according to Greenwich, if the answer
RTC in local TZ: yes
that means our time is ticking according to the system established
that's all, I think it was useful to you

Many new users who have just switched to Linux from the Windows operating system, and still run this system from time to time, are faced with the problem that after windows loading In ubuntu, the time goes back or forward a few hours, then after several reboots it is already difficult to understand what time it is. All this happens due to differences in the time storage format in these operating systems Oh. And it will happen every time you reboot, no matter how much you install right time. But this problem can be solved. And even in several ways. In this article we will look at how to solve the problem of time getting lost in Ubuntu and Windows.

CONFIGURING WINDOWS TO WORK WITH UTC

So, if you're confused windows time and linux when switching between operating systems, the best way will force Windows to work in a more correct and logical format. To do this, just add one registry key. You can do this with one command in the console. To open the console in Windows 10, move your mouse to the bottom left corner, then click right button. IN context menu select Command line(administrator):

> Reg add HKLM\SYSTEM\CurrentControlSet\Control\Ti meZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1

And for 64-bit, you need to use the REG_QWORD value type:

> Reg add HKLM\SYSTEM\CurrentControlSet\Control\Ti meZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1

Target="_blank">https://losst.ru/wp-content/uploads/2016/10/utc-windows-600x139-300x70.png 300w" width="600" />

Almost ready, but the Windows time service, regardless of this setting, will write the time in local format when updating it via the Internet, so it is convenient to disable this service. To do this, run:

> sc config w32time start= disabled

HOW TO RETURN BACK?

If you want to return everything to the way it was, then this can be done as easily as possible. First we return the registry key to the correct position:

> Reg add HKLM\SYSTEM\CurrentControlSet\Control\Ti meZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 0

And start the synchronization service back:

> sc config w32time start= demand

CONFIGURING LINUX FOR LOCALTIME

By default, Linux uses the UTC time format, but if Ubuntu 16.04 messes with Windows time, you can very easily force the system to store local time in the hardware timer. On all distributions that use Systemd, including Ubuntu 16.04, all you need to do is run the command:

Sudo timedatectl set-local-rtc 1 --adjust-system-clock

To view the current state of the hardware and software clocks, run:

Sudo timedatectl

Target="_blank">https://losst.ru/wp-content/uploads/2016/10/rtc-localtime-600x242-300x121.jpg 300w" width="600" />

Done, you can now restart your computer and start Windows to make sure that the time does not get lost when rebooting. On older Ubuntu systems, you need to edit the /etc/default/rcS file and replace UTC=yes with UTC=no. You can do this with the command:

Sudo sed -i "s/UTC=yes/UTC=no/" /etc/default/rcS

HOW TO RETURN BACK?

Again, you can return everything as it was with one command:

Sudo timedatectl set-local-rtc 0

And in older Ubuntu distributions:

Sudo sed -i "s/UTC=no/UTC=yes/" /etc/default/rcS

CONCLUSIONS

That's all. Now if you encounter windows problem 10 - gets lost ubuntu time or any other Linux distribution, you will already know how to solve it using two completely working methods.

Many new users who have just switched to Linux from the Windows operating system, and still run this system from time to time, are faced with the problem that after loading Windows in Ubuntu, the time goes back or forth several hours, then after several reboots it’s already difficult understand what time it is now.

All this happens due to differences in the time storage format in these operating systems. And it will happen every time you reboot, no matter how much you set the correct time. But this problem can be solved. And even in several ways. In this article we will look at how to solve the problem of time getting lost in Ubuntu and Windows.

As I already said, the problem is in different formats for storing and restoring time. There are two types of clocks on the computer. Hardware clocks are always running, even when the computer is turned off and the software clock is built into the kernel. When the computer is turned on, the value of the hardware clock is written to the software clock, and subsequently the operating system takes the time from there. But Windows and Linux operate differently with these two clocks. There are two ways to work:

  • UTC- both hardware and software clocks are based on Greenwich Mean Time. That is, the clock gives universal time in the zero time zone. For example, if your time zone is GMT+3, Kyiv, then the clock will be three hours behind. And users locally add to this time a correction for the time zone, for example, plus +3. Each user adds the amendment he needs. This is done on the servers so that each user can get the correct time for their time zone.
  • localtime- in this version, the software clock also runs according to Greenwich Mean Time, but the hardware clock runs according to the time of the local time zone. There is no difference for the user; you still need to add an adjustment to your time zone. But when loading and synchronizing the time, Windows subtracts 3 hours (or some other time zone adjustment) from the hardware time so that the software time is correct.

So why does Ubuntu and Windows time get lost? Let's say Windows is running, and over time everything is fine there, it is saved in localtime format. But when you reboot into Linux, the operating system takes Localtime and thinks it is UTC. Thus, the user will take the already correct time and add to it a correction for the time zone. Therefore, the time will no longer be correct.

Next, you corrected the time, and now the hardware clock works in UTC. But then load WIndows. The system thinks that this is Localtime and, to set the correct software time, adds a time zone correction to the hardware, for example, in our case +3. Then each user applies this correction again and the time is already off, again.

The only sure way to solve this problem is to make both systems work using the same format, and this is not at all difficult. Moreover, you can go in two ways: either make Windows work in UTC, or Linux in the Localtime format, which is not entirely correct, but quite possible. So let's move on to solving the problem of the time getting lost in Ubuntu.

Configuring Windows to work in UTC

So, if you experience windows and linux timing problems when switching between operating systems, the best way is to force Windows to work in a more correct and logical format. To do this, just add one registry key. You can do this with one command in the console. To open the console in Windows 10, move your mouse to the lower left corner, then click the right button. From the context menu, select Command Line (Administrator):

> Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1

And for 64-bit, you need to use the REG_QWORD value type:

> Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1

Almost ready, but the Windows time service, regardless of this setting, will write the time in local format when updating it via the Internet, so it is convenient to disable this service. To do this, run:

> sc config w32time start= disabled

How can I get it back?

If you want to return everything to the way it was, then this can be done as easily as possible. First we return the registry key to the correct position:

> Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 0

And start the synchronization service back:

> sc config w32time start= demand

Configuring Linux to run localtime

By default, Linux uses the UTC time format, but if Ubuntu 16.04 messes with Windows time, you can very easily force the system to store local time in the hardware timer. On all distributions that use Systemd, including Ubuntu 16.04, all you need to do is run the command:

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

To view the current state of the hardware and software clocks, run:

sudo timedatectl

Done, you can now restart your computer and start Windows to make sure that the time does not get lost when rebooting. On older Ubuntu systems, you need to edit the /etc/default/rcS file and replace UTC=yes with UTC=no. You can do this with the command:

sudo sed -i "s/UTC=yes/UTC=no/" /etc/default/rcS

How can I get it back?

Again, you can return everything as it was with one command:

sudo timedatectl set-local-rtc 0

And in older Ubuntu distributions:

sudo sed -i "s/UTC=no/UTC=yes/" /etc/default/rcS

conclusions

That's all. Now, if you encounter a problem in Windows 10 - the time is lost on Ubuntu or any other Linux distribution, you will already know how to solve it using two completely working methods. If you have any questions, ask in the comments!
We figured out how to set the correct time in Ubuntu and Windows so that time zones don’t get confused, but what are time zones and why are they needed? Let’s finish the video about it:

Using multiple operating systems on the same computer sometimes causes them to conflict with each other when they use the same thing. Sometimes it concerns something as simple as time. Even such popular PC operating systems as Windows and Ubuntu can not get along and constantly change each other's time to the incorrect one.

The reasons for this phenomenon are actually simple: Windows perceives the system time (which is displayed in the CMOS settings) as local (taking into account the time zone), and Ubuntu - according to UTC (Greenwich Mean Time, not taking into account the time zone). Because of this, they adjust the system time to suit their logic, violating each other's logic.

The solution to the problem is also simple: either force Windows to add a time zone offset to the system time, or prevent Ubuntu from adding this offset.

Settings in Ubuntu

Starting from version 16.04, time display settings can be switched using two commands.

Enabling local time display:
sudo hwclock --localtime --adjust

Enabling UTC display:
sudo hwclock --utc --adjust

In older versions of Ubuntu you need to edit the rtC file:

sudo nano /etc/default/rcS

You need to add (to display local time) or remove this line (to display UTC time):

Settings in Windows

Almost everything on Windows system settings are edited in the registry; TimeZoneInformation, which is necessary in this situation, is no exception. It is located in the registry at this address:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation

Here you need to add or change the RealTimeIsUniversal parameter. Its type is DWORD. In order for the system time to be read in UTC, you need to set the value to 1; to recognize it as local, you need to set the value to 0 or completely remove this parameter.

The Registry Editor can be launched using the regedit command.

In UEFI mode ( secure boot). My BIOS time is correct.

When I boot into Ubuntu and then boot into Windows 10, it shows the wrong time. I have to fix it manually or online in Windows 10 and when I reboot into Windows 10 it is not a problem. The clock shows the correct time. And then when I reboot into Linux the clock is correct, but when going back to Windows 10 the clock starts working again.

Operating systems store and retrieve time in the hardware clock located on your motherboard to keep track of time even when the system is not powered. Most operating systems (Linux/Unix/Mac) store the time on the hardware clock as UTC by default, although some systems (notably Microsoft Windows) store the time on the hardware clock as "local" time. This causes problems in the system dual boot if both systems treat the hardware clock differently.

The advantage of using a hardware clock as UTC is that you don't have to change the hardware clock when moving between time zones or when Daylight Saving Time (DST) starts or ends, since UTC has no time or time offsets.

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

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

Make Windows use UTC

Note. This method was not originally supported in Windows Vista and Server 2008, but returned with Vista SP2, Windows 7, Server 2008 R2 and Windows 8/8.1.

So that MS Windows calculates the time from the hardware clock in UTC format.

Create a file named WindowsTimeFixUTC.reg with the following content, and then double-click it to merge the content into the registry:

Windows Registry Editor Version 5.00 "RealTimeIsUniversal"=dword:00000001

Note. The Windows Time service will still record local time in the RTC regardless of the registry setting above when turned off, so it is convenient to disable the Windows Time service using this command (if time synchronization is required while Windows is using some third party time synchronization):

Sc config w32time start= disabled

Cancel change

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

Windows Registry Editor Version 5.00 "RealTimeIsUniversal"=-

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

Sc config w32time start= demand

Make Linux "local" time

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

  1. change /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 and higher systems (eg Ubuntu 16.04 LTS):

    open a terminal and run the following command