5 # Let the command line override our host id.
6 spl_hostid=$(getarg spl_hostid=)
7 if [ -n "${spl_hostid}" ] ; then
8 info "ZFS: Using hostid from command line: ${spl_hostid}"
9 zgenhostid -f "${spl_hostid}"
10 elif [ -f "/etc/hostid" ] ; then
11 info "ZFS: Using hostid from /etc/hostid: $(hostid)"
13 warn "ZFS: No hostid found on kernel command line or /etc/hostid."
14 warn "ZFS: Pools may not import correctly."
20 # We'll take root unset, root=zfs, or root=zfs:
21 # No root set, so we want to read the bootfs attribute. We
22 # can't do that until udev settles so we'll set dummy values
23 # and hope for the best later on.
28 info "ZFS: Enabling autodetection of bootfs after udev settles."
31 ZFS\=*|zfs:*|zfs:FILESYSTEM\=*|FILESYSTEM\=*)
32 # root is explicit ZFS root. Parse it now. We can handle
33 # a root=... param in any of the following formats:
36 # root=zfs:FILESYSTEM=rpool/ROOT
37 # root=FILESYSTEM=rpool/ROOT
38 # root=ZFS=pool+with+space/ROOT+WITH+SPACE (translates to root=ZFS=pool with space/ROOT WITH SPACE)
40 # Strip down to just the pool/fs
42 root="${root#FILESYSTEM=}"
43 root="zfs:${root#ZFS=}"
44 # switch + with spaces because kernel cmdline does not allow us to quote parameters
45 root=$(printf '%s\n' "$root" | sed "s/+/ /g")
49 info "ZFS: Set ${root} as bootfs."
53 # Make sure Dracut is happy that we have a root and will wait for ZFS
54 # modules to settle before mounting.
55 if [ ${wait_for_zfs} -eq 1 ]; then
56 ln -s /dev/null /dev/root 2>/dev/null
57 initqueuedir="${hookdir}/initqueue/finished"
58 test -d "${initqueuedir}" || {
59 initqueuedir="${hookdir}/initqueue-finished"
61 echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh"