I always tell people that 'nothing can go wrong' and that 'their computer won't even remember' if I boot their systems from my Ubuntu-installed pendrive, but I recently found out that this is not true. Booting from a pendrive has the possibility of changing the hardware clock of the computer it is used on.
As explained e.g. in these help pages, Linux and Windows interpret the hardware clock as UTC and local time, respectively. This means that in a dual-boot system, one wants to make Linux read the system clock as local time too, to prevent a mismatch in Windows. The problem is that I want to use my pendrive both in computers with Linux as their main OS and computers with Windows as their main OS, so whatever decision I make for my pendrive (local time vs UTC), it's not going to fit all computers.
Is there a way to simply prevent Ubuntu from changing the system clock, so at least I don't mess up other people's setups? If that means the pendrive system sometimes does not display the correct time, then so be it.
NOTE TO EAGER FLAGGERS: I know that this question has been asked a thousand times on this site by dual-booters (see the two Q&A's below), but for as far as I could find the proposed solution was always to adjust Linux settings to interpret the hardware clock as local time (or make Windows interpret it as UTC). This is not an option for me since I want a portable system that does not change any clocks.
is responsible for updating time on systemd based systems. That is a built-in NTP client for systemd. This will stop and disable it:
(systemd uses timedatectl and that can be used by itself too).
Please note, regardless of your question that when system clock is set to Local Time,
systemd-timesyncd
won't update hardware clock. So the EASIEST approach would be to use local time.UTC=yes
in/etc/default/rcS
. Set that to no if you want to disable updating the hardware clocktimedatectl --adjust-system-clock set-local-rtc true
does the same and will warn you about breaking time zone changes and daylight saving time adjustments.I think it is a good goal to customize your USB drive Linux installation to be an unobtrusive guest. I thought it might be a simple kernel modification to stub out the function that is doing this, but it looks like the kernel is just providing functions to write to the CMOS and
hwclock
is the program responsible for updating the time. So I think you should get the source code forhwclock
and stub out thecmos_set_time
function. Rebuild it and replace your USB drive version of /sbin/hwclock with your newly built version.