Stop Debian from saving to the hardware clock on shutdown / Prevent Debian from messing up the system time (dualboot with Windows)

Using Debian for some time now, I faced this problem and could not find a solution for it. Well now I’ve found it and would like to share!

Most PCs have a hardware clock (RTC clock) for keeping time. Linux distributions like Debian and Arch recommend saving the hardware clock to UTC, while in Windows and most other operating systems set it to local time. This creates the problem between time settings of Debian/LMDE and Windows/Other OS.

To fix this, we will follow the procedure below:

Configure Linux to use RTC Clock as localtime

First of all check whether the hardware clock is set to local time or UTC using the command-

sudo hwclock -D   # for newer distros its hwclock -v

This will show the system time (Operating System time), Hardware clock time and whether hardware clock is set to localtime. By default in Debian Hardware clock is set to UTC.

Now assuming your system time is correct, write it to the hardware clock and set hardware clock to localtime, use the command-

sudo hwclock -w --localtime

This will set the current system time to hardware clock and configure the hardware clock to localtime.

Make sure system timezone is correct

If your system time is not correct, first of all make sure your time zone is set correctly by using the command-

sudo dpkg-reconfigure tzdata

Now if the system time is correct, go to previous step and set system time to hardware clock

Otherwise to manually set the system time use the date command-
date -s “1 JUL 2013 20:30:00”

The hardware clock time and type can be set directly using following syntax-

hwclock --set --date='07/23/13 21:10:00' --localtime

[Optional] Disable sync to hardware clock on shutdown

I have Debian installed on an external disk, and don’t like to save the system time to hardware clock as it causes issues with existing systems. To prevent Debian from doing that, edit the file /etc/default/hwclock as-

sudo nano /etc/default/hwclock

(also make sure that the line is uncommented)

Now at shutdown it will say-“Not Saving the System Clock”

Update (May 2021) – With Debian 11 Bullseye, the above method does not seem to work, the hardware clock gets periodically synchronized anyway. Searching for a solution; if you find one please drop a comment!

Alternate solution: configure Windows to use hardware clock as UTC

  1. Configure Windows to use Hardware clock time as UTC

To make MS Windows calculate the time from the hardware clock as UTC. Create a file named WindowsTimeFixUTC.reg with the following contents and then double click on it to merge the contents with the registry:

Windows Registry Editor Version 5.00

  1. Set Linux distributions to use Hardware clock time as UTC by-

sudo hwclock -w --UTC


I’ve tried editing /etc/default/rcS and setting UTC=no as posted on many sites but it did not work for me.

Further Reading


2 thoughts on “Stop Debian from saving to the hardware clock on shutdown / Prevent Debian from messing up the system time (dualboot with Windows)

  1. It is possible that the periodic setting of the hardware clock is caused by a kernel build parameter.
    man hwclock

    Automatic Hardware Clock Synchronization by the Kernel
    You should be aware of another way that the Hardware Clock is
    kept synchronized in some systems. The Linux kernel has a mode
    wherein it copies the System Time to the Hardware Clock every 11
    minutes. This mode is a compile time option, so not all kernels
    will have this capability. This is a good mode to use when you
    are using something sophisticated like NTP to keep your System
    Clock synchronized.

    I use a debian system installed on a usb pen drive, and would like to configure the system to ignore the HWCLOCK entirely and only use ntp.
    we’ll see how far I get.

    1. I checked the kernel config on my Debian system (/boot/config-5.10.0-9-amd64) and did not find any mention of hwclock. lsmod | grep hwclock is empty as well.
      Best of luck with your search Maximilian, what you mention is exactly what this guide is meant to achieve.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s