Hello, Tracking a new startup of the system usually fall into looking kern.boottime. But it isn't constant, sometimes drifts over time, so it isn't a 100% reliable source. On Linux implemented /proc/sys/kernel/random/boot_id [1] with a random value generated early at boot, unique for every running kernel instance. It would be nice to have it on FreeBSD too. Thanks, [1] - http://man7.org/linux/man-pages/man3/sd_id128_get_machine.3.html
I agree that this would be useful to provide, and seems straightforward enough.
To clarify, this is different from kern.hostuuid (and kern.hostid an alias, set via /etc/rc.d/hostid) in that each *boot* gets a new id, rather than a once per install, which is constant/immutable/read-only until the next boot? I also note that for kern.hostuuid, there's an associated security.jail.param.host.hostuuid sysctl. Presumably this feature request should also apply to jails too?
A commit references this bug: Author: cem Date: Tue Mar 17 22:27:17 UTC 2020 New revision: 359053 URL: https://svnweb.freebsd.org/changeset/base/359053 Log: Implement sysctl kern.boot_id Boot IDs are random, opaque 128-bit identifiers that distinguish distinct system boots. A new ID is generated each time the system boots. Unlike kern.boottime, the value is not modified by NTP adjustments. It remains fixed until the machine is restarted. PR: 244867 Reported by: Ricardo Fraile <rfraile AT rfraile.eu> MFC after: I do not intend to, but feel free Changes: head/sys/kern/kern_mib.c
Dropping if someone wants to MFC or further enhance re jails.
Thanks for the quick response. I just tried the last snapshop of 13.0-CURRENT x86 build today and the option doesn't fail but it doesn't report anything. root@:~ # sysctl kern.boot_id root@:~ # echo $? 0 root@:~ #
Created attachment 212834 [details] Fix output for sysctl kern.boot_id
Created attachment 212836 [details] Update man 3 syctl with kern_boot_id
Created attachment 212837 [details] Update man 8 syctl with kern_boot_id and order list
I fix it with this code change, please see the patch uploaded. Also, there are two other patches to update man pages. root@:~ # sysctl kern.boot_id kern.boot_id: 16254718031988427779
@cem did you see the last patches? is needed something more? Having the functionality working on -current can allow to test it right, it would be helpful. Thanks,
Hello, On FreeBSD-13.0-CURRENT-i386-20200611-r362037 I still have an empty output. root@:~ # sysctl kern.boot_id Thanks,
^Triage: assign to committer.
To print this value, one option is to use sysctl -x: $ sysctl -x kern.boot_id kern.boot_id: Format: Length:16 Dump:0x75ca41033699ae64afe63a45a6b5d258 The patch in comment #6 does not seem necessary or correct. The patch in comment #7 documents a non-existent KERN_BOOT_ID identifier. The patch in comment #8 combines an add and sort; those should be independent so it is clear what is being changed. Cleared 'patch' tag.
(In reply to Ricardo Fraile from comment #8) Hm, and sysctl.8 is not an exhaustive list of all sysctls. Mostly the tree is self-documenting or documented elsewhere. I'm not sure adding this to that page is justified.