Technology

How to test a new hard drive

Joost van der Laan
#harddrive
#test
#zfs
#badblocks
#smart
#scrub

How to test a new hard drive

Hard drives break a lot. In fact, it is the part of a computer that breaks most of all. While we cannot prevent them from breaking, we can make sure we got a good new drive to begin with. Before starting to use a new harddrive, it is wise to test it to see if you received one without faults. Especially for big NAS disks that will be holding a lot of your valuable data. For big disks, this will take a long time, but at least you can be sure your new disk is not faulty. 8TB disks will take around 5 days to test, 12TB around 9 days.

Also, if you bought an external drive to shuck it (remove it from the external drive enclosure), run this test before shucking your drive.

The test

If you have multiple drives, plug them in 1 by 1 so you know which drive is which.

1. SMART Test

Check the drive stats from SMART. Replace /dev/sd* with the correct drive letter.

sudo apt-get install smartmontools

smartctl -A /dev/sd*

smartctl -t long /dev/sd*

For Western Digital mybook usb drive add -d sat to smartctl.

The smart long test will take ~1000 minutes with 8TB. This test does not give feedback, it seems like it is doing nothing.

To view test results:

sudo smartctl -a /dev/sd*

sudo smartctl -d sat -a /dev/sd*
sudo smartctl -d sat -a --tolerance permissive /dev/sd*

2) BadBlocks test - m

This is a complete write and read test, it will destroy all data on the harddrive.

# if mounted, unmount the disk first
sudo umount /dev/sd*

sudo badblocks -b 4096 -wsv /dev/sd*

Example run:

sudo badblocks -b 4096 -wsv /dev/sdg Checking for bad blocks in read-write mode From block 0 to
1953506559 Testing with pattern 0xaa: done
Reading and comparing: done
Testing with pattern 0x55: done
Reading and comparing: done
Testing with pattern 0xff: done
Reading and comparing: done
Testing with pattern 0x00: done
Reading and comparing: done
Pass completed, 0 bad blocks found. (0/0/0 errors)

This takes approximately 123 hours (5 days) for a 8TB disk.

3) ZFS format

It is possible to find compression errors with compression on, which would be missed with compression off. Therefore we turn on compression.

zpool create -f -o ashift=12 -O logbias=throughput -O compress=lz4 -O dedup=off -O atime=off -O xattr=sa TESTrunpool /dev/sd*

zpool export TESTrunpool

sudo zpool import -d /dev/disk/by-id TESTrunpool

sudo chmod -R ugo+rw /TESTrunpool

4) Fill Test with F3

f3write /TESTrunpool && f3read /TESTrunpool

5) ZFS Scrub

To check for read, write and checksum errors.

zpool scrub TESTrunpool

Finished!

All tests passed? Great, you have a good drive! Still, don’t forget harddrives break a lot, more then any other part in a computer.

If not, contact the reseller and send it back or get a refund. Write down the serial number and the test results.

8TB wwn-0x5000cca267e4a96d - Passed

8TB wwn-0x5000cca27dc2265e - Passed

8TB wwn-0x5000cca099c4d828 - Failed, 12 -Read errors, non recoverable, drive is
unsafe to use.

8TB wwn-0x5000cca099c4d828 - Failed, CheckSum errors, possibly recoverable,
drive use is not recommended.
← Back to Blog