Bug 254058 - zfs doesn't set mnt_time aka RootOnZFS doesn't work without RTC
Summary: zfs doesn't set mnt_time aka RootOnZFS doesn't work without RTC
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-06 09:07 UTC by Peter Jeremy
Modified: 2022-09-08 12:51 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Jeremy freebsd_committer freebsd_triage 2021-03-06 09:07:04 UTC
vfs_mountroot() extracts the most recent mnt_time from the mounted filesystems (root and devfs at the time) and passes it to inittodr() as a fallback if there isn't a functioning system RTC.  This is intended to ensure that things like log timestamps don't go backwards.

Unfortunately, only the UFS code actually initialises mnt_time so other root filesystems types will leave mnt_time set to the epoch (1970-01-01 0000Z).  Root on NFS isn't impacted because that uses nfs_mountroot(), which does inittodr() based on the remote filesystem.

That leaves ZFS: If a system with root on ZFS doesn't have a functioning RTC then the system time will start at 1970-01-01 0000Z until (eg) NTP fixes it.  This leaves close-to-epoch timestamps strewn throughout the filesystem, which is annoying.
Comment 1 Ronald Klop 2022-09-08 12:51:36 UTC
Created a workaround for this issue on my RootOnZfs RPI4.
https://www.freshports.org/sysutils/fakertc
Putting myself in the cc of this PR.