zfsutils-linux: persist hostid in postinst script
/etc/hostid does not exist on a minimal debian system. ZFS reads its contents for MMP (zpool property multihost set to on), and needs the value to be stable. Before the SPL->ZFS merge the spl userspace package wrote the file (by parsing/ mangling the output of hostid (1)) Since ZFS provides the zgenhostid script, which creates a random 4 byte hostid and writes it to /etc/hostid, we use that instead. (hostid (1) default to mangling a configured ip of the system, which can be the same across multiple installs (install happens with the same ip) Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
parent
4114f700a9
commit
5b9cd1ad57
19
zfs/debian/zfsutils-linux.postinst
Normal file
19
zfs/debian/zfsutils-linux.postinst
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
# The hostname and hostid of the last system to access a ZFS pool are stored in
|
||||
# the ZFS pool itself. A pool is foreign if, during `zpool import`, the
|
||||
# current hostname and hostid are different than the stored values thereof.
|
||||
#
|
||||
# The only way of having a stable hostid is to define it in /etc/hostid.
|
||||
# This postinst helper will check if we already have the hostid stabilized by
|
||||
# checking the existence of the file /etc/hostid to be 4 bytes at least.
|
||||
# If this file don't already exists on our system or has less than 4 bytes, then
|
||||
# a new (random) value is generated with zgenhostid (8) and stored in
|
||||
# /etc/hostid
|
||||
|
||||
if [ ! -f /etc/hostid ] || [ "$(stat -c %s /etc/hostid)" -lt 4 ] ; then
|
||||
zgenhostid
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
Loading…
Reference in New Issue
Block a user