# what the...??   ( hwclock suddenly fails )

## corey_s

Out of nowhere, when booting my machine, at the point when init fires up the clock rc ( "Setting system clock to hardware clock [UTC]..." ) - I get the following:

```

 * Setting system clock to hardware clock [UTC]...

 * Failed to set system clock to hardware clock

```

Huh?

So, looking further into it - I throw a 

```
set -x
```

 into 

```
/etc/init.d/clock
```

 and I find the culprit:

```

++ /sbin/hwclock --adjust --utc

+ errstr='select() to /dev/rtc to wait for clock tick timed out'

```

Running this manually, as root, at the prompt verifies:

```

scanner ~ # hwclock --adjust --utc

select() to /dev/rtc to wait for clock tick timed out

scanner ~ # 

```

... there's about a 3-5 second delay before the error turns up.

WTF?

I didn't do anything at all to my box - other than rebooted into windoze for a long time for my girlfriend to run excel.  After snooping around on the windoze partition, I found some suspicious binaries and realized that in the relatively short time she used my pc, there were allready some malware hanging around - not her  fault - and potentialy just a red-herring and nothing at all to do with this problem...  but that's all that happened - my system has been quite stable for months now.

Here's the perms to /dev/rtc:

```

scanner ~ # ls -l /dev/rtc  /dev/misc/rtc

crw-rw-r--  1 root root 10, 135 Sep 30 02:27 /dev/misc/rtc

lrwxrwxrwx  1 root root       8 Oct 31 13:06 /dev/rtc -> misc/rtc

scanner ~ #

```

Can anybody help me out here?   Thanks a ton, it's beyond me.

Cheers,

Corey

----------

## corey_s

Ok - well, I fixed it.

After trying everything else I could possibly come up with; I just went ballistic and completely nuked /dev/rtc/ and /dev/misc/rtc...

Rebooted, and everthing's fine.   Cool.

Beers!

Corey

----------

## JLP

It appears I hav a similar problem. One day I rebooted my computer and I got the same message. I tried manualy runing hwclock and i get this message:

enterprise misc # hwclock --debug

hwclock iz util-linux-2.12b

hwclock: Open of /dev/rtc failed, errno=2: No such file or directory.

No usable clock interface found.

Cannot access the Hardware Clock via any known method.

I looked for this file and it realy isn't there. So why did it just disapear all of a sudden? hwclock was runing just fine a few days ago.

How do I get this back.

----------

## corey_s

Do you guys have '/dev/misc/rtc' ?

If so, just do a  'ln -s /dev/misc/rtc/ /dev/rtc'

If you don't have '/dev/misc/rtc' - then I have no suggestions; what worked for me, was I actualy rm'd both /dev/rtc and /dev/misc/rtc then rebooted.  They were recreated after the reboot and everything's been fine since.

Did you recently emerge udev?

----------

## JLP

/dev/misc/rtc/ also doesn't exist. Maybe I have upgraded to udev in the meantime. I'm not sure. I'll see if it gets any better when I upgrade from 042 to 043 that just got released.

----------

## JLP

I upgraded udev and still no devices. It looks like that for some reason rtc module stopped loading before hwclock is called. How to fix this? Is it a bug in new Gentoo kernel or udev?

----------

## JLP

Anyone knows what is going on?

----------

## commonloon

I found my clock init script failing after changing my kernel. I think I ran into the same issue(s). So I posting my fix, hoping I'll help the next guy  :Wink: 

Symptom: the bootmisc init script fails, i.e., its dependency 'clock' fails, showing failed to set hardware clock in boot msgs. I am running udev, but while it was my 1st suspect, it was not the cause.

It seems there was no device node for rtc, revealed by:

```

hwclock --debug

```

Tried:

```

cd /dev

mknod /dev/rtc c 10 135

```

...But fixed by make menuconfig, etc.,  enabling "Realtime Clock Support" in the kernel under "Character Devices". 

----------

## mstamat

Set CLOCK_OPTS="--directisa" on /etc/conf.d/clock. Then reboot. If you don't want to reboot, zap clock service (/etc/init.d/clock zap) and start it again (/etc/init.d/clock start). That did the trick for me.  :Very Happy: 

----------

## taciturnus

I experienced the same problem when playing with kernel.

To find out what's the problem, I compiled kernel like this:

```

     -> Device Drivers

          -> Character devices

              <M> Enhanced Real Time Clock Support (module is called rtc)

              <M> Generic /dev/rtc emulation (module is called genrtc)

              [*]   Extended RTC operation

```

During reboot I got:

```

* Setting system clock to hardware clock [UTC]...

* Failed to set system clock to hardware clock                           [ !! ]

```

Logged in as root and tried:

```

# lsmod

Module                  Size  Used by

rtc                    10444  0 

# hwclock --show

select() to /dev/rtc to wait for clock tick timed out

# rmmod rtc

# lsmod

Module                  Size  Used by

# modprobe genrtc

# lsmod

Module                  Size  Used by

genrtc                  8604  0 

# hwclock --show

Wed Jun  8 11:41:53 2005  -0.102536 seconds

```

So it seem "Enhanced Real Time Clock Support" has a problem on my PC.

I'm on Intel P4 with Hyperthreading support & UDEV & vanilla-sources-2.6.11.10.

----------

## mendo

I have started to get this error too. I think it started after upgrading baselayout.

I have always compiled rtc as a module and the module got loaded automatically at startup. Now it seems that it no longer loads the module automatically so i have put it into /etc/modules.autoload.d/kernel-2.6 but it still doesn't work. However when the system is up and running i can simply do

/etc/init.d/clock stop

/etc/init.d/clock start

and it can now set the system clock without problem. Without loading the module in modules.autoload.d i first have to modprobe rtc before the clock initscript works.

I thought that maybe the /dev/rtc device wasn't created correctly when the rtc module got loaded so i have tried modifying the clock init script. I added these lines at the top of the start() function:

ls -l /dev/rtc

ls -l /dev/misc

sleep 20

ls -l /dev/rtc

ls -l /dev/misc

What i see now when booting is that before the sleep the rtc and misc/rtc devices doesn't exist. After the sleep they do! And because of the sleep it can now set the system clock correctly. (it is probably not necessary to sleep as long as 20 seconds)

I have a feeling that it is a problem with udev. I'm using udev-058. I had to upgrade from udev-045 because that version didn't create the /dev/sound/* devices correctly resulting in alsa oss-emulation not working.

I think that it would work if rtc is compiled into the kernel instead of compiled as a module but i haven't tried that yet.

Something has surely changed in the different init scripts lately. In my time i have installet alot of gentoo systems (40+), i have always compiled rtc as a module, i have never loadet the module manually via modules.autoload.d and it has always worked fine.

----------

## thanster

I'm experiencing this as well I've tried udev 45 and 58 and the problem affects both.

It appears that the clock init script is just running too early to work, it seems to work fine when I manually stop/start the service later.... (dependencies changed??)

----------

