Gentoo Archives: gentoo-amd64

From: Duncan <1i5t5.duncan@×××.net>
To: gentoo-amd64@l.g.o
Subject: [gentoo-amd64] Re: hardware clock often doesn't sync to system on shutdown
Date: Mon, 15 Sep 2008 22:33:46
Message-Id: pan.2008.09.15.22.31.47@cox.net
In Reply to: Re: [gentoo-amd64] Re: hardware clock often doesn't sync to system on shutdown by Thanasis
1 Thanasis <thanasis@××××××××××.org> posted 48CE7EAE.9080404@××××××××××.org,
2 excerpted below, on Mon, 15 Sep 2008 18:26:38 +0300:
3
4 > on 09/15/2008 05:57 PM Sebastian Redl wrote the following:
5 >> Thanasis wrote:
6 >>> I attach the /etc/init.d/clock which shows a local "readonly" variable
7 >>> that controls a "--noadjfile" option. What does the following test do?
8 >>>
9 >>> if ! touch /etc/adjtime 2>/dev/null ; then
10 >>> readonly="yes"
11 >>> elif [[ ! -s /etc/adjtime ]] ; then
12 >>> echo "0.0 0 0.0" > /etc/adjtime
13 >>> fi
14 >> First it tests if a touch of /etc/adjtime succeeds. If not, the file is
15 >> not writeable, and it sets the readonly variable.
16 >>
17 >> Then it tests if /etc/adjtime exists (it does, since the touch
18 >> succeeded) and has non-zero size. If not, it writes a zero adjust into
19 >> the file.
20 >>
21 >> Sebastian
22 > How can I make /etc/adjtime readonly? I tried "chmod a-w /etc/adjtime",
23 > but root can always write to it :-) , unless the init script doesn't run
24 > as root.
25
26 A caveat in that the below are all untested ideas. I'm just throwing
27 them out as possible solutions I'd explore further if it were me. They
28 may work, or not, but it's probably worth investigating them further and/
29 or testing them.
30
31 There's a spot in /etc/conf.d/clock to set your own options, right? From
32 the script, perhaps it's ${CLOCK_OPTS}. If you can set your own
33 arbitrary options, you can try adding --noadjfile to them. Except
34 hwclock is called several times (twice for start, once for stop if you
35 have it set to do so) with different options, and I've not checked to see
36 what effect setting --noadjfile will have in all those calls. You could
37 reason it out or just try it and see.
38
39 Alternatively, the manpage says there's an --adjfile=filename option.
40 You could try adding that option and pointing it elsewhere, so the
41 scripts don't look in the right place.
42
43 A third thing to try would be making the adjfile a directory (make it an
44 empty one just in case) instead of a file. Obviously it won't be
45 possible to write a valid adjust into it then, but I'm not sure what the
46 failure mode would be, tho it shouldn't blow up the system so it should
47 be safe to try.
48
49 Finally, a combination of options two and three above, pointing
50 --adjfile= at a different location, an empty directory, might work.
51
52 As I said, those are ideas I'd try.
53
54 Something else I HAVE done on occasion, is hack whatever initscript a bit
55 to fit my needs. If you do so, make sure portage's (assuming that's the
56 PM you're using, others... I expect you'd know what to configure in them)
57 CONFIG_PROTECT variables are set to include that dir (IIRC it does as
58 it's under /etc, but the mask variable may unprotect it, so check that),
59 so an update lets you manage the changes instead of overwriting it
60 without asking.
61
62 --
63 Duncan - List replies preferred. No HTML msgs.
64 "Every nonfree program has a lord, a master --
65 and if you use the program, he is your master." Richard Stallman

Replies

Subject Author
Re: [gentoo-amd64] Re: hardware clock often doesn't sync to system on shutdown Thanasis <thanasis@××××××××××.org>