Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a fedora 10 installation where hwclock does not work; it always reports errno 2 (Open of /dev/rtc failed, No such file or directory.) Currently, I have no idea how the system time is set since "hwclock" does not appear in any runlevel or init script.
I also know that /etc/localtime is a copy of an appropriate file from /usr/share/zoneinfo.
The hardware clock is set to localtime, but the value from "date" which seems to rule everything adjusts as if the clock were UTC, and it will not let me reset the timezone.
Of course, I can really set the clock in the BIOS to UTC -- but I have some other linux distos on the box which seem to be making their own way in the world and this all get screwed around with.
I do not care about setting the hardware clock via the OS; how can I get the OS to recognize my timezone and that the hardware clock is set to local time??????
First things first;
have you got a file on the machine called /etc/hardwareclock ?
If so, check that it contains the line "localtime".
If the file does not exist, create it, and put "localtime" into it.
I'm not sure if this will take effect immediately, (if any effect at all), or if you would need to reboot or go to init 1 and back, but it's a place to start.
As for the /dev/rtc not existing, I'd venture a guess that the kernel is not configured with the correct option(s) for the rtc device to exist.
You could manually create it, though I'm not sure if that will actually make it available for use.. It might though. The /dev/rtc device on a 2.6 kernel is a CHARACTER device, MAJOR 10, MINOR 135, which you can create with the 'mknod' command.
Last edited by GrapefruiTgirl; 03-18-2009 at 10:27 PM.
First things first;
have you got a file on the machine called /etc/hardwareclock ?
If so, check that it contains the line "localtime".
If the file does not exist, create it, and put "localtime" into it.
This didn't make a difference, but mknod and then hwclock --hctosys and everything's fine, thanks much. I also adjust something something in /etc/sysconfig/clock, I don't know if either of these those two things will matter since hwclock presumes localtime anyway, Or So I Have Been Told.
I do have a hand rolled kernel right now, but the stock kernel did the same thing. Part of the problem was the other install is debian lenny, which seems to work hwclock wise, meaning the behavior of the two systems mismatch and I am supposed to be developing software for the one but prefer using the other setup to work in, so I have to keep swithching back and forth. BTW I have not seen a kernel option to do with the hardware clock in a long time.
So what should I do now, just stick the mknod and --hctosys in rc.local? Or will that be too late? There is an init script called "udev-post", maybe that will be a good place...the inittab on in this thing is one line! Sigh.
# Set the system time from the hardware clock using hwclock --hctosys.
if [ -x /sbin/hwclock ]; then
# Check for a broken motherboard RTC clock (where ioports for rtc are
# unknown) to prevent hwclock causing a hang:
if ! grep -q -w rtc /proc/ioports ; then
CLOCK_OPT="--directisa"
fi
/sbin/hwclock --adjust
if grep -wq "^UTC" /etc/hardwareclock ; then
echo "...setting system time from the hardware clock (UTC)."
/sbin/hwclock $CLOCK_OPT --utc --hctosys
else
echo "...setting system time from the hardware clock (localtime)."
/sbin/hwclock $CLOCK_OPT --localtime --hctosys
fi
fi
The above is what's in my rc.S file, which is the first init script that gets run from inittab when my system boots.
Again, this is Slackware, not Fedora, so I'm not sure how this applies exactly.
I am running the latest kernel, hand-made, (despite what my sidebar claims) and there are still a couple options in there regarding RTC, which I presume have some effect on what /dev/nodes are made, and/or what hardware device(s) as far as clocks go, are looked for by the kernel. One of the options as I recall is in the 'character devices' section.
Finally, I would like to think the /dev/rtc node would persist over reboots, but maybe it won't.. If not, then I would put the mknod instructions either in rc.S if you have one, and/or if your system uses the rc.1, rc.2 etc folder system for runlevel scripts, make a script accordingly and put a startup link in each of levels 1,2,3,4,5 folders.
I dunno how a one-line inittab gets much done, but maybe it would be a worthwhile idea to put a more complete inittab on the system? Either copying one from another distro of yours and adjusting it where necessary, or I could post mine if it would help..
UPDATE: In xconfig (for making kernel) scroll down to the 'character devices' section, and you will get in there a checkbox for "Create legacy RTC device /dev/rtc" or similar. That will solve that issue properly.
Last edited by GrapefruiTgirl; 03-18-2009 at 11:25 PM.
Reason: update about /dev/rtc
One of the options as I recall is in the 'character devices' section.
Teehee, look at that. Well I guess I just did check it automatically, because it is there. Re: the rc.S script, I grepped through all the init scripts and none of them mention hwclock except in combination with "halt". However, I run the FC10 very stripped down, maybe something that was pulled out.
Quote:
Finally, I would like to think the /dev/rtc node would persist over reboots,
Goodness no! Fedora uses udev, the entire /dev is I think empty between boots. I just noticed mounting debian that /dev contents ARE there, I had just presumed all distos were like this now. Hmmph...but there is no rtc there either. Thinks again.
I dunno how a one-line inittab gets much done, but maybe it would be a worthwhile idea to put a more complete inittab on the system? Either copying one from another distro of yours and adjusting it where necessary, or I could post mine if it would help..
I can write an old school inittab, I used to make little bootable floppies. The trend in Fedora seems to imply "opaque souce".
Yeah, Slackware use UDEV too, and I'm not totally sure how it works, but one time (I was trying something or other) and I deleted the contents of my /dev folder in the hopes that upon reboot, it would remake everything afresh and without tonnes of extra nodes I didn't need. Boy was I wrong! Luckily I had backed up the contents BEFORE deleting them, as the machine would not boot at all, I had to restore the contents...So evidently SOME of the /dev nodes are carried over during reboot out of necessity, but not all.
The symlink and node I use for my modem (on another machine now) I need to recreate upon reboot, and I do that in rc.local.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.