From e801507fcb8003bdb76b79641ab89b3c63f8ccbb Mon Sep 17 00:00:00 2001
From: "Alan J. Pippin" <ajp@pippins.net>
Date: Sun, 8 Jan 2023 11:43:24 -0700
Subject: [PATCH] Tweaked dd commands for label clear operation

Change-Id: I2ccffbf5b5cfaabe60a68af76f5a271e342c16c1
---
 zfs-labelclear | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/zfs-labelclear b/zfs-labelclear
index a1f07b4..1f319e3 100755
--- a/zfs-labelclear
+++ b/zfs-labelclear
@@ -11,19 +11,21 @@ fi
 
 # List the labels
 echo "-> About to clear these labels off of this disk: $DISK" 
+blkid "$DISK"
 lsblk --output NAME,FSTYPE,MODEL,LABEL,PTTYPE,SIZE -e 7 "$DISK"
 echo "-> Are you sure you want to continue? (y/n)"
 read input && if [ "$input" != "y" ]; then exit 1; fi
 
-# Wipe all partitions
+# Wipe all partitions and MBR and GPT labels
 sudo sgdisk -Z "$DISK"
 
 # Wipe the metadata off the front of the disk
-sudo dd if=/dev/zero of="$DISK" count=1 bs=512k
+sudo dd if=/dev/zero of="$DISK" bs=512k count=10
 
 # Wipe the metadata off the back of the disk
-sudo dd if=/dev/zero of="$DISK" seek=$(( $(blockdev --getsz "$DISK") - ( ( 256 * 1024 * 2) / $(blockdev --getpbsz "$DISK") ) ))
+sudo dd if=/dev/zero of="$DISK" bs=512k seek=$(( $(blockdev --getsz "$DISK") - 4096 )) count=1M
 
 # List the labels
 echo "-> Labels now on the disk"
+blkid "$DISK"
 lsblk --output NAME,FSTYPE,MODEL,LABEL,PTTYPE,SIZE -e 7 "$DISK"
-- 
2.34.1