Sunday 28 Apr 2024

Badblocks command for burn-in test

Image copyright

I have purchased a re-certified hard drive to expand my ZFS pool to support my data growth. I will show how I test the drive prior to committing data, or in my case resilvering my pool.

I check SMART data using smartmontools on linux, and output the results into a log file to review.

smartctl -a /dev/sdX > /path/smart.log

As discussed before, I looked for pending and reallocated sectors. If any pending, I do not trust the drive.

This is only the history of the drive - there could be damaged sectors not yet found. To test for this, I run a command to write data to every block and read it back. If the data changes, we know there are damaged sector. To do this, I use the command badblocks.

By default, badblocks will write out four patterns to every sector and read back as it goes along. This can be time consuming and I just want "a-good-enough" test without waiting days, especially as hard drive capacity increase, I prefer to run one pattern; I use a custom badblocks command with random pattern in destructive mode, that is if you run this command your hard drive contents will be destroyed.

Writes four patterns:

badblocks -b 4096 -wsv /dev/sda

Writes one random pattern (this is the one I am using):

badblocks -wsvt "random" -b 4096 /dev/sdz

w = read / write (destructive)
s = current progress of scan
b = blocksize 4096
v = verbose
t = test pattern, e.g. 0 or "random"

I will write about my resilvering process once the drive arrives and has been tested.

Read the manual.