Linux and Windows at different times. Is the time going wrong? Another reason…. Solution using Mac OS X
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.
CONFIGURING WINDOWS TO WORK WITH 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\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 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.
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 a 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 on a dual boot system 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 changing Windows 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 originally not 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:
- change /etc/default/rcS
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
In this article, I talked about the reasons and their solutions if the date and time on your computer is lost. This article dealt with common problems regardless of the number of operating systems installed on your laptop and system unit.
Today we’ll talk about the problem when the time, namely the clock, goes wrong by several hours, as if the time zone is changing. This problem arose for me after I started using two Linux and Windows operating systems on my PC at the same time.
This problem turns out to be not so new. To solve this problem, many problems have been written on the Internet.
The essence of the problem is if the time is wrong.
There are two operating systems on the PC, namely Linux and Windows.
I'm running Linux - the time is normal.
I did some work and rebooted into windows - the time shows several hours earlier (or later, I don’t remember exactly).
I set the time, set up automatic synchronization with the Internet, but nothing helped. The problem cannot be solved in a simple way. I searched the Internet and it turns out that the problem is that the computer has two types of clocks, hardware and software.
The hardware clock always runs, even when the computer is turned off, there is an additional battery, an accumulator on the board. It maintains the passage of time and saves settings.
Program time, it is written into the program when turned on and then taken from there.
Windows and Linux work differently with these clocks, hence the timing glitch when rebooting from one operating system to another.
Here. What is written about this on other sites about this:
How to solve this problem?
Make windows and linux work the same with this hardware clock.
On the Internet, on the topic “time is lost,” it is written that the right solution would be to make Windows work correctly. Linux works correctly, according to many people.
This means that Windows needs to be made to work like Linux over time.
The process of solving the problem itself.
You need to add the key to the registry of your Windows operating system.
There are ways to add this key using a command, using the command line. We will do everything by hand in order. And it will be clear to ourselves what we did, and our brains will work a little.
Call the Execute window using a keyboard shortcut +R. Or just select execute from the menu.
Type regedit and click OK.
The Registry Editor will open.
Go to the registry branch along the path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
There, in the left half of the editor, right-click and click create parameter
For x32 bit DWORD systems
For x64 bit QWORD systems
Give it the name RealTimeIsUniversal
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:
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, but 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