diff --git a/src/sbin/opnsense-importer b/src/sbin/opnsense-importer index 7ac727043..54da94445 100755 --- a/src/sbin/opnsense-importer +++ b/src/sbin/opnsense-importer @@ -111,6 +111,16 @@ timeout_prompt() return ${RETURN} } +zfs_load() +{ + # we need to load ZFS to list pools + if kldstat -qm zfs; then + export ZFS="yes" + else + kldload zfs + fi +} + probe_for_part() { DEV=${1} @@ -124,11 +134,6 @@ probe_for_part() export PART="/dev/${DEV}p3" return 0 elif [ "${DEV}" = "zroot" ]; then - if kldstat -qm zfs; then - export ZFS="yes" - else - kldload zfs - fi if zpool import | awk '{ print $1 " " $2 }' | grep -q "${DEV} ONLINE"; then export POOL="${DEV}" return 0 @@ -142,6 +147,8 @@ DEVS= PART= if [ -n "${1}" ]; then + zfs_load + if ! probe_for_part ${1}; then echo "No previous configuration was found on this device." bootstrap_and_exit 1 @@ -159,6 +166,8 @@ else fi fi + zfs_load + DEVS=$(camcontrol devlist; gmirror status -s; graid status -s) fi @@ -197,8 +206,8 @@ elif [ -n "${POOL}" ]; then echo "Starting import for ZFS pool '${POOL}'." echo - if ! zpool import -f -R /tmp/hdrescue ${POOL} && \ - zfs mount ${POOL}/ROOT/default; then + zpool import -f -R /tmp/hdrescue ${POOL}; + if ! zfs mount ${POOL}/ROOT/default; then echo "The device could not be mounted." fi fi