Do you check if the hard disk drive (HDD) is serviceable before using it? Nowadays, the emphasis on storage reliability has silently increased as more people are leveraging network attached storage (NAS) and external storage enclosures to back up their data. But what makes these storage solutions reliable? The building blocks – HDD! How do one ensure the new HDD is reliable? Personally, I qualify them using a Linux utility call badblocks and I recommend you do something similar too.
But wait. I thought there is S.M.A.R.T?
Self-Monitoring, Analysis, and Reporting Technology, or S.M.A.R.T., for HDDs keep tabs or a record of the HDD’s metrics. From number of times the HDD is powered on or the duration of operating hours; to the amount of discovered or reallocated bad blocks. Isn’t this the answer we are looking for? Not really. S.M.A.R.T. keeps a record of events. That is to say, if you are writing a file to a new area on the HDD and discovered a bad block, it will be recorded by S.M.A.R.T. However, it does not know if there are bad blocks in untouched area. Period.
What are bad blocks? What is badblocks?
Bad blocks are actually spots on the hard disk drive (HDD) that you can no longer write to or read from. It may result from a manufacturing error; natural wear, physical damage from the hard drive’s head hitting the platter when it is dropped, etc. In short, it is not a nice thing to have on your HDD. Nowadays, HDDs are smart enough to remap the identified bad blocks with available extra blocks.
So bad blocks are either:
- Pre-existing but not discovered; or
- Created subsequently created due to wear or damage.
Now on to another badblocks. badblocks is a program to test storage device for bad blocks. While S.M.A.R.T passively wait for errors to be discovered and updates the metrics on bad blocks, badblocks [program] proactively checks for bad blocks by writing patterns to every block and then checking them to identify damaged areas.
Running badblocks [program] proactively identifies the bad blocks in scenario 1 above. If you are uncomfortable with the discovered bad blocks, you can attempt a warranty replacement claim or even a return if the manufacturer or retailer allows it.
Running badblocks is a time consuming activity
Just a heads up, running the badblocks test is a time consuming activity but it gives you peace of mind. I am not talking about a couple of hours; I am referring to tens to hundreds of hours. Is it worth it? I reckon it is because I rather spend time qualifying HDD for use than spending it on rebuilding RAID later on.
The time required to complete the test depends on a few factors, mainly – storage capacity (size) and read/write throughput of the HDD. The larger the capacity, more time is required to check every block. The higher the throughput, lesser time is required as more blocks can be addressed in one instruction.
Just for the record, my Seagate Barracuda Pro 10TB HDD took approximately 112 hours to complete. It is almost five (5) days.
Sidetrack: The Seagate Barracuda Pro 10TB
I bought some Seagate Barracuda Pro 10TB HDDs for my new Synology Network Attached Storage (NAS). These are CMR (Conventional Magnetic Recording) hard drives and are better for NAS usage compared to SMR (Shingled Magnetic Recording). Seagate has a page listing which of their products are using CMR and SMR.
Just some key advantages of Seagate Barracuda Pro series. They are 7,200 RPM drives with sustained data rates up to 250 MB/s and burst data rate of 6 Gb/s. They also have 300TB/year workload limit and MTBF of 1M hours which makes them great for home servers.
But wait. Ain’t my new HDD taking a hit doing this rigorous test?
Honestly, it does but it is for a good cause as you will be assured that it does not have pre-existing bad blocks.
If you have a new 10TB HDD that is rated for 300TB annual workload, you would probably utilize 80TB (four sets of 10TB reads and writes). This is 26.7% (80/300 x 100) of the annualized workload.
Warning: If you have concerns with the hit, do not proceed with the test. If you are using a SSD, I recommend that you do not proceed because they have limited lifespan.
Running badblocks test
Warning: The badblocks test recommended in this guide will destroy any existing data on the HDD. Do your own backups.
Booting into Linux
If you do not have a Linux-based system, you either have to borrow it from a friend or set one up. You can actually have a bootable Linux on USB stick. For this, I recommend the bootable Ubuntu on USB. To set one up, simply follow the guide on creating a bootable Ubuntu USB stick.
Locating the block storage
You can attach the HDD to be tested via the SATA port or via an USB enclosure. Following which, you can use the following command to identify the HDD.
One important thing to note is that HDD to be tested might come with multiple partitions. You should run it on every partition to test every nook and cranny of the HDD.
$ sudo badblocks -wvs -b 4096 /dev/sdXX
# Do change /dev/sdXX to the correct partition to be tested
# -w: do a destructive write test
# -v: verbose
# -s: show progress
# -b 4096: set block size to 4096 bytes (4K)
What’s left is waiting for the test to complete.
Desired badblocks results
The desired results is badblocks stating the test is completed with 0 bad blocks found.
Pass completed, 0 bad blocks found. (0/0/0) errors.