2 # Wipes the ZFS labels off of a disk
3 # The metadata of zfs is stored in the first and last two 256kB of each disk involved in zfs.
8 echo "Usage: $0 <disk>"
13 echo "-> About to clear these labels off of this disk: $DISK"
15 lsblk --output NAME,FSTYPE,MODEL,LABEL,PTTYPE,SIZE -e 7 "$DISK"
16 echo "-> Are you sure you want to continue? (y/n)"
17 read input && if [ "$input" != "y" ]; then exit 1; fi
19 # Wipe all partitions and MBR and GPT labels
20 sudo sgdisk -Z "$DISK"
22 # Wipe the metadata off the front of the disk
23 sudo dd if=/dev/zero of="$DISK" bs=512k count=10
25 # Wipe the metadata off the back of the disk
26 sudo dd if=/dev/zero of="$DISK" bs=512k seek=$(( $(blockdev --getsz "$DISK") - 4096 )) count=1M
29 echo "-> Labels now on the disk"
31 lsblk --output NAME,FSTYPE,MODEL,LABEL,PTTYPE,SIZE -e 7 "$DISK"