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"
14 lsblk --output NAME,FSTYPE,MODEL,LABEL,PTTYPE,SIZE -e 7 "$DISK"
15 echo "-> Are you sure you want to continue? (y/n)"
16 read input && if [ "$input" != "y" ]; then exit 1; fi
19 sudo sgdisk -Z "$DISK"
21 # Wipe the metadata off the front of the disk
22 sudo dd if=/dev/zero of="$DISK" count=1 bs=512k
24 # Wipe the metadata off the back of the disk
25 sudo dd if=/dev/zero of="$DISK" seek=$(( $(blockdev --getsz "$DISK") - ( ( 256 * 1024 * 2) / $(blockdev --getpbsz "$DISK") ) ))
28 echo "-> Labels now on the disk"
29 lsblk --output NAME,FSTYPE,MODEL,LABEL,PTTYPE,SIZE -e 7 "$DISK"