site  contact  subhomenews

Timezone in the initrd (initramfs)

March 18, 2010 — BarryK
I'm just starting to look into automatic handling of improper shutdown for installation modes other than full hd install (the latter has been solved, see my recent post).

If we do a f.s. check in the initramfs, I think that it would be best if the local time is known, as, I think, it is undesirable for the fixed f.s. to be "in the future" after doing the switch_root to the Puppy f.s. and setting the system time.

So, I was thinking, if I set environment variable TZ='XXX-23' prior to doing an e2fsck, that should do it. If I have got my reasoning right, the '-23' means my location is 23 hours east of Greenwich, so it would be the most "behind" time possible.
The 'XXX' is any three letters to denote a hypothetical location, and it can actually be those letters 'XXX'.

A reference on timezones:
http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html

Note, I found a syntax error in the TZ variable setting made in /etc/profile. /etc/localtime is a symlink to the timezone, and /etc/profile reads this and sets TZ. If /etc/localtime points to /usr/share/zoneinfo/Etc/GMT-8 then it seems that the correct setting for TZ is TZ=':Etc/GMT-8' -- what was missing before was the colon prefix.

Comments

TZ variable
Username: BarryK
A titbit of info for Puppy developers... Yes, setting "export TZ='XXX-23'" does indeed work as I expected. When I built what I hoped would be Quirky 010, I saw that the time/date in the tray was wrong. The boot script /etc/rc.d/rc.country runs 'hwclock' to set the system time from the hardware clock, and it appears that it reads TZ variable in preference to /etc/localtime. In my tray, the time/date showed as 16:17 on 18th March, whereas it was actually 7:17 on the 19th March. As I am 8 hours behind GMT here in Perth, that works out right -- the system time was set to 23 hours behind GMT, confirming 'XXX-23' worked as expected. I had set TZ in the 'init' script in the initramfs, and this carried over into the main f.s. One fix is "unset TZ" at the beginning of rc.sysinit, but my solution was to set TZ correctly before executing 'hwclock'. Note, the 'hwclock' I'm using in Quirky is a busybox applet. Earlier puppies use a standalone full hwclock and I don't know whether that would behave the same.

time zone
Username: sherry1
"A time zone is a region of the earth that has uniform standard time, usually referred to as the local time. By convention, time zones compute their local time as an offset from UTC. Local time is UTC plus the current time zone offset for the considered location. Time zones are divided into standard and daylight saving. Daylight saving time zones include an offset typically +1 for daylight saving time. Standard time zones can be defined by geometrically subdividing the Earth's spheroid into 24 lunes, bordered by meridians each 15° of longitude apart. The local time in neighboring zones would differ by one hour. However, political boundaries, geographical practicalities, and convenience of inhabitants can result in irregularly-shaped zones. Moreover, in a few regions, half-hour or quarter-hour differences are in effect. Before the adoption of time zones, people used local solar time. Originally this was apparent or true solar time, as shown by a sundial, and later it became mean solar time, as kept by most mechanical clocks. Mean solar time has days of equal length, but the difference between mean and apparent solar time, called the equation of time, averages to zero over a year. I am a student of <a href="http://www.ccieanswers.com">cisco ccie</a> and i am so much specialties in the network solution's.

hwclock
Username: BarryK
"mories, Oops! Thanks, I fixed it.


Tags: woof