tinyapps.org / blog


Verify disk wipe #

After zero-filling a disk, verify with hexdump or md5sum and All-Zero Hash Calculator. On a 2.5" 500GB SATA drive, both hexdump and md5sum took 144m16s to run.

1. hexdump:

   # hexdump /dev/sda
   0000000 0000 0000 0000 0000 0000 0000 0000 0000
   *
   7470c06000

7470c06000 hex = 500107862016 decimal, which is the number of bytes on disk.

UPDATE 1: Rather than waiting for the entire disk to be dumped, run sudo diff -s -q --speed-large-files /dev/zero /dev/sda to terminate the process once any nonzero value is encountered. 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).

UPDATE 2: By combining dd (from coreutils-8.24 or higher) with hexdump, progress can be monitored like so:

    # dd if=/dev/sda bs=8192 status=progress | hexdump 
    0000000 0000 0000 0000 0000 0000 0000 0000 0000
    *
    1147183104 bytes (1.1 GB, 1.1 GiB) copied, 3.00001 s, 382 MB/s

2. md5sum and All-Zero Hash Calculator:

   # md5sum /dev/sda
   91564846bfd6055945b31bbd831378a7

You'll need 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

/nix | Jan 29, 2012


Subscribe or visit the archives