a5e84ad1915e5bbcd49af793beb51b73316ceee4
[zfs.git] / dracut / 90zfs / parse-zfs.sh
1 #!/bin/sh
2
3 . /lib/dracut-lib.sh
4
5 # Let the command line override our host id.
6 spl_hostid=`getarg spl_hostid=`
7 if [ "${spl_hostid}" != "" ] ; then
8         info "ZFS: Using hostid from command line: ${spl_hostid}"
9         echo "${spl_hostid}" > /etc/hostid
10 elif [ -f /etc/hostid ] ; then
11         info "ZFS: Using hostid from /etc/hostid: `cat /etc/hostid`"
12 else
13         warn "ZFS: No hostid found on kernel command line or /etc/hostid.  ZFS pools may not import correctly."
14 fi
15
16 case "$root" in
17         ""|zfs|zfs:)
18                 # We'll take root unset, root=zfs, or root=zfs:
19                 # No root set, so we want to read the bootfs attribute.  We can't do
20                 # that until udev settles so we'll set dummy values and hope for the
21                 # best later on.
22                 root="zfs:AUTO"
23                 rootok=1
24
25                 info "ZFS: Enabling autodetection of bootfs after udev settles."
26                 ;;
27
28         ZFS\=*|zfs:*|zfs:FILESYSTEM\=*|FILESYSTEM\=*)
29                 # root is explicit ZFS root.  Parse it now.
30                 # We can handle a root=... param in any of the following formats:
31                 # root=ZFS=rpool/ROOT
32                 # root=zfs:rpool/ROOT
33                 # root=zfs:FILESYSTEM=rpool/ROOT
34                 # root=FILESYSTEM=rpool/ROOT
35
36                 # Strip down to just the pool/fs
37                 root="${root#zfs:}"
38                 root="${root#FILESYSTEM=}"
39                 root="zfs:${root#ZFS=}"
40                 rootok=1
41
42                 info "ZFS: Set ${root} as bootfs."
43                 ;;
44 esac
45
46 # Make sure Dracut is happy that we have a root and will wait for ZFS
47 # modules to settle before mounting.
48 ln -s /dev/null /dev/root 2>/dev/null
49 echo '[ -e /dev/zfs ]' > $hookdir/initqueue/finished/zfs.sh