- [Fix] Windows Showing Wrong Time in Linux-Windows Dual-boot System
- Method 1: Linux Side Fix (Make Linux use “Local” Time)
- Method 2: Windows Side Fix (Make Windows use “UTC” Time)
- Author: Jaber Al Nahian
- How to Fix Time Differences in Ubuntu 16.04 & Windows 10 Dual Boot
- Dual Boot: Fix Time Differences Between Ubuntu And Windows
- Fix time differences between Ubuntu and Windows
- How to revert the changes
- Сбивается время в Ubuntu и Windows
- Почему так происходит?
- Настройка Windows для работы по UTC
- Как вернуть обратно?
- Настройка Linux для работы localtime
- Как вернуть обратно?
- Выводы
[Fix] Windows Showing Wrong Time in Linux-Windows Dual-boot System
If you have a computer where a Linux OS (e.g. Ubuntu) is dual-booted with Windows, you will notice that, every time you reboot from Linux to Window, clock time displaying incorrectly in Windows. Even some Linux may show incorrect time if you are returning from Windows. Here’s how to solve this.
To keep track of proper time, Operating Systems make use of BIOS time settings from your computer’s motherboard. Because BIOS has the ability to keep running the clock even if your system is turned off (using CMOS memory and battery). Different Operating Systems may use different methods to store clock/time information in BIOS. For example, Unix and Linux based systems (e.g. Debian, Ubuntu, Mac, BSD, etc.) use “UTC” time format while Windows uses “Local time” format to write to BIOS clock settings. UTC (GMT) is better as you don’t have to change hardware time when you move to another timezone.
The problem happens when you install multiple Operating Systems with multi-boot procedure on same computer which shares same motherboard. As the same BIOS clock settin is used by all OS present on the computer, when you reboot from one to another, they read each other’s BIOS clock settings incorrectly. This is why your Windows or Linux is showing wrong time when switching from each other. However, Boot Camp in Mac system has fix for this.
To fix this problem, you need to change how an OS stores its clock data to BIOS. You should do it either from Windows side, or from Linux side. Not both!
Method 1: Linux Side Fix (Make Linux use “Local” Time)
We need to edit the file /etc/default/rcS and set UTC=no. You can do it normally by using any text editor or use following method if you have gedit installed.
- Open Terminal (press Ctrl+Alt+T for quick access) and type the following command and hit Enter.
- Type your password when it asks and hit Enter. This will give you root access.
- Now type the following command and hit Enter to open /etc/default/rcS file with gedit text editor.
- This will Open that rcS file in gedit. Notice “UTC” is set to “yes” there.
- Replace “yes” with “no” as following and click Save on toolbar.
- Close both gedit and Terminal. You are done!
Above guide is applicable for most Debian based Linux OSes like Ubuntu, Linux Mint, etc. and many other non-Debian Linux. You can checkout UbuntuTime help page.
On Fedora, openSUSE, ArchLinux, Some Debian versions: Replace the word UTC with the word LOCAL in /etc/adjtime file. In case the file doesn’t exist, create the file with following contents:
0.0 0 0.0
0
LOCAL
On Red Hat: Replace “UTC=true’‘ with “UTC=false” in “UTC” line of the file /etc/sysconfig/clock.
If you can’t find related file in your version of Linux Distro, check out clock/time configuration documentation page on your Operating System’s official site or try Windows side fix. However, many other factors are also involved regarding UTC vs Local preference in Linux clock system.
If you have more than one Linux OS installed on the same machine, make this change for all Linuxes.
Method 2: Windows Side Fix (Make Windows use “UTC” Time)
This fix is tested on Windows 10, Window 8.x, Windows 7 and Vista Service Pack 2. Any lower version of Windows will be supported.
- Press Windows+R key and type regedit and hit OK. This will open Windows Registry Editor.
- Navigate to the location HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation.
- From left side, right-click on TimeZoneInformation folder and then select New >DWORD (32-bit) Vlaue.
- Rename the new entry to RealTimeIsUniversal.
- Now double-click on the entry RealTimeIsUniversal and set Value data 1. Hit OK then.
- Close Registry Editor.
In case you want to revert this, simply delete the entry RealTimeIsUniversal.
Now the problem is “Windows Time service” will still write “local time” to hardware clock setting. So we need to disable it and prevent it from auto starting. To do so,
- Press Windows+R key and type services.msc and hit OK. This will open Windows Service manager.
- Locate Windows Time and double-click on it.
- Choose Disabled under Startup type and hit Apply.
- You are done!
Note: Syncing your Windows clock with internet using buit-in “Date and Time” settings will make “Window Time service” again start.Thus it will break your preference. Try to use a third-party tool to sync it.
You can always change these setting if you decide to keep Windows clock in local time.
If you have more than one Windows (such as Windows 10 and Windows 7) installed on same system, do this change for all Windows versions.
Again, use either Windows fix, or Linux. Not both.
Tell us how you managed to keep your both Window and Linux time accurate in your multi-boot computer.
Author: Jaber Al Nahian
Jaber is a Programmer and Tech Enthusiast Geek from Dhaka, Bangladesh. He is the founder and Chief-Editor of TechGainer. While he is away from his keyboard, either he’s fishing or messing with wildlife. In case, you can contact him at rijans[at]techgainer[dot]com.
How to Fix Time Differences in Ubuntu 16.04 & Windows 10 Dual Boot
For users who dual boot Ubuntu 16.04 and Windows, you may find the clock time is off that causes time differences after you reboot and switch between the two systems. Here’s how to fix it.
Ubuntu maintains the hardware clock (RTC, real time clock) in universal time (UTC) by default while Windows maintains the clock in local time, thus causing time conflicts between Ubuntu and Windows.
To fix it, either set Ubuntu to maintain RTC in local time or make Windows uses UTC.
1. Disable UTC and use Local Time in Ubuntu:
In previous Ubuntu editions, you can edit the config file /etc/default/rcS to disable UTC.
In Ubuntu 16.04, open terminal (Ctrl+Alt+T) and run the command below instead:
To check out if your system uses Local time, just run:
you’ll the local time zone is in use in the Warning section.
Finally restart and switch to Windows, adjust system clock time if need and done.
2. Make MicroSoft Windows uses UTC:
Another way to fix this issue is doing the following changes in Windows, Windows 10, in the case below:
1.) First if you’ve switched to local time in Ubuntu, run command in Ubuntu terminal to use back UTC:
2.) Restart and select boot into Windows 10, when you’re in, do:
- go to Start Menu, search for and launch cmd as Administrator.
- When the command console opens, paste below command to create a DWORD value to the registry:
For 64-bit Windows, use a QWORD value instead:
Dual Boot: Fix Time Differences Between Ubuntu And Windows
Author : Andrew | Posted: September 08, 2014
Fix time differences between Ubuntu and Windows
A. To fix the UTC / local time difference between Ubuntu and Windows from Ubuntu by making Ubuntu use local time.
For Ubuntu 16.04 and newer, run the following command (thanks to Erwinson Pagtalunan for the update!):
You can then check if Ubuntu uses local time, you can then use the following command:
Which should display the following «RTC in local TZ: yes». A warning will also be displayed. Here’s the full command output:
For Ubuntu versions older than 16.04: you must edit the /etc/default/rcS file and replace «UTC=yes» with «UTC=no» (both without the quotes). To do this automatically, simply copy/paste the following command in a terminal:
How to revert the changes
A. From Ubuntu: reverting this change from Ubuntu is pretty easy.
Ubuntu 16.04 and newer: to revert the changes, simply run the following command:
Ubuntu versions older than 16.04: all you have to do is replace «UTC=no» with «UTC=yes» in the /etc/default/rcS file. To do this automatically, copy/paste the command below in a terminal:
Firstly, open the .reg file downloaded when applying the fix for Windows (see download link above) with a text editor and change the «RealTimeIsUniversal» value from «dword:00000001» to «-» (without the quotes). Here’s how the file should look like after making this change:
Then save the file and double click it.
Сбивается время в Ubuntu и Windows
Многие новые пользователи, которые только перешли на Linux с операционной системы Windows, и пока все еще запускают эту систему время от времени, сталкиваются с проблемой, что после загрузки Windows в Ubuntu сбивается время на несколько часов назад или вперед, затем после нескольких перезагрузок уже сложно понять какое сейчас время.
Все это происходит из-за различий формата хранения времени в этих операционных системах. И будет происходить при каждой перезагрузке, сколько бы вы ни устанавливали правильное время. Но эту проблему можно решить. И даже несколькими способами. В этой статье мы рассмотрим, как решить проблему сбивается время в Ubuntu и Windows.
Почему так происходит?
Как я уже сказал, проблема в разных форматах хранения и восстановления времени. В компьютере есть два вида часов. Аппаратные — идут всегда, даже когда компьютер выключен и программные часы, встроенные в ядро. Когда компьютер включается значение аппаратных часов записывается в программные, и в дальнейшем операционная система берет время оттуда. Но Windows и Linux работают по-разному с этими двумя часами. Есть два способа работы:
- UTC — и аппаратные, и программные часы идут по Гринвичу. То есть часы дают универсальное время на нулевом часовом поясе. Например, если у вас часовой пояс GMT+3, Киев, то часы будут отставать на три часа. А уже пользователи локально прибавляют к этому времени поправку на часовой пояс, например, плюс +3. Каждый пользователь добавляет нужную ему поправку. Так делается на серверах, чтобы каждый пользователь мог получить правильное для своего часового пояса время.
- localtime — в этом варианте программные часы тоже идут по Гринвичу, но аппаратные часы идут по времени локального часового пояса. Для пользователя разницы никакой нет, все равно нужно добавлять поправку на свой часовой пояс. Но при загрузке и синхронизации времени Windows вычитает из аппаратного времени 3 часа (или другую поправку на часовой пояс), чтобы программное время было верным.
Так почему же сбивается время Ubuntu и Windows? Вот, допустим, работает Windows, и со временем там все нормально, оно сохранено в формате localtime. Но при перезагрузке в Linux, операционная система берет время Localtime, и думает что это UTC. Таким образом, пользователь будет брать уже правильное время, и прибавлять к нему поправку на часовой пояс. Поэтому время уже будет неверным.
Дальше вы исправили время, и теперь аппаратные часы работают в UTC. Но затем грузите WIndows. Система думает, что это localtime и для установки правильного программного времени добавляет к аппаратному поправку на часовой пояс, например, в нашем случае +3. Дальше каждый пользователь еще раз применяет эту поправку и время уже сбито, опять.
Единственно верный способ решить эту проблему — заставить обе системы работать по одному формату и сделать это совсем не сложно. Причем можно пойти двумя путями: либо заставить Windows работать по UTC, либо Linux по формату localtime, что является не совсем правильным, но вполне возможно. Итак перейдем к решению проблемы сбивается время в Ubuntu.
Настройка Windows для работы по UTC
Итак, если у вас сбивается время Windows и Linux при переключении между операционными системами, лучшим способом будет заставить Windows работать по более правильному и логичному формату. Для этого достаточно добавить один ключ реестра. Вы можете сделать это с помощью одной команды в консоли. Чтобы открыть консоль в Windows 10 проведите мышь в левый нижний угол, затем нажмите правую кнопку. В контекстном меню выберите Командная строка (администратор):
Дальше наберите команду для 32 битных систем:
> Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
А для 64-битных, нужно использовать тип значения REG_QWORD:
> Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1
Почти готово, но служба времени Windows независимо от этой настройки будет писать время в местном формате при обновлении его через интернет, поэтому удобно эту службу отключить. Для этого выполните:
> sc config w32time start= disabled
Как вернуть обратно?
Если вы хотите вернуть все как было, то сделать это можно проще простого. Сначала возвращаем ключ реестра в правильное положение:
> Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 0
И запускаем обратно службу синхронизации:
> sc config w32time start= demand
Готово, а дальше рассмотрим, как заставить Linux использовать формат времени localtime.
Настройка Linux для работы localtime
По умолчанию Linux использует формат хранения времени UTC, но если Ubuntu сбивает время Windows, вы можете очень просто заставить систему хранить в аппаратном таймере местное время. Во всех дистрибутивах, использующих Systemd, в том числе в Ubuntu для этого достаточно выполнить команду:
sudo timedatectl set-local-rtc 1 —adjust-system-clock
Чтобы посмотреть текущее состояние аппаратных и программных часов выполните:
Готово, теперь вы можете перезапустить компьютер и запустить Windows, чтобы убедиться, что время не сбивается при перезагрузке. В более старых системах Ubuntu, вам нужно отредактировать файл /etc/default/rcS и заменить UTC=yes на UTC=no. Вы можете сделать это командой:
sudo sed -i ‘s/UTC=yes/UTC=no/’ /etc/default/rcS
Как вернуть обратно?
Опять же, вернуть все как было можно с помощью одной команды:
sudo timedatectl set-local-rtc 0
А в старых дистрибутивах Ubuntu:
sudo sed -i ‘s/UTC=no/UTC=yes/’ /etc/default/rcS
Выводы
Вот и все. Теперь, если вы столкнетесь с проблемой Windows 10 — сбивается время Ubuntu или любом другом Linux дистрибутиве, вы уже будете знать, как её решить с помощью двух полностью работающих способов. Если у вас остались вопросы, спрашивайте в комментариях!
Мы разобрались, как настроить правильное время в Ubuntu и Windows, чтобы временные зоны не сбивались, но что такое временные зоны и зачем они нужны, на завершение видео про это: