Reusing a ZFS drive for another filesystem

Reusing a ZFS drive for another filesystem

It's a good practice to swap out drives in critical storage as they get old before they fail, or perhaps you've upgraded the drives from 1TB to 4TB to increase storage in your ZFS array, but wan't to use those old 1TB drives for something else, less critical. Particularly if you're going to use the drive both in Windows and Linux you're likely to run into trouble.

Here's what's likely to happen.

Let's say you format the drive in Linux as NTFS. Everything looks good initially, but when you reboot into Windows it can't see what you just spent an hour copying to the drive.

Or, you format it in Windows as NTFS but then Linux refuses to mount the partition, claiming it doesn't know what a ZFS filesystem is.

Fixing the issue

ZFS does a good job of ensuring that if something goes wrong it can still recover, and that includes some pretty redundant and sticky flags for the drive that can cause these types of scenarios. There's probably several ways to fix this, but here's the way I use.

BE CAREFUL! If you choose the wrong destination device you will toast whatever is on it!
dd if=/dev/zero of=/dev/sdg bs=512 count=1 conv=notrunc

This will write all zero's to the start of drive /dev/sdg. Note you'll need to replace "sdg" with whatever your drive is listed as. If you don't know how to find that out, you probably shouldn't be doing this because you're likely to lose data. You also cannot have any filesystem mounted when you do this.

Once this is run, you can then create a new GPT structure and partition the drive.

Posted by Tony on Nov 06, 2018 |