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