ZFS How to un-ZFS-ify a drive?

I put ZFS on a microSD card to try s.th. out (keylocation file to prompt). Worked as hoped for.

How does one remove ZFS from the drive again? So that gpart shows the device and I can dd an OS image onto it?

Actually, I find it confusing that a ZFS drive goes under the radar of gpart.
 
I find it confusing that a ZFS drive goes under the radar of gpart.
It doesn't. But it will if you use the whole disk for ZFS, but that's not "under the radar". There's simply no partition table at all.
 
Are you doing this from a FreeBSD system?
Exactly what gpart command are you running, gpart list?
What does "geom disk list" show?
How about just "ls -ltr /dev/da*"

If geom disk list shows da0 and ls -ltr /dev/da* also shows something, does "mount" or "zfs list" show anything related to da0?
Related to SirDice how did you initially set up zfs on da0?

In theory, as long as nothing is mounted /using da0 you should be able to do gpart commands to create a partition table.
 
Are you doing this from a FreeBSD system?
Exactly what gpart command are you running, gpart list?
What does "geom disk list" show?
How about just "ls -ltr /dev/da*"

If geom disk list shows da0 and ls -ltr /dev/da* also shows something, does "mount" or "zfs list" show anything related to da0?
yes, 15.0-RELEASE-p1

Geom name: da0
Providers:
1. Name: da0
Mediasize: 31927042048 (30G)

zfs list
no datasets available

ls /dev/da0
/dev/da0
 
Still, it could show s.th. like

34 500118125 ada0 GPT (238G)
- zfs - (238G)
Not if you created the zpool on the "whole device". That would have wiped out any existing partition table.

So based #7, you should be able to do "gpart create -s GPT /dev/da0" If you do that, it will probably show up under gpart list
 
Why would it show partition information if there's no partition table on the disk?
I think this confuses some people because a brand new USB drive you get from Walmart "shows up" simply because it has a partition table of some sort because it's been formatted to some kind of Windows thing.
"Why does a brand new one show up but one I mucked with doesn't".
 
Not if you created the zpool on the "whole device". That would have wiped out any existing partition table.

So based #7, you should be able to do "gpart create -s GPT /dev/da0" If you do that, it will probably show up under gpart list
That did the trick. Thank you.

Bash:
# gpart create -s GPT /dev/da0
da0 created
# gpart show
..
=>      40  62357424  da0  GPT  (30G)
        40  62357424       - free -  (30G)
 
Now you can add partitions :
gpart add -t freebsd-zfs -s mysize -l mylabel /dev/da0
gpart add -t freebsd-ufs -s mysize -l mylabel /dev/da0
gpart add -t linux-data ada0 (for ext4)
gpart add -t ms-basic-data (for ntfs)
gpart add -t \!12 (for msdos)
 
Using CoW filesystems on devices like USB pendrives and SD cards with no wear leveling is a bad idea due to the write amplification. Someone should tell the NomadBSD guys to add this warning.
 
You may want to check what util-linux wipefs does or even call it with `wipefs -a -f $DEV` because I remember dd at the beginning not being enough sometimes. =/
My experience with doing dd to clear stuff is "how much". If one looks at partition table sizes you think "1M should be enough" but it's not. Over the years I've seen recommendations of up to 100MB which I think covers even MS defaults for efi partitioning.
Meta Data seems to wind up in a few places:
Beginning of device (first X sectors)
End of device (last Y sectors)
Beginning of partition
End of partition

The easiest way to clear (most tedious and often not needed) is dd if=/dev/zero over the whole device
 
For an empty disk :
gpart create -s MBR
gpart create -s GPT
But remember that this (and the various other posts of the same sort) will destroy any data currently stored on the device.

My experience with doing dd to clear stuff is "how much". If one looks at partition table sizes you think "1M should be enough" but it's not. ...
The easiest way to clear (most tedious and often not needed) is dd if=/dev/zero over the whole device
A hundred or a few hundred MB at the beginning, and a few MB at the very end.

That should work nearly all the time to destroy enough that normal operations (such as reading partition tables or trying to mount) will correctly show that the disk is empty. My personal technique is to just start a dd at the beginning, then do something else (like check e-mail or get another coffee), then hit control C, and make sure the write speed was reasonable (roughly 100 MB/second or more). Then do the very end to get rid of the backup copy of the partition table. That is actually quite difficult, since you need something like camcontrol or smartctl to find out how big the disk hardware is.
 
Back
Top