Resolving hostid mismatch with ZFS

2014-11-29 18:59 - Linux

All of my ZFS-using Linux machines have recently started spewing ZFS status errors:

$ sudo zpool status
  pool: rpool
 state: ONLINE
status: Mismatch between pool hostid and system hostid on imported pool.
        This pool was previously imported into a system with a different hostid,
        and then was verbatim imported into this system.
action: Export this pool on all systems on which it is imported.
        Then import it to correct the mismatch.
  scan: scrub repaired 0 in 0h30m with 0 errors on Sat Nov 29 04:51:59 2014

Critically, it causes various cron jobs to send mail (with this error) which were previously silent. So what's going on? What I know for certain is I can:

# dd if=/dev/urandom of=/dev/stdout bs=1 count=4 > /etc/hostid
# hexdump /etc/hostid
0000000 9872 1823
# hostid

This is running booted into a fully operational system. Notice the byte ordering! The contents of the file are in network (big endian) order. If I regenerate the initramfs after filling this file:

# xzcat /boot/initramfs | cpio -id
# hexdump ./etc/hostid
0000000 2318 7298

The hostid file in the initramfs does not match the input file from /etc/, due to genkernel's mangling of the hostid value. So you can't generate a host ID that way. Unless you work around that problem by copying the hostid file out of the initramfs into your live system! Once the files match, zpool status will no longer complain.


No comments!

Post a comment:

  If you do not have an account to log in to yet, register your own account. You will not enter any personal info and need not supply an email address.

You may use Markdown syntax in the comment, but no HTML. Hints:

If you are attempting to contact me, ask me a question, etc, please send me a message through the contact form rather than posting a comment here. Thank you. (If you post a comment anyway when it should be a message to me, I'll probably just delete your comment. I don't like clutter.)