0

I bought new external USB 3.0 hard drive WD Elements 2 TB and decided to check it
by using dd, head and md5sum tools.

First I zeroed all hard drive:

root@yurko-laptop:/home/yurko-laptop# dd if=/dev/zero of=/dev/sdb bs=16M
dd: запись «/dev/sdb»: На устройстве кончилось место
119232+0 записей считано
119231+0 записей написано
скопировано 2000365289472 байта (2,0 TB), 91532,5 c, 21,9 MB/c

After that I tried to calculate md5 sum for it.
However when I used head command I obtained message about read error:

root@yurko-laptop:/home/yurko-laptop# head -c 2000365289472 /dev/sdb | md5sum
head: ошибка чтения «/dev/sdb»: Ошибка ввода/вывода
5132d3021b8570c6009877dfd132631f  -

I did this procedure before for USB sticks and it worked without any errors or warnings.

Moreover, md5sum results for /dev/sdb and /dev/zero were different:

yurko-laptop@yurko-laptop:~$ head -c 2000365289472 /dev/zero | md5sum
2635e14edab6b044de7d63dd9a242273  -

The main idea is that after zeroing hard drive md5sum results must be identical.

Does it mean that this hard drive is bad or this approach is not useful in that case?


Update:

In my case fdisk -l /dev/sdb said that sector size is 512 bytes:

root@yurko-laptop:/home/yurko-laptop# fdisk -l /dev/sdb

Disk /dev/sdb: 2000.4 GB, 2000365289472 bytes
255 heads, 63 sectors/track, 243197 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table
root@yurko-laptop:/home/yurko-laptop#

So:

2000365289472 bytes total / 512 sector size = 3906963456 sectors total,
(20 * 1024 * 1024) bytes / 512 sector size = 40960 sectors,
3906963456 sectors total - 40960 sectors = 3906922496 sectors to skip.

I zeroed the last 20 MB of the drive and checked the md5 sum again,
however it was the same as calculated before. Maybe there is some
specific how head command reads /dev/sdb:

root@yurko-laptop:/home/yurko-laptop# dd if=/dev/zero of=/dev/sdb seek=3906922496
dd: запись в «/dev/sdb»: На устройстве кончилось место
40961+0 записей считано
40960+0 записей написано
скопировано 20971520 байт (21 MB), 4,05176 c, 5,2 MB/c
root@yurko-laptop:/home/yurko-laptop# head -c 2000365289472 /dev/sdb | md5sum
head: ошибка чтения «/dev/sdb»: Ошибка ввода/вывода
5132d3021b8570c6009877dfd132631f  -
root@yurko-laptop:/home/yurko-laptop#

Again, for USB sticks it worked.

When I tried to use smartctr, I found out that this hard drive doesn't support S.M.A.R.T. technology:

root@yurko-laptop:/# smartctl -a -d scsi /dev/sdb
smartctl 5.40 2010-07-12 r3124 [i686-pc-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

Device: WD       Elements 10B8    Version: 1007
Serial number: WX21AB3Y5219    
Device type: disk
Local Time is: Sun Aug 17 14:42:49 2014 EEST
Device does not support SMART

Error Counter logging not supported
No self-tests have been logged
root@yurko-laptop:/# 

Still and all, I got a lot of satisfaction from this investigation.

2

One problem is that your hard drive does NOT necessarily fit in full 16MB blocks and as a result the last, lets say 15MB of the drive, is random data from factory or some windows formatting junk, which generates a different md5.

There is nothing to md5 from /dev/zero ! Its virtual. First check whats the logical/physical sector size!

 sudo fdisk -l /dev/sdb

For a new drive it should be 4096. So it means that you can fill your drive with 4096 chunks (block size) of zeros completely, so then:

dd if=/dev/zero of=/dev/sdb bs=4096 conv=notrunc,noerror & pid=$!
kill -USR1 $pidnumer

You can omit the "conv=notrunc,noerror & pid=$!" parts; the kill -USR1 $pidnumer shows you how far the zeroing has progressed. conv and noerror just ensures that every block is tried and upon error (errors are shown in terminal) the zeroing continues. more @

man dd

You can also try to just zero the last 20M of the drive by calculating how many sectors there are and how many you need to skip (check fdisk -l for disk size in bytes). 2,000,000,000,000 bytes/4096=488281250 sectors total. 20,000,768 bytes /4096=4883sectors 488281250-4883=488276367 sectors to seek

 dd if=/dev/zero of=/dev/sdb bs=4096 seek=488276367 conv=notrunc,noerror & pid=$!

then check the md5 again If there were input/output errors dd would show it anyways. Better hdd test tools are smartmontools

smartctl -a /dev/sdb Look for Reallocated_sectors, reallocated sector count, offline uncorrectable, pending sectors. And Error log. Any values of those forementioned is bad news and bring the hdd to warranty. also you can try bonnie++ for example create a partition on the usb disk (doesn't matter what type) , format it and mount it to for example to /dev/sdb1

bonnie++ -u root -d /mnt/sdb1 -n 10:100000000:100:4096 -x 3 -m 5gb

And check the results of bonnie and also /var/log/syslog and other logs for input output errors.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.