4

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.

  • It might be better to cure this issue than prevent it. I'm imagining you could run a script that detects whether the hardware clock is set to UTC or local time, and configures Ubuntu appropriately. – wjandrea Oct 8 '17 at 22:56
  • (that is, set the Ubuntu live system to treat the hardware clock as local or UTC, as needed) – wjandrea Oct 8 '17 at 23:11
  • Dupe of askubuntu.com/q/683067/158442, looks like. I don't see any other reason why Ubuntu will write to the system clock other than to update it. – muru Oct 9 '17 at 0:58
  • 4
    OP has been very explicit that they don't want to detect/adjust whether Ubuntu uses local or UTC, they want to prevent modifying hardware clock completely. This has a bunch of close votes already that are incorrect. – thomasrutter Oct 9 '17 at 1:14
  • @wjandrea That sounds like the ideal solution, but I am not sure whether such information is even stored in the BIOS. It just keeps a clock, interpreting this clock might be done completely by the OS, in which case the script you propose would either have to 'check how other installed operating systems do it' (which is unrealistic) or need an internet connection to deduce which time zone was used. – Bib-lost Oct 9 '17 at 7:09
0
systemd-timesyncd.service

is responsible for updating time on systemd based systems. That is a built-in NTP client for systemd. This will stop and disable it:

$ sudo -i 
# systemctl stop systemd-timesyncd
# systemctl disable systemd-timesyncd

(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.

  • In older versions there would be a UTC=yes in /etc/default/rcS. Set that to no if you want to disable updating the hardware clock
  • timedatectl --adjust-system-clock set-local-rtc true does the same and will warn you about breaking time zone changes and daylight saving time adjustments.
0

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 for hwclock and stub out the cmos_set_time function. Rebuild it and replace your USB drive version of /sbin/hwclock with your newly built version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.