7 if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then
8 warn "ZFS: Will force-import pools if necessary."
14 # We have ZFS modules loaded, so we're able to import pools now.
15 if [ "$root" = "zfs:AUTO" ] ; then
16 # Need to parse bootfs attribute
17 info "ZFS: Attempting to detect root from imported ZFS pools."
19 # Might be imported by the kernel module, so try searching before
21 zfsbootfs=`zpool list -H -o bootfs | sed 'q'`
22 if [ "$?" != "0" ] || [ "$zfsbootfs" = "" ] || [ "$zfsbootfs" = "no pools available" ] ; then
23 # Not there, so we need to import everything.
24 info "ZFS: Attempting to import additional pools."
25 zpool import -N -a ${ZPOOL_FORCE}
26 zfsbootfs=`zpool list -H -o bootfs | sed 'q'`
27 if [ "$?" != "0" ] || [ "$zfsbootfs" = "" ] || [ "$zfsbootfs" = "no pools available" ] ; then
31 warn "ZFS: No bootfs attribute found in importable pools."
33 # Re-export everything since we're not prepared to take
34 # responsibility for them.
35 zpool list -H | while read fs rest ; do
42 info "ZFS: Using ${zfsbootfs} as root."
44 # Should have an explicit pool set, so just import it and we're done.
45 zfsbootfs="${root#zfs:}"
46 pool="${zfsbootfs%%/*}"
47 if ! zpool list -H $pool > /dev/null ; then
48 # pool wasn't imported automatically by the kernel module, so
50 info "ZFS: Importing pool ${pool}..."
51 if ! zpool import -N ${ZPOOL_FORCE} $pool ; then
52 warn "ZFS: Unable to import pool ${pool}."
60 # Above should have left our rpool imported and pool/dataset in $root.
61 # We need zfsutil for non-legacy mounts and not for legacy mounts.
62 mountpoint=`zfs get -H -o value mountpoint $zfsbootfs`
63 if [ "$mountpoint" = "legacy" ] ; then
64 mount -t zfs "$zfsbootfs" "$NEWROOT" && ROOTFS_MOUNTED=yes
66 mount -o zfsutil -t zfs "$zfsbootfs" "$NEWROOT" && ROOTFS_MOUNTED=yes