PDA

View Full Version : Time resets to UTC at boot in Knoppix 6.2.1



linuxoid
08-19-2010, 06:41 PM
I've noticed that time always resets to UTC at boot in spite of local settings. I think I found a couple of problems in /etc/init.d /knoppix-autoconfig. I've fixed them as described below, but please let me know if there is a regular fix for it.

1. In start_clock function I've changed <checkbootparam utc || UTC="-u"> to <checkbootparam utc && UTC="-u">. Looks like an obvious bug to me, but let me know if I've missed anything.

2. I've moved a call to start_clock function after udev completed created devices, because in the original version hwclock was called before /dev/rtc was created and it caused an error message "file /dev/misc/rtc doesn't exist". To see the error you'll need to change /dev/null to a real file.

Please let me know when a fix is available.

kl522
08-20-2010, 02:34 AM
Wow it's quite surprising that it takes so long to hear about this problem for the first time. Perhaps it's my ignorance. I wonder how other people have dealt with this problem. For me I have overriden the original thing, I do 'hwclock --localtime -s". I used to have problem get the correct time after I booted into Windows. After doing this, my clock is still correct after I boot into Windows and back to Knoppix.

evenso
08-21-2010, 10:58 PM
I am guilty of ignoring this problem. I think it just didn't take precedence over getting Knoppix up working the way I wanted. Now it is no longer an issue. Fixed somewhere in the upgrades I guess.

kl522
08-22-2010, 02:51 AM
It can't be. No way this problem can be fixed by a debian packages updates. It has to be some scripts have been modified.

evenso
08-22-2010, 03:57 AM
I noticed after posting: when booted into openbox, my conky script reports UTC even as the lxd taskbar clock reports PDT.

evenso
08-22-2010, 05:22 AM
The conky clock script needed to be offset from system time rather than GMT offset it used on the computer it came from. That means my system time is set at UTC (GMT) at boot and LXDE panel clock is offset correctly from system time, maybe from a configuration on install.

utu
08-26-2010, 02:43 AM
Glad to see a discussion on this.

My knoppix 6.2.1 reads out in local time ok here.

However, in my other life, I can watch Ubuntu 10.04.1
start with local time and see it reset itself to GMT.

I can remember getting crosswise with dual boots to windows,
but I think I'll try some ideas mentioned here to see
if I can't get Ubuntu straightened out, after all.

Thanks, all, for the ideas.

utu
08-26-2010, 03:39 AM
PS

In my Ubuntu 10.04.01 case, a new 2Gb SD card version,
I noticed the system started in local time, but went to GMT
when the wifi network clicked in.

I'd never clicked the date/time display to set its parameters.
You guessed it, default on the date/time applet was UTC, not localtime.
I think this solved my problem, unless win7 complains.

BoDiddley
10-31-2010, 02:09 PM
Using knoppix 6.2.1 based on the conversation I played around with hwclock command. "hwclock -r" set the clock to my system clock, remained successful after reboot.

BoDiddley
11-16-2010, 06:42 PM
1)dpkg-reconfigure tzdata 2) date MMDDHHmmCCYY 3) hwclock --localtime. These three steps are another alternative. However when I did 4) hwclock --systohc - it changed my windows clock. When I corrected Windows - it put me back at square one in Knoppix (step 4 did me in - this time). I believe this problem centers around the fact that /etc/adjtime is never created. Maybe I will have to learn how to create based on "man hwclock".

krishna.murphy
11-17-2010, 05:07 AM
1)dpkg-reconfigure tzdata 2) date MMDDHHmmCCYY 3) hwclock --localtime. These three steps are another alternative. However when I did 4) hwclock --systohc - it changed my windows clock. When I corrected Windows - it put me back at square one in Knoppix (step 4 did me in - this time). I believe this problem centers around the fact that /etc/adjtime is never created. Maybe I will have to learn how to create based on "man hwclock".

I ran into this in the past, too. I just used Windows time-setting, then made sure that the correct time showed in Knoppix as well, and skipped the "hwclock --systohc" that messes up the Windows time setting. Frankly, it's a lot easier to get the right time set in Windows (under "Internet time"), and all you have to do once that's done is to avoid messing it up in Knoppix. I edited the defective script as discussed in this thread (http://www.knoppix.net/forum/threads/28834-saving-time-zone?p=122078#post122078), and it works now, after it's own peculiar fashion - UTC is displayed immediately after boot, but within 30-60 seconds "Knoppix switches itself over" to the correct TZ display. WEIRD!

Cheers!
Krishna :mrgreen:

BoDiddley
11-17-2010, 11:48 PM
Lenny just released a new tzdata. upgraded and ran dpkg-reconfigure. HD install simply will not set correct tz for America New_York. If anybody wants to use --adjust, uncomment hwclock.sh

linuxoid
09-16-2013, 02:36 AM
Sorry for reviving the old thread, but I'm on 7.2 now and it still doesn't work. The first bug (checkbootparam utc || UTC="-u") has been fixed, but the second (calling start_clock before /dev/rtc has been created) is still there. You need to call start_clock after 'hwsetup', because the latter is the one that creates the devices by reading information from /proc.

On top of that hwclock sets up time zone to UTC if --localtime param is not provided. Here is a quote from man page:


If you specify neither --utc nor --localtime, the default is
whichever was specified the last time hwclock was used to set
the clock (i.e. hwclock was successfully run with the --set,
--systohc, or --adjust options), as recorded in the adjtime
file. If the adjtime file doesn't exist, the default is UTC
time. It means that you need explicitly provide '--localtime' parameter if you want local time.

Here is a patch that works for me:

--- knoppix-autoconfig 2013-09-15 10:03:37.000000000 -0700
+++ knoppix-autoconfig-new 2013-09-15 18:10:01.000000000 -0700
@@ -722,7 +722,7 @@
}

start_clock(){
- local UTC=""
+ local UTC="--localtime"
checkbootparam utc && UTC="-u"
export UTC # local export only visible to subprocess of this function
( hwclock $UTC -s & ) >/dev/null 2>&1 # background, can hang
@@ -845,9 +845,6 @@
# Mount /sys and usbfs if not already present
start_sys

-# Set system clock to BIOS clock
-start_clock
-
# Start splashscreen if requested and DEBUG is not set
check_start_splash

@@ -890,6 +887,9 @@
# Knoppix hardware setup (i.e. X config)
checkbootparam nohwsetup || start_hwsetup

+# Set system clock to BIOS clock
+start_clock
+
# Start dbus now, which is prerequisite to network-manager and hal
start_dbus

Werner P. Schulz
09-16-2013, 07:34 AM
This works (http://knoppix.net/forum/threads/30659-Keeping-up-with-the-times?p=129869&viewfull=1#post129869) without fiddling and patching within Knoppix.

linuxoid
09-16-2013, 10:00 PM
This works (http://knoppix.net/forum/threads/30659-Keeping-up-with-the-times?p=129869&viewfull=1#post129869) without fiddling and patching within Knoppix.

The whole point of my post was that it doesn't and it couldn't, because 'start_clock' in knoppix-autoconfig is called before /dev/rtc is created.

I do use tz=US/Pacific in boot params and when I type 'date', zone is PDT, but time is UTC.

The other thing - I did run 'hwclock -s' manually, but it still didn't work because you need to use --localtime in the new version, otherwise the default might be UTC (if adjust file doesn't exist).

In regard of patch itself, I might need to change it because it's not always working. The thing is that 'udev_all' starts in background and /dev/rtc might not be added, even if you call start_clock after start_udev, so what needs to be done is to call something like below explicitly and in the same shell to make sure that it's completed before start_clock is called:

udevadm trigger --subsystems-match=rtc --action=add

The solution above seemed to be more stable. I'll post a new pacth soon after testing.

Werner P. Schulz
09-17-2013, 07:23 AM
Did you really use UTC in BIOS before starting Knoppix?

linuxoid
09-29-2013, 04:32 AM
Can't use UTC in BIOS, because of Windows 7 that I have on the same machine and that doesn't handle UTC in BIOS well. Below is a patch that works for me. I've added
RTC device creation in the same shell and it seemed to be working more stable than the previous patch.


--- knoppix-autoconfig 2013-09-28 20:20:33.000000000 -0700
+++ knoppix-autoconfig.new 2013-09-28 20:19:47.000000000 -0700
@@ -383,8 +383,15 @@
if /sbin/udevd --daemon; then
# X could already start after this.
udev_graphics
+
+ # Need to start rtc to start clock
+ addprogress "Creating rtc ..."
+ /sbin/udevadm trigger --subsystem-match=rtc --action=add >/dev/null 2>&1
+
+
# Now launch remaining hardware detection in a new subshell
- ( { udev_audio ; udev_all; } & ) >/dev/null 2>&1
+ addprogress "Creating remaining hardware..."
+( { udev_audio ; udev_all; } & ) >/dev/null 2>&1
fi
}

@@ -722,7 +729,7 @@
}

start_clock(){
- local UTC=""
+ local UTC="--localtime"
checkbootparam utc && UTC="-u"
export UTC # local export only visible to subprocess of this function
( hwclock $UTC -s & ) >/dev/null 2>&1 # background, can hang
@@ -845,9 +852,6 @@
# Mount /sys and usbfs if not already present
start_sys

-# Set system clock to BIOS clock
-start_clock
-
# Start splashscreen if requested and DEBUG is not set
check_start_splash

@@ -896,6 +900,9 @@
# With xorg 7.4, hal is a prerequisite
start_hal

+# Start clock
+start_clock
+
# ACPI handling
start_acpi

Werner P. Schulz
09-29-2013, 09:28 AM
With dual boot Windows installation you can use within Windows:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\↲
TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
In earlier times Microsoft doesn't offer this registry key for their users because they don't want to change their stupid way of time handling.

utu
09-29-2013, 03:47 PM
@ linuxoid & Werner
Thanks to you both for these solutions.
Cheers.