Rebooting the kernel without resetting uptime?

Craig Boston craig at tobuj.gank.org
Sun Dec 5 19:06:49 PST 2004


On Friday 03 December 2004 8:20 am, Stefan Midjich wrote:
> I know a guy i respect on IRC told me this is not possible but since
> this is the hackers list i thought the topic at least deserves a
> discussion. I guess i wont be able to sit still until someone either
> does it or shows me why it can't be done.

Of course you can.  Just attach gdb to your running kernel and muck with the 
global boottime structure.  That's considered cheating, though, so don't do 
it!

( a few minutes later )

Hmm, apparently either something has changed in kgdb in 5.3 or I just forgot 
the magic incantation, because it doesn't seem to allow modification of 
memory -- just "Bad file descriptor".  Getting the address from there and 
writing to /dev/kmem directly still works though.

the-cheat# uname -r
5.3-STABLE
the-cheat# uptime
 9:03PM  up 3485 days, 21:44, 1 user, load averages: 0.24, 0.12, 0.12
the-cheat# sysctl kern.boottime
kern.boottime: { sec = 801120000, usec = 345099 } Mon May 22 00:20:00 1995
the-cheat#

:-P

Craig


More information about the freebsd-hackers mailing list