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. see: http://zfsonlinux.org/msg/ZFS-8000-EY scan: scrub repaired 0 in 0h30m with 0 errors on Sat Nov 29 04:51:59 2014 config: ...
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 0000004 # hostid 18239872
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 0000004
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.