Time Clock and Windows Dual Boot

broken clock

Part of the standard way to handle time on computers is to set the hardware clock (a.k.a. the BIOS clock) to UTC. Then users can select a timezone for displaying as their system time. Contrary to this conventional way of doing things, the Windows operating system sets the hardware clock to the configured local time. Clock malfunctions tend to happen if you’re dual booting a Linux system. Posix operating systems expects the convention to be followed. Here’s how I addressed this problem.

Setting the Hardware Clock

All the following steps assume that the hardware clock is set to the correct time. If it’s not, you can adjust it in the BIOS settings or you can use hwclock. The hwclock command is for reading or setting the hardware clock (or RTC – Real Time Clock).

sudo hwclock --set --date "dd mmm yyyy HH:MM"

dd – 2 digit day of the month.
mmm – 3 letter abbreviation for the month.
yyyy – 4 digit year.
HH:MM – Hours and minutes.

Set the Hardware Clock to Local Time

There’s no sense fighting Windows for control of the clock. There is a way to edit the registry to tell Windows that the hardware clock is set to UTC, but that lead to other concerns. Just let Windows have it’s way with the clock.

You need to configure the Linux system to break with convention. The following command will inform the Linux system that the hardware clock is using local time.

sudo hwclock --localtime

Set the System Clock to Match

To synchronize the system clock to the hardware clock.

sudo hwclock --hctosys

Set your Local Timezone

Now the Linux is aware that the hardware clock is using local time instead of UTC, you can configure the system time zone accordingly.

sudo dpkg-reconfigure tzdata

My local timezone is Hawaii Standard Time, so I set my timezone to Pacific/Honolulu.

Current default time zone: 'Pacific/Honolulu'
Local time is now: Thu Feb 7 10:08:57 HST 2019.
Universal Time is now: Thu Feb 7 20:08:57 UTC 2019.

Tell timedatectl that Hardware Clock is Set to Local TIme

Ubuntu 18.04 uses timedatectl to control time. We must inform this system that we’ve changed the hardware clock to local time, otherwise we’ll keep running into the time being set incorrectly each time we switch OS.

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

Now when we issue the timedatectl command, we’ll see RTC is in local timezone (TZ).

timedatectl
Local time: Wed 2019-02-13 10:11:54 HST
Universal time: Wed 2019-02-13 20:11:54 UTC
RTC time: Wed 2019-02-13 10:11:54
Time zone: Pacific/Honolulu (HST, -1000)
System clock synchronized: no
systemd-timesyncd.service active: yes
RTC in local TZ: yes

Leave a Reply

Your email address will not be published.