]> git.proxmox.com Git - mirror_zfs.git/blob - contrib/dracut/90zfs/parse-zfs.sh.in
contrib: dracut: parse-zfs: stop pretending we support FILESYSTEM=
[mirror_zfs.git] / contrib / dracut / 90zfs / parse-zfs.sh.in
1 #!/bin/sh
2 # shellcheck disable=SC2034,SC2154
3
4 . /lib/dracut-lib.sh
5
6 # Let the command line override our host id.
7 spl_hostid=$(getarg spl_hostid=)
8 if [ -n "${spl_hostid}" ] ; then
9 info "ZFS: Using hostid from command line: ${spl_hostid}"
10 zgenhostid -f "${spl_hostid}"
11 elif [ -f "/etc/hostid" ] ; then
12 info "ZFS: Using hostid from /etc/hostid: $(hostid)"
13 else
14 warn "ZFS: No hostid found on kernel command line or /etc/hostid."
15 warn "ZFS: Pools may not import correctly."
16 fi
17
18 wait_for_zfs=0
19 case "${root}" in
20 ""|zfs|zfs:)
21 # We'll take root unset, root=zfs, or root=zfs:
22 # No root set, so we want to read the bootfs attribute. We
23 # can't do that until udev settles so we'll set dummy values
24 # and hope for the best later on.
25 root="zfs:AUTO"
26 rootok=1
27 wait_for_zfs=1
28
29 info "ZFS: Enabling autodetection of bootfs after udev settles."
30 ;;
31
32 ZFS=*|zfs:*)
33 # root is explicit ZFS root. Parse it now. We can handle
34 # a root=... param in any of the following formats:
35 # root=ZFS=rpool/ROOT
36 # root=zfs:rpool/ROOT
37 # root=ZFS=pool+with+space/ROOT+WITH+SPACE (translates to root=ZFS=pool with space/ROOT WITH SPACE)
38
39 # Strip down to just the pool/fs
40 root="${root#zfs:}"
41 root="zfs:${root#ZFS=}"
42 # switch + with spaces because kernel cmdline does not allow us to quote parameters
43 root=$(echo "$root" | tr '+' ' ')
44 rootok=1
45 wait_for_zfs=1
46
47 info "ZFS: Set ${root} as bootfs."
48 ;;
49
50 *)
51 info "ZFS: no ZFS-on-root"
52 esac
53
54 # Make sure Dracut is happy that we have a root and will wait for ZFS
55 # modules to settle before mounting.
56 if [ "${wait_for_zfs}" -eq 1 ]; then
57 ln -s /dev/null /dev/root 2>/dev/null
58 initqueuedir="${hookdir}/initqueue/finished"
59 echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh"
60 fi