Verify disk wipe #

1. dd & hexdump

dd if=/dev/sda bs=8192 status=progress | hexdump

2. diff (terminate on any nonzero value)

sudo diff -s -q --speed-large-files /dev/zero /dev/sda

(A similar result can be obtained via: sudo hexdump /dev/sda | head -n 3 though the process terminates with a "Command terminated abnormally." error message if any nonzero value is encountered).

3. md5sum (simultaneous hash calculation)

dd if=/dev/sda bs=1M status=progress | tee >(hexdump -C >&2) | md5sum
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
  251000193024 bytes (251 GB, 234 GiB) copied, 1099.66 s, 228 MB/s
...
3a70c70000
f0b051b7e64c7c3ebe055080cdbdf945  -

3a70c70000 is the hexadecimal byte offset from hexdump; converting to decimal (printf "%d\n" 0x3a70c70000) = 251000193024 bytes. f0b051b7e64c7c3ebe055080cdbdf945 is the MD5 checksum.

4. All-Zero Hash Calculator

"[C]alculates the expected CRC32 (ITU-T V.42), MD5, SHA1 and SHA256 hash values for a specified length of all-zero data." You'll need either the number of bytes or sectors (the latter may be listed on the drive sticker as LBA) to verify the hash:

fdisk -l /dev/sda
Disk /dev/sda: 500.1 GB,  500107862016 bytes

testdisk /dev/sda
Proceed > None > Advanced > Size in sectors
976773168

5. See also

/nix | Jan 29, 2012


RSS | Archives