@ -251,6 +251,11 @@ fi
# Set variables based on the value of REAL_ROOT
# Set variables based on the value of REAL_ROOT
case "${REAL_ROOT}" in
case "${REAL_ROOT}" in
ZFS*)
ZFS*)
ZFS_POOL=${REAL_ROOT#*=}
ZFS_POOL=${ZFS_POOL%%/*}
USE_ZFS=1
;;
ZFS)
USE_ZFS=1
USE_ZFS=1
;;
;;
esac
esac
@ -258,12 +263,15 @@ esac
# Verify that it is safe to use ZFS
# Verify that it is safe to use ZFS
if [ "USE_ZFS" = "1" ]
if [ "USE_ZFS" = "1" ]
then
then
if [ -x /sbin/zfs ]
if [ -x /sbin/zfs -a -x /sbin/zpool ]
then
then
MY_HWOPTS="${MY_HWOPTS} zfs"
MY_HWOPTS="${MY_HWOPTS} zfs"
else
else
bad_msg 'zfs binary not found: aborting use of zfs!'
USE_ZFS=0
USE_ZFS=0
[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
bad_msg 'Aborting use of zfs!'
fi
fi
fi
fi
@ -486,16 +494,24 @@ do
fi
fi
;;
;;
ZFS*)
ZFS*)
if [ "${USE_ZFS}" = '0' ]; then
prompt_user "REAL_ROOT" "root block device"
continue
fi
ROOT_DEV="${REAL_ROOT#*=}"
ROOT_DEV="${REAL_ROOT#*=}"
if [ "${ROOT_DEV}" != 'ZFS' ]
if [ "${ROOT_DEV}" != 'ZFS' ]
then
then
zfs get type ${ROOT_DEV} > /dev/null
if [ "$(zfs get type -o value -H ${ROOT_DEV})" = 'filesystem' ]
if [ "$?" = '0' ]
then
then
got_good_root=1;
got_good_root=1;
REAL_ROOT=${ROOT_DEV}
REAL_ROOT=${ROOT_DEV}
ROOTFSTYPE=zfs
ROOTFSTYPE=zfs
else
bad_msg "${ROOT_DEV} is not a filesystem"
prompt_user "REAL_ROOT" "root block device"
got_good_root=0
continue
fi
fi
else
else
BOOTFS=$(/sbin/zpool list -H -o bootfs)
BOOTFS=$(/sbin/zpool list -H -o bootfs)
@ -562,8 +578,13 @@ do
good_msg "Mounting $REAL_ROOT as root..."
good_msg "Mounting $REAL_ROOT as root..."
if [ "${ROOTFSTYPE}" = 'zfs' ]
if [ "${ROOTFSTYPE}" = 'zfs' ]
then
if [ "zfs get -H -o value mountpoint ${REAL_ROOT}" = 'legacy' ]
then
then
MOUNT_STATE=rw
MOUNT_STATE=rw
else
MOUNT_STATE=rw,zfsutil
fi
else
else
MOUNT_STATE=ro
MOUNT_STATE=ro
fi
fi