Checking if any data exists on a presumably empty storage device
There is a device, /dev/zero
on a linux system that always gives zero when read.
So, how about comparing your hard drive with this device:
cmp /dev/sdX /dev/zero
If all is well with zero-ing out your hard drive it will terminate with:
cmp: EOF on /dev/sdb
telling you that the two files are the same until it got to the end of the hard drive. If there is a non zero bit on the hard drive cmp will tell you where it is in the file.
If you hav the pv
package installed then
pv /dev/sdX | cmp /dev/zero
will do the same thing with a progress bar to keep you amused while it ckecks your drive (the EOF will now be on -
rather than sdX
though).
From https://superuser.com/a/559855/236344:
od
will replace runs of the same thing with *
, so you can easily use it to scan for nonzero bytes:
$ sudo od /dev/disk2 | head
0000000 000000 000000 000000 000000 000000 000000 000000 000000
*
234250000