I recently re-built an older PC from a laundry list of Frankenstein parts. However before installing anything to the hard drive I found I wanted to check it for physical errors and problems as I couldn’t remember why I wasn’t using this particular drive in any of my other systems.
From an Ubuntu 12.04 live CD I used GParted to to delete the old partition on the drive. This let me start from a clean slate. After the drive had absolutely nothing on it I went searching for an easy way to test the drive for errors. I stumbled across this excellent article and began using badblocks to scan the drive. Basically what this program does is write to every spot on the drive and then read it back to ensure that it still holds the data that was just written.
Here is the command I used. NOTE: This command is destructive and will damage the data on the hard drive. DO NOT use this if you want to keep the data that is already on the drive. Please see the above linked article for more information.
badblocks -b 4096 -p 4 -c 16384 -w -s /dev/sda
What does it all mean?
- -b sets the block size to use. Most drives these days use 4096 byte blocks.
- -p sets the number of passes to use on the drive. When I used the option -p 4 above it means that it will write/read from each block on the drive 4 times looking for errors. If it makes it through 4 passes without finding new errors then it will consider the process done.
- -c sets the number of blocks to test at a time. This can help to speed up the process but will also use more RAM.
- -w turns on write mode. This tells badblocks to do a write test as well.
- -s turns on progress showing. This lets you know how far the program has gotten testing the drive.
- /dev/sda is just the path to the drive I’m scanning. Your path may be different.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).