2011-03-18 01:18:13 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. /lib/dracut-lib.sh
|
2015-02-15 22:28:42 +03:00
|
|
|
. /lib/dracut-zfs-lib.sh
|
2011-03-18 01:18:13 +03:00
|
|
|
|
2015-02-15 22:28:42 +03:00
|
|
|
ZFS_DATASET=""
|
|
|
|
ZFS_POOL=""
|
2011-07-25 00:53:15 +04:00
|
|
|
|
2015-02-15 22:28:42 +03:00
|
|
|
case "${root}" in
|
|
|
|
zfs:*) ;;
|
|
|
|
*) return ;;
|
|
|
|
esac
|
2011-07-04 21:25:31 +04:00
|
|
|
|
2015-03-23 19:17:56 +03:00
|
|
|
# Delay until all required block devices are present.
|
|
|
|
udevadm settle
|
|
|
|
|
2015-02-15 22:28:42 +03:00
|
|
|
if [ "${root}" = "zfs:AUTO" ] ; then
|
|
|
|
ZFS_DATASET="$(find_bootfs)"
|
|
|
|
if [ $? -ne 0 ] ; then
|
|
|
|
zpool import -N -a ${ZPOOL_IMPORT_OPTS}
|
|
|
|
ZFS_DATASET="$(find_bootfs)"
|
|
|
|
if [ $? -ne 0 ] ; then
|
|
|
|
warn "ZFS: No bootfs attribute found in importable pools."
|
|
|
|
export_all
|
|
|
|
|
|
|
|
rootok=0
|
|
|
|
return 1
|
2011-07-25 00:46:16 +04:00
|
|
|
fi
|
2015-02-15 22:28:42 +03:00
|
|
|
fi
|
|
|
|
info "ZFS: Using ${ZFS_DATASET} as root."
|
|
|
|
fi
|
2011-07-04 21:25:31 +04:00
|
|
|
|
2015-02-15 22:28:42 +03:00
|
|
|
ZFS_DATASET="${ZFS_DATASET:-${root#zfs:}}"
|
|
|
|
ZFS_POOL="${ZFS_DATASET%%/*}"
|
2014-10-06 15:08:33 +04:00
|
|
|
|
2015-02-15 22:28:42 +03:00
|
|
|
if import_pool "${ZFS_POOL}" ; then
|
|
|
|
info "ZFS: Mounting dataset ${ZFS_DATASET}..."
|
|
|
|
if mount_dataset "${ZFS_DATASET}" ; then
|
|
|
|
ROOTFS_MOUNTED=yes
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
rootok=0
|
|
|
|
need_shutdown
|