Nemesis Porteus System Clock from RTC and UTC vs. Local

Arch based Porteus community project
Post Reply
rych
Shogun
Shogun
Posts: 227
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0rc3 x64 OpenBox
Location: NZ

Nemesis Porteus System Clock from RTC and UTC vs. Local

Post#1 by rych » 16 Jun 2021, 09:55

Booting Blaze's most recent nemesis-xfce-20.12.26-k5.4.50-x86_64.iso, it doesn't show me the correct time. Even though I set my time zone in one of the porteus config files, which indeed seem to be parses at boot, that's not all. The next problem is that Nemesis thinks my RTC is set to UTC, while it's actually set to local time (BIOS time equals my local time). I replaced the "UTC" with "LOCAL" in the file

Code: Select all

/etc/adjtime
and rebooted. Now `hwclock` shows the correct time, but the `date` shows the old, UTC based time anyway. Somehow the system has remembered it like that. Running

Code: Select all

hwclock -s
corrects System Clock making it equal to Hardware Clock, but only in the current session. How do I make it survive the reboot? And perhaps I'm doing things wrong? Thanks

User avatar
M. Eerie
Shogun
Shogun
Posts: 303
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

Nemesis Porteus System Clock from RTC and UTC vs. Local

Post#2 by M. Eerie » 16 Jun 2021, 17:35

Hi rych

I found out that you have to be careful when setting the system time and maybe hardware clock because you may end changing the host hardware clock. (Are you dualbooting ?)

My setup is like this:
  • In $BOOTDEV/config/time I have this line commented #HWCLOCK=yes
    Only TIMEZONE, NTP_SERVERS and ENABLE_NTP lines are uncommented (enabled/parsed)
  • Somewhere in $PORTDIR/rootcopy/etc/local.d/my-patches.start (which is a bash script executed at startup before the GUI comes up), I have included these lines:

    Code: Select all

    #!/bin/bash
    
    ...
    
    if [ "$(blkid | grep -E 'myUUID|my-other-s-UUID-s')" ]; then
       sed -i 's/UTC/localtime/g' /etc/hardwareclock
       hwclock --localtime --hctosys ### or hwclock -ls
    fi
    
    ...
    
This gives me total control of when and where I want to set the time from/to.

NOTES:

You get your local disk UUID's by:

Code: Select all

porteus~ $  blkid | grep sda
$BOOTDEV is your boot device (usually /mnt/sdb1). Open a terminal and check with:

Code: Select all

porteus~ $ echo $BOOTDEV
$PORTDIR is the porteus dir inside your $BOOTDEV. Likewise:

Code: Select all

porteus~ $ echo $PORTDIR
Hope it helps.
Cheers!

rych
Shogun
Shogun
Posts: 227
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0rc3 x64 OpenBox
Location: NZ

Nemesis Porteus System Clock from RTC and UTC vs. Local

Post#3 by rych » 17 Jun 2021, 08:47

M. Eerie, yes I figured I could have a script that runs hwclock -s each reboot. But can't I change something persistently to teach my system to do such an elementary thing more natively?

Again, my hardware clock has been correct. And hwclock displays it right. However, the System clock (date command and XFCE) is 12 hours off for some reason, which in my case coincides (at least in hours-min-sec, forgot to check the date) with UTC because of my UTC+12 time zone (which I set correctly in TIMEZONE= in /mnt/sda/config/time which led to localtime pointing to the right zoneinfo).

Anyway, my timezone selection appears to have an effect on my clock that it shouldn't have: my RTC is already set to local time, and I explicitly put LOCAL in /etc/adjtime.

So, first, I'm going to comment out the TIMEZONE= altogether to see if it makes system clock coincide with RTC, and if not, will try to select a different timezone until I see the correct clock (and date)
Last edited by rych on 17 Jun 2021, 10:42, edited 1 time in total.

rych
Shogun
Shogun
Posts: 227
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0rc3 x64 OpenBox
Location: NZ

Nemesis Porteus System Clock from RTC and UTC vs. Local

Post#4 by rych » 17 Jun 2021, 12:02

OK that "solved" it: commenting out TIMEZONE= in /mnt/sda/config/time and removing changes/etc/localtime

Now date and hwclock agree perfectly on time and date. Only the date command adds it favourite "UTC" at the end -- it really wants to insist on my time being in UTC and I failed to teach it to respect "localtime" setting -- oh well, as long as it correctly displays the time itself, I'll let him think it's UTC.

Tried /etc/conf.d/hwclock: clock="local" -- no effect. I'm giving up. The "solution" above will have to do for now.

Post Reply