disk3=/dev/disk/by-id/ata-CT500MX500SSD1_2045E4C5724A
lsblk --output NAME,MODEL,SERIAL,WWN -D $disk3
NAME MODEL SERIAL WWN
sdu CT500MX500SSD1 2045E4C5724A 0x500a0751e4c5724a
├─sdu1 0x500a0751e4c5724a
├─sdu2 0x500a0751e4c5724a
└─sdu3 0x500a0751e4c5724a
disk3_wwn=wwn-0x500a0751e4c5724a
sgdisk --print $disk3
Disk /dev/disk/by-id/ata-CT500MX500SSD1_2045E4C5724A: 976773168 sectors, 465.8 GiB
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): DE43CD39-B54D-42C5-AA26-055B989D5520
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 968386540 sectors (461.8 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02 BIOS boot partition
2 4096 4194304 2.0 GiB EF00 EFI system partition
3 4196352 8390655 2.0 GiB EF00 EFI system partition
# check ZFS labels on the added drive
# check for ZFS labels?
for part in $disk3 ${disk3}-part{1..3}; do echo $part; zdb -l $part; done
✅ clear, there was none
# preview wipefs for $disk3
wipefs --no-act --all $disk3-part3
wipefs --no-act --all $disk3-part2 # vfat
wipefs --no-act --all $disk3-part1
wipefs --no-act --all $disk3 # GPT
# $disk3 ZAP dry run safety check
printf $disk3 | grep 'C5724A$' && { echo match; echo zapping...; echo; echo sgdisk --zap-all $disk3; printf "\nzapped. exit code: %s\n" "$?"; }
/dev/disk/by-id/ata-CT500MX500SSD1_2045E4C5724A
match
zapping...
sgdisk --zap-all /dev/disk/by-id/ata-CT500MX500SSD1_2045E4C5724A
zapped. exit code: 0
# 💥 ZAP $disk3
printf $disk3 | grep 'C5724A$' && { echo match; echo zapping...; echo; sgdisk --zap-all $disk3; printf "\nzapped. exit code: %s\n" "$?"; }
/dev/disk/by-id/ata-CT500MX500SSD1_2045E4C5724A
match
zapping...
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
zapped. exit code: 0
# 👆 this zeroed at least the first 20480 bytes / 20 KiB of the drive and reloaded the partition table
# The GPT partition table is 16,384 bytes / 32 KiB, or 32 (512 byte) sectors, starting on sector 2
# AFAIK the MBR is stored on sector 1 (the first 512 bytes of the disk)
# The GPT header and partition table are written at both the beginning and end of the disk.
# The last 1MiB of the disk was also zeroed, unclear how much was performed by sgdisk.
# how I verified this
root@viper:/var/tmp# lscpu |grep Endian
Byte Order: Little Endian
endianness=little
# dump the first 1MiB of $disk3 to file
dd iflag=direct if=$disk3 bs=1M count=1 of=/var/tmp/CT500MX500SSD1_2045E4C5724A-1M-after.device
# hex dump first 1MiB
od -A x -t x2z --endian=$endianness CT500MX500SSD1_2045E4C5724A-1M-after.device |head
000000 0000 0000 0000 0000 0000 0000 0000 0000 >................<
*
005000 4241 4333 0000 0200 ffff ffff ffff ffff >AB3C............<
# 👆 this od format is very close to xxd format and has the advantge of being able to detect and skip duplicates.
# format: hex byte offset followed by 8 pairs of hex bytes, followed by the ASCII representation
# the * represents that between offset 000000 to 005000 the bytes were duplicates of the previous offset (zeroed)
# hex 005000 represents the byte offset, the offset of the first byte displayed on that line of the dump
# also the offset of the end of the previous 16 bytes
# hex 005000 = 20480 decimal, so we can see from offset 000000 to 20480 the bytes were zeroed
# dump the last 1MiB of $disk3 to file (976773168 - 2048 * 512 = 976771120) (2048 * 512 bytes = 1MiB)
dd iflag=direct if=$disk3 bs=512 skip=976771120 of=/var/tmp/CT500MX500SSD1_2045E4C5724A-1M-END-after.device
# hex dump - we sees the full 1MiB has been zeroed
root@viper:/var/tmp# od -A x -t x2z --endian=$endianness CT500MX500SSD1_2045E4C5724A-1M-END-after.device
000000 0000 0000 0000 0000 0000 0000 0000 0000 >................<
*
100000
# the disk is ready to be used :)