Re: Using ZFS uberblock time to initialise system clock

Ronald Klop <[email protected]> Sat, 9 May 2026 11:35:09 +0200 (CEST)
Newsgroups gmane.os.freebsd.devel.file-systems
Message-ID <1931192428.237166.1778319309301@localhost>
Van: Peter Jeremy <[email protected]>
Datum: 9 mei 2026 03:00
Aan: [email protected]
Onderwerp: Using ZFS uberblock time to initialise system clock

> 
> 
> 
> FreeBSD has provision to initialise the system TOD clock from a filesystem
> timestamp if no hardware RTC provides a valid time (see inittodr() called
> from vfs_mountroot() or nfs_mountroot()).  This has support for UFS and NFS
> root filesystems but not ZFS.
> 
> ZFS has a suitable timestamp in its uberblock (ub_timestamp) so it should
> just be a matter of plumbing that timestamp through.  Digging into the code,
> the most obvious problem is that ZFS doesn't initialise mnt_time in struct
> mount when the filesystem is mounted.  So I tried patching zfs_domount() to
> initialise mnt_time.  That solved the plumbing problem but revealed that, by
> the time zfs_domount() is called on the root filesystem, ub_timestamp has
> been "updated" to the (uninitialised) system clock.
> 
> Before I spend too much more time digging into this, has anyone else dug into
> where the uberblock is updated during the root mount?
> 
> -- 
> Peter Jeremy
> 
> 
> 
> 
> 
> 
> 



Hi Peter,
I hope you will find the answer.
In the meantime I can advertise my port that “resolved” this issue for me.
https://www.freshports.org/sysutils/fakertc/

Regards,
Ronald