diff --git a/zfs/debian/zfsutils-linux.postinst b/zfs/debian/zfsutils-linux.postinst new file mode 100644 index 0000000..df78321 --- /dev/null +++ b/zfs/debian/zfsutils-linux.postinst @@ -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# +