aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorÉrico Rolim <[email protected]>2020-11-13 00:00:59 -0300
committerBrian Behlendorf <[email protected]>2020-11-17 12:19:42 -0800
commite4257ed76d31b3290a2455fb69d7c6d9be00c459 (patch)
treea012a57b12b79be3f6a87a9dd8d876b8f5abc288 /contrib
parentc4a5e3b90fc98890e58cd93c0eea1b27484648d1 (diff)
config/dracut/90zfs: handle cases where hostid(1) returns all zeros
On systems with musl libc, hostid(1) always prints "00000000", which will cause improper behavior when the 90zfs module is configured in a dracut initramfs. Work around this by copying the host /etc/hostid if the file exists, and otherwise only write /etc/hostid if hostid(1) returns something meaningful. This avoids zgenhostid creating a random /etc/hostid for the initramfs, which could lead to errors when trying to import the pool if spl_hostid isn't defined in the kernel command line. Furthermore, tag the /etc/hostid file as hostonly, since it is system specific and shouldn't be taken into account when trying to use an initramfs generated in one system to boot into a different system. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Georgy Yakovlev <[email protected]> Co-authored-by: Andrew J. Hesford <[email protected]> Signed-off-by: Érico Rolim <[email protected]> Closes #11174 Closes #11189
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/dracut/90zfs/module-setup.sh.in8
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/dracut/90zfs/module-setup.sh.in b/contrib/dracut/90zfs/module-setup.sh.in
index db5670cd5..42afda602 100755
--- a/contrib/dracut/90zfs/module-setup.sh.in
+++ b/contrib/dracut/90zfs/module-setup.sh.in
@@ -85,7 +85,13 @@ install() {
fi
# Synchronize initramfs and system hostid
- zgenhostid -o "${initdir}/etc/hostid" "$(hostid)"
+ if [ -f @sysconfdir@/hostid ]; then
+ inst @sysconfdir@/hostid
+ type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/hostid
+ elif HOSTID="$(hostid 2>/dev/null)" && [ "${HOSTID}" != "00000000" ]; then
+ zgenhostid -o "${initdir}@sysconfdir@/hostid" "${HOSTID}"
+ type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/hostid
+ fi
if dracut_module_included "systemd"; then
mkdir -p "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"