ZFS Prevent zpools from being mounted

I had an old server crash and moved the HDDs from that system to another, but then imported the zools incorrectly which clobbered root filesystem making nothing work (including any zfs commands to try to fix it). Unseating those transferred drives allows the system to boot up again properly, but now zfs will recognize that zpool as being last mounted by this system and automatically import it if I were to seat the hotswap tray again. How do I prevent the system from recognizing this zpool and allow me to import it correctly?
 
Does a simple zpool export poolname do the job? I want to make sure before I have remote hands do a lot of back and forth.
 
For my backup pool/remote mirror (where I feared for such things happening) I resorted to drop this into /etc/rc.d/zfsnomount-local:
Code:
#!/bin/sh
#

# PROVIDE: zfsnomount
# REQUIRE: zfsbe
# BEFORE: zfs

. /etc/rc.subr

name="zfsnomount"
desc="block ZFS backup pools from mounting"
rcvar="zfs_enable"
start_cmd="zfsnomount_start"
stop_cmd="zfsnomount_start"
required_modules="zfs"

zfsnomount_start()
{
        echo "Inhibit backup ZFS pool from mounting"
        local fs
        zfs list -o name -t filesystem | grep "^backup/" | while read fs; do
                zfs set canmount=off "$fs"
        done
}

load_rc_config $name
run_rc_command "$1"
 
Thanks PMc, since it appeared to me that this post got rejected, I went ahead and tried the zpool export poolname option and it worked. Then I mounted the zpool correctly using the zpool -R mountpoint poolname option.
 
Back
Top