Adventures in ZFS: Destroy A Zpool Without Importing

Adventures in ZFS: Destroy A Zpool Without Importing

Recently I ran into an issue where I had a zpool that wasn’t imported in a system, and I was unable to import it due to zpool version incompatibilities.  This can happen if you are going to a older revision of Solaris or if you are crossing platforms between ZFS and OpenZFS.  This posed an interesting problem for me, as how do I destroy a pool that I haven’t imported?  There might be a quick command to handle this, but this actually presented another problem, as in my example I actually had a zpool name collision as well (this was the second mirror in an old rpool).

The first thing I tried was using dd to overwrite the first part of the disk (this is a common solution in Linux, however this didn’t work here, the zpool metadata was still available to the system.  I have no doubt that had I let dd overwrite the whole disk this would have no longer been a problem, however there had to be a better way.

Create Another Zpool on the Member Disk

To get around this problem we need to force create a new zpool on the underlying disk.  This is dangerous, we need to ensure we are using the correct disk device, since we are forcing it to create it will take an active disk the same as an inactive disk.

# zpool create -f tempzpool c9d0

It is worth mentioning that you need to use zpool status to ensure that you are not using an active disk device, you can then cross-reference those disks with format to look for the missing disk.

Destroy the New Zpool

Now that we have created the new zpool we can easily destroy it.

# zpool destroy tempzpool

Once the zpool was destroyed I was able to mirror the disks as expected.