Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Nov 2022 17:00:26 +0100
From:      Olivier Certner <olivier.freebsd@free.fr>
To:        questions@freebsd.org
Subject:   Re: What exactly is hostid used for?
Message-ID:  <1931267.2YEvzyG8uJ@ravel>
In-Reply-To: <NHHpbAs--3-9@tutanota.com>
References:  <NHHpbAs--3-9@tutanota.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1931267.2YEvzyG8uJ>