[Pkg-zfsonlinux-devel] Comparing the Debian and Ubuntu version of spl-linux

Aron Xu happyaron.xu at gmail.com
Wed Sep 28 20:14:48 UTC 2016


On Wed, Sep 28, 2016 at 8:58 PM, Turbo Fredriksson <turbo at bayour.com> wrote:
> On Sep 28, 2016, at 8:08 AM, Petter Reinholdtsen wrote:
>
>> Another and related question.  Is it really a good idea to store the
>> current value returned by gethostid() in /etc/hostid?
>
> My opinion is, and have always been, that the hostid is NOT needed
> on Linux. A couple of years ago me and Brian talked about removing
> it altogether and instead probe for devices.
>
> Which is "The Linux Way(™)"..
>
> That was the reason for my extensive work on the initrd, sysv and
> dracut work to make sure we find the devices needed.
>
>
> The hostid value is/was supposed to be an indicator that the pool
> isn't imported on another host.
>
> This can be a problem under (at least) these conditions:
>
>   1. You're importing a pool with devices from a SAN/NAS.
>   2. You're dual-booting different dists/operating systems.
>
> People that would have a problem with any of this is in minority,
> which is why I think it's better to work for the large majority,
> rather than the minority.
>
> My initrd/sysv/dracut scripts takes this into account by having
> those that might have a problem with this specifying their pools
> manually in the /etc/default/zfs.
>
>> The value is
>> derived from the current IP address via the current hostname according
>> to the gethostid() manual page, and that mean it will be the same across
>> many machines behind NAT or otherwise on a private IP range commonly
>> used on home routers (like 192.168.*).
>
> The value isn't intended to be unique across the world, just across
> 'your own' network - make sure that the pool(s) haven't already been
> imported by another host (see above).
>
> That's the only thing it's used for - 'zpool import' will look at the
> hostid value recorded in the pool and compare that with the value in
> /etc/hostid and if they don't match, refuse a verbatim import. To override
> and import anyway, a 'force' needs to be specified, in which the new
> (system) value will be recorded in the pool.
>

Well I don't see the necessity of having the hostid guard in zfs for
importing pools, but probably someone may update me with a reason. But
at this moment recording current hostid is the best idea to make sure
it does not break. In current packaging:

1. If /etc/hostid is a registered conffile of previous spl package,
remove the conffile but not modifying/removing it actually (this is
true because it's modified by previous postinst script, it's not gone
from file system).

2. If no /etc/hostid is present, generate a new one in postinst script
by writing current value to it, taking care of endianness.

3. Previously the job was done in spl-dkms package, but changed to spl
package because spl-dkms is not mandatory to have. Probably
zfsutils-linux is a even better place?


Regards,
Aron



More information about the Pkg-zfsonlinux-devel mailing list