Skip to content

Commit

Permalink
Force spl.spl_hostid=0 when matching hostid
Browse files Browse the repository at this point in the history
If the SPL kmod has a non-zero spl_hostid parameter, nothing we write to
/etc/hostid will have any effect. Forcing the module parameter to zero
will cause ZFS to look to /etc/hostid for a value regardless of the
initial state.
  • Loading branch information
ahesford committed Apr 30, 2021
1 parent ed5d23b commit 8886db3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 90zfsbootmenu/zfsbootmenu-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ center_string() {
# returns: 0 on successful write, 1 on error

write_hostid() {
local hostid ret
local hostid ret splmod
splmod="/sys/module/spl/parameters/spl_hostid"

# Normalize the hostid
if ! hostid="$( printf "%08x" "0x${1:-0}" 2>/dev/null )"; then
Expand All @@ -142,6 +143,10 @@ write_hostid() {
ret=$?
fi

if [ "${ret}" -eq 0 ] && [ -w "${splmod}" ]; then
echo 0 > "${splmod}" || zwarn "failed to force spl.spl_hostid=0 for host ID matching"
fi

return ${ret}
}

Expand Down

0 comments on commit 8886db3

Please sign in to comment.