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