Apr 16, 2011

How to check for bad blocks on a mac with Mac OS X?


In the olden days you could always check a hard drive for bad blocks using the built in tools, but no more since the dawn of Mac OS X, which is about a decade ago. Anyways, a good article here on bad blocks and a Terminal Tool that will actually allow the process of checking a disk gone haywire.

Link to article on bad blocks

Here's the gist of the article
The badblocks command will be installed in /usr/local/sbin/badblocks, and it will probably not be on your PATH, so you have to type the entire path when using, or edit your PATH environment variable.

Usage is simple. First, run the “mount” command, so that you know the device names for the drives you want to test. You can obtain something like this:

arroz% mount
/dev/disk0s3 on / (local, journaled)
devfs on /dev (local)
fdesc on /dev (union)
on /.vol
automount -nsl [142] on /Network (automounted)
automount -fstab [168] on /automount/Servers (automounted)
automount -static [168] on /automount/static (automounted)

The internal hard drive is /dev/disk0 (note that /dev/disk0 is the entire drive, /dev/disk0s3 is a single partition). Imagining you want to test the internal hard drive you would type the command (as root):

badblocks -v /dev/disk0



Here's the link to the tool: Download BadBlock Terminal Tool
And my personal mirror of it: Mirror of BadBlock Terminal Tool

Some things I noted was that it couldn't run a check on a disk mounted, so I unmounted the drive, and had to run the command in sudo. But other that it's a great little tool.