Files
mirror_zfs/contrib/dracut/90zfs/mount-zfs.sh.in
T

57 lines
1.3 KiB
Bash
Raw Normal View History

2011-03-17 15:18:13 -07:00
#!/bin/sh
2015-02-15 20:28:42 +01:00
. /lib/dracut-zfs-lib.sh
2011-03-17 15:18:13 -07:00
2015-02-15 20:28:42 +01:00
ZFS_DATASET=""
ZFS_POOL=""
2011-07-24 16:53:15 -04:00
2015-02-15 20:28:42 +01:00
case "${root}" in
zfs:*) ;;
*) return ;;
esac
2011-07-04 13:25:31 -04:00
if command -v systemctl >/dev/null; then
# If sysroot.mount exists, the initial RAM disk configured
# it to mount ZFS on root. In that case, we bail early.
loadstate="$(systemctl --system --show -p LoadState sysroot.mount || true)"
if [ "${loadstate}" = "LoadState=not-found" -o "${loadstate}" = "" ] ; then
info "ZFS: sysroot.mount absent, mounting root with mount-zfs.sh"
else
info "ZFS: sysroot.mount present, delegating root mount to it"
return
fi
2016-04-24 11:35:44 +00:00
fi
# Delay until all required block devices are present.
udevadm settle
2015-02-15 20:28:42 +01: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."
2015-02-16 09:56:04 +01:00
export_all || export_all "-f"
2015-02-15 20:28:42 +01:00
rootok=0
return 1
2011-07-24 16:46:16 -04:00
fi
2015-02-15 20:28:42 +01:00
fi
info "ZFS: Using ${ZFS_DATASET} as root."
fi
2011-07-04 13:25:31 -04:00
2015-02-15 20:28:42 +01:00
ZFS_DATASET="${ZFS_DATASET:-${root#zfs:}}"
ZFS_POOL="${ZFS_DATASET%%/*}"
2015-02-15 20:28:42 +01: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