Re: What exactly is hostid used for?

From: Olivier Certner <olivier.freebsd_at_free.fr>
Date: Sun, 20 Nov 2022 16:00:26 UTC
Hi,

> 1. What is it used for?

To identify a given machine uniquely, for a variety of purposes.

> 2. Can you safely disable it?

Yes and no, see below.

> 3. What relation does it have to ZFS?

AFAIK, ZFS uses the hostid to identify the machine that last imported a given 
pool, storing this info in the pool. When you try to import such a pool, ZFS 
will refuse to do so automatically if you haven't set your hostid correctly, 
thinking you're trying to import a pool from another machine (to proceed 
anyway, you have to use '-f'). This is true irrespective of the value of the 
'multihost' pool property (see zpoolprops(7)).

It is also used by NFSv4, as pointed out by Graham. See nfsv4(4):
"Also, since an NFSv4 mount uses the host uuid to identify the
client uniquely to the server, you cannot safely do an NFSv4 mount when
    hostid_enable="NO"
is set in rc.conf(5)."

It can be used in configuring HAST (see hast.conf(5); never tried it myself).

It is probably used by pf(4) when using pfsync(4) (to identify which host 
created a given rule).

epair(4) assigns Ethernet MAC by default based on the hostid. if_genet(4) does 
the same.

So yes, you can "safely" disable it, as long as you don't rely on the above 
functionality. I'm not guaranteeing that this list is exhaustive for the base 
system. Moreover, applications can access the hostid ('kern.hostid' or the 
longer 'kern.hostuuid') through sysctl(3) or gethosid(3), and do whatever they 
want with it.

But frankly, why would you ever bother with disabling it?

Regards.

-- 
Olivier Certner