Synchronizing Time Between Linux and Windows in Dual-Boot Setups
If you run both Linux and Windows on the same machine, you might notice that after rebooting, your system clock jumps by a few hours.
This happens because both systems read the same hardware clock but interpret it differently: Windows treats it as local time, while Linux treats it as UTC.
To fix this, both systems need to use the same time reference. There are two main approaches:
Use UTC for both systems (recommended):
- On Linux:
timedatectl set-local-rtc 0 --adjust-system-clock
It's not necessary because Linux uses UTC by default, but this explicitly ensures the setting.
- On Windows: Use this command:
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /t reg_dword /d 1 /f
It will add a registry key to treat the hardware clock as UTC.
You can save it in a .txt file, rename it to switch-to-utc-time.bat and run as administrator. Alternatively, open a cmd or PowerShell window as administrator, paste the line, and press Enter.
Ater applying the registry setting, restart Windows.
Use local time for both systems (Windows default):
- On Linux:
timedatectl set-local-rtc 1 --adjust-system-clock
Then reboot.
After this change, both OS clocks will stay in sync, preventing issues with logs, Git commits, scheduled tasks, or databases caused by time jumps.
What is hardware clock and where is it stored?
The hardware clock, sometimes called RTC or CMOS clock, is built into the motherboard and keeps time even when the computer is powered off.
You’ve probably remembered that small CMOS battery — the one that used to make your clock reset when it died, and maybe the one you’ve even replaced yourself.
Both Linux and Windows read this clock at startup.
Why this matters for users
If your clocks aren’t in sync, you might notice:
- Files showing the wrong creation or modification time.
- Scheduled tasks running too early or too late.
- Confusing timestamps in logs.
Why this matters for developers
For developers, having consistent system time is critical. When dual-boot clocks drift, you may encounter:
- Git commits appearing with the wrong timestamp.
- Build systems triggering unnecessary rebuilds due to “past” or “future” timestamps.
- Scheduled tasks running at unexpected times.
- Logs from different OSes or containers being misaligned.
Using UTC is generally better because it avoids timezone-related issues and daylight saving changes. Linux servers, Docker containers, CI/CD pipelines, and cloud environments almost always operate in UTC, so aligning your local machine avoids subtle bugs in development workflows.
Top comments (0)