pantz.org banner
Check your disks with badblocks
Posted on 09-17-2005 02:35:00 UTC | Updated on 09-17-2005 02:35:00 UTC
Section: /software/badblocks/ | Permanent Link

A friend mentioned that taking the word of the hard drive manufacturers test software may not be such a hot idea. After testing 2 hard drives with Maxtors Maxblast software they gave both drives a clean bill of health. But after using the badblocks program (part of the ext2progs package) it found one drive was indeed ok but the other one did have bad blocks on it. Do a check using both the manufacturers software and (if that passes) badblocks. You can do as many hd's as you want at a time. I would suggest just popping in a knoppix cd and testing. Some examples and explanation of the commands are below.

Badblocks is used to search for bad blocks on a device (usually a disk partition).

You NEVER want to use all of the ram in the system. If you do, kswapd will try to free up memory in real time and use 90% of the cpu. To make sure you don't starve the system of resources use the following calculation:

    TotalRamMB * 3
   -----------------   =  Maximum "-c" value
         32

So, if you have 1gig of ram (1024 MB)...

     1024*3
    -------  = 96 MB
       32

... you can use a 96MB count size. 

Using 96MB count will use a total of 768MBof ram. This is less than the total amount of ram we have in the machine, but you want to give the rest of the system adiquate memory else your test will run out of ram. Running out of ram will either crash the machine, crash the badblocks test or increase your test time by a factor of 10. Not good.

Since the "-b" is a 4K block and "-c" is going to be 96MB the values must be multiplied by 1024 for the badblocks command line.

Destructive test (one test drive with 1Gig ram) *Best Test*

badblocks -b 4096 -c 98304 -w -s /dev/hda1

NON-Destructive test (one test drive with 1Gig ram)

badblocks -b 4096 -c 98304 -s /dev/hda1

Also, if you want to test 2 drives in parallel you need to divide the max "-c" number by 2.

     1024*3
    -------  = 48 MB
       64

I would suggest putting each drive on its own ide controller because this will speed up the testing a bit and reduce the load significantly. By putting each dive on its own chain you will not loose both drives if one drive dies in the middle of the test. You also need to make sure to keep the output of the tests segregated to make sure you know which drive tested with/without errors. Pipe the output to a log file is the easiest way.

Destructive test (Two test drives with 1Gig ram) *Best Test*

badblocks -b 4096 -c 49152 -w -s /dev/hda1 >> loghda1 &
badblocks -b 4096 -c 49152 -w -s /dev/hdc1 >> loghdc1 &

NON-Destructive test (two test drives with 1Gig ram)

badblocks -b 4096 -c 49152 -s /dev/hda1 >> loghda1 >> loghda1 &
badblocks -b 4096 -c 49152 -s /dev/hdc1 >> loghdc1 >> loghdc1 &

Lastly, test time. This greatly depends on the speed of your system and on the speeds for the drive and how many drives you are testing. Note that drives from the same manufacturer and with the same size do not have the same amount of blocks. We are testing blocks here. So a 250G drive with 40 million blocks will take less time to test than a 250G drive with 60 million blocks.

My times are:

P4 3.0GHz with PATA 133 250G 1 Drive == 8 hours with a load of ~1 P4 3.0GHz with PATA 133 250G 2 Drives == 14 hours with a load of ~2.2

OS and Software. Use a bootable cdrom distribution like SystemRescue CD or Knoppix. Most distributions will have "badblocks" on it.

1. Boot the cd distro.
2. Verify the hardrives are found.
3. Use fdisk or parted to make a partition on each drive to be tested. One
   large partition on each disk is the best for the destructive test.
4. Run the badblocks line of your choice.
5. Look at the output. If you just see line with testing and reading on it
   with done at the end then the drive is fine. If you see any numbers in the
   output, then those numbers are the address of the bad blocks. If you have bad
   blocks you can have the file system mark them depending on the filesystem you
   are using. RTFM for that info.

Reddit!

Related stories


RSS Feed RSS feed logo

About


3com

3ware

alsa

alsactl

alsamixer

amd

android

apache

areca

arm

ati

auditd

awk

badblocks

bash

bind

bios

bonnie

cable

carp

cat5

cdrom

cellphone

centos

chart

chrome

chromebook

cifs

cisco

cloudera

comcast

commands

comodo

compiz-fusion

corsair

cpufreq

cpufrequtils

cpuspeed

cron

crontab

crossover

cu

cups

cvs

database

dbus

dd

dd_rescue

ddclient

debian

decimal

dhclient

dhcp

diagnostic

diskexplorer

disks

dkim

dns

dos

dovecot

drac

dsniff

dvdauthor

e-mail

echo

editor

emerald

encryption

ethernet

expect

ext3

ext4

fat32

fedora

fetchmail

fiber

filesystems

firefox

firewall

flac

flexlm

floppy

flowtools

fonts

format

freebsd

ftp

gdm

gmail

gnome

google

gpg

greasemonkey

greylisting

growisofs

grub

hacking

hadoop

harddrive

hba

hex

hfsc

html

html5

http

https

hulu

idl

ie

ilo

intel

ios

iperf

ipmi

iptables

ipv6

irix

javascript

kde

kernel

kickstart

kmail

kprinter

krecord

kubuntu

kvm

lame

ldap

linux

logfile

lp

lpq

lpr

maradns

matlab

memory

mencoder

mhdd

mkinitrd

mkisofs

moinmoin

motherboard

mouse

movemail

mplayer

multitail

mutt

myodbc

mysql

mythtv

nagios

nameserver

netflix

netflow

nginx

nic

ntfs

ntp

nvidia

odbc

openbsd

openntpd

openoffice

openssh

openssl

openvpn

opteron

parted

partimage

patch

perl

pf

pfflowd

pfsync

photorec

php

pop3

pop3s

ports

postfix

power

procmail

proftpd

proxy

pulseaudio

putty

pxe

python

qemu

r-studio

raid

recovery

redhat

router

rpc

rsync

ruby

saltstack

samba

schedule

screen

scsi

seagate

seatools

sed

sendmail

sgi

shell

siw

smtp

snort

solaris

soundcard

sox

spam

spamd

spf

spotify

sql

sqlite

squid

srs

ssh

ssh.com

ssl

su

subnet

subversion

sudo

sun

supermicro

switches

symbols

syslinux

syslog

systemd

systemrescuecd

t1

tcpip

tcpwrappers

telnet

terminal

testdisk

tftp

thttpd

thunderbird

timezone

ting

tls

tools

tr

trac

tuning

tunnel

ubuntu

unbound

vi

vpn

wget

wiki

windows

windowsxp

wireless

wpa_supplicant

x

xauth

xfree86

xfs

xinearama

xmms

youtube

zdump

zeromq

zic

zlib