Thursday, April 27, 2017

wipefs

I wanted to throw out a quick post on the heels of my ZFS Seeding Replication post. One of the things I have noticed with ZFS is that it goes to great lengths to protect the data it is responsible for. I'm not sure if my particular problem is a result of that, or of ZFS just doesn't want to leave a disk once the disk has been formatted to ZFS. But there is indeed a problem getting ZFS off of seed disks.

In FreeNAS you would just destroy the zpool and make sure to click the "Mark the disks as new," and call it a day. In Linux, my go-to solutions for quickly nuking the partitions on a disk have been one of the following.


  • dd bs=1M if=/dev/zero of=/dev/sdwhatever
  • cfdisk -z /dev/sdwhatever
But both of those have failed me with ZFS formatted disks. The partitions persist, and unplugging/replugging the drive results in Linux seeing the drive as a ZFS member. I haven't tried actually importing the zpool, now that I think about it. A fun experiment for another time.

The important thing here is the wipefs command, which apparently comes with Ubuntu Gnome 16.10 which is what I'm currently using.


wipefs /dev/sdc
First, show that sdc contains no partition table.
zpool create -f testpool /dev/sdc
ZFS it up!
wipefs /dev/sdc
Now we see a gpt partition table.
zpool export testpool
Export the zpool.
wipefs -a /dev/sdc
From orbit, nuke sdc.
wipefs /dev/sdc
We check sdc once more, and no more partition table, no more ZFS.

There's probably an easier way to do this, but I didn't find any additional options with zpool export, which is where I would expect to find an option to do this.

06/03/2017 Update:
I'm silly. zpool export is for when you want the pool to stay intact, but need to migrate it elsewhere, or turn the system off, or whatever. zpool destroy is the option we want. I'm going to leave this post up, though. wipefs is a handy utility, even if I was being silly.

No comments:

Post a Comment