Re: Getting boottime early in booting

From: Rick Macklem <rick.macklem_at_gmail.com>
Date: Sat, 04 Apr 2026 15:34:48 UTC
On Sat, Apr 4, 2026 at 1:52 AM Dag-Erling Smørgrav <des@freebsd.org> wrote:
>
> Rick Macklem <rick.macklem@gmail.com> writes:
> > 1 - I need a value that will be different each time the machine boots.
> >      I would normally use getboottime(), but for the NFS root fs mount,
> >      it just returns 0.
> >      Any ideas w.r.t. something I can acquire early in booting that will
> >      change each time the system is booted?
>
> Just use arc4random(9).
Yes, that does seem to work now. (It didn't seem to be working when I
tried before posting? For the very old i386 system I am testing on,
arc4random() works for me, if I wait until I really need the value, which
is when the RPC is being done to the NFS server. Before testing, I was
trying arc4random() much earlier in the boot.)

For a UEFI laptop, it looks like arc4random() works quite early in the
boot. (It has the entropy_efi_seed=YES in it's boot variables.)

Anyhow, thanks everyone, for the useful hints, rick

>
> DES
> --
> Dag-Erling Smørgrav - des@FreeBSD.org