Description
System information
Type | Version/Name |
---|---|
Distribution Name | Void Linux |
Distribution Version | rolling release |
Linux Kernel | 5.9.3 |
Architecture | x86_64 |
ZFS Version | 2.0.0-rc5 |
SPL Version | 2.0.0-rc5 |
Describe the problem you're observing
When building an initramfs using dracut, I get errors in the part where it calls zgenhostid
:
# Synchronize initramfs and system hostid
zgenhostid -o "${initdir}/etc/hostid" "$(hostid)"
Since current musl versions implement gethostid(3)
, which is what hostid(1)
uses, as a stub that returns 0, this command fails, because zgenhostid.c
has a check for that argument, which rejects any value smaller than 1: if (input_i < 0x1 || input_i > UINT32_MAX) {
.
I have a patch in the musl ML for implementing the behavior where gethostid(3)
reads /etc/hostid
, but that hasn't been merged yet, and any systems that don't have latest musl will still be affected.
I checked the final initramfs, and it doesn't have a /etc/hostid
file.
Describe how to reproduce the problem
Generate an initramfs using dracut in a musl based system with ZFS versions after 9cc177b.
Include any warning/errors/backtraces from the system logs
The dracut command printed out the help text for zgenhostid
, since the error path includes a call to usage()
.
Possible solutions
The zfs module for dracut before 9cc177b still did the wrong thing on musl, since it would end up with a zeroed out /etc/hostid
in the initramfs; but it still managed to write the file into the initramfs and didn't pollute the initramfs tool output with error messages from zgenhostid
. If we want to return to this state, it would be enough to simply allow input_i
in zgenhostid.c
to be 0.
Otherwise, zgenhostid
could be extended to read /etc/hostid
itself or the initramfs generation could copy /etc/hostid
from the host system if it exists. The disadvantage here is that it will be a workaround for a musl limitation that should be solved at some point in the future.
I am open to discussing possible solutions and fixes, including making PRs for them.