Operating System - HP-UX
1834299 Members
2572 Online
110066 Solutions
New Discussion

How to check BadBlock on disk

 
SOLVED
Go to solution
C_V
Frequent Advisor

How to check BadBlock on disk

- Hey guys how do you check a disk for bad blocks aside from using fsck.

- Is there a way to determine what files are affected of a bad block.

- How to determine a bad block in a logical volume.
8 REPLIES 8
Jannik
Honored Contributor
Solution

Re: How to check BadBlock on disk

The command to see bad block from lv is (if it is lvol1 in vg01):
lvdisplay -v / dev/vg01/lvol1 |grep -i stale

- Is there a way to determine what files are affected of a bad block.
maybe :-)

I haven't got a system with a failed disk but try this script:

#!/usr/bin/ksh

DIR="/yourdir"

for i in $(find $DIR -type f)
do
echo $i
dd if=$i of=/dev/null
if [ $? -ne 0 ]
then
echo "ERROR in $i" >> /tmp/errors
fi
done

The script will log errors to the file but on the other hand it might hang if it is waiting for a bad block. The you will again be back to the lvdisplay command.

I it is possible the mirror the faulted disk to another and remove the old.
jaton
Bill Hassell
Honored Contributor

Re: How to check BadBlock on disk

> Hey guys how do you check a disk for bad blocks aside from using fsck.

fsck cannot check for any disk defects. It is a directory structure tool and adjusts pointers and tables for consistency. If fsck reads a bad spot on the disk, the read fails with errno 5 (I/O error) and that cannot be fixed by fsck.

> Is there a way to determine what files are affected of a bad block.

Not without extensive knowledge of the VxFS filesystem structures and how to use fsdb.

> How to determine a bad block in a logical volume.

Yes, the dd command bypasses the filesystem and simply reads data. To look at /dev/vg00/lvol3, use this command:

dd if=/dev/vg00/rlvol3 of=/dev/null bs=1024k

This will read 1MB blocks and stop if a read failure occurs. Be sure to use the "r" device file (rlvol3) for faster performance.


Bill Hassell, sysadmin
Suraj K Sankari
Honored Contributor

Re: How to check BadBlock on disk

Hi,

dd is the right command to find out the disk related problem for better knowledge please refer this doc.

Suraj
Asif Sharif
Honored Contributor

Re: How to check BadBlock on disk

Hi Nakihid,

see the doc at...
http://docs.hp.com/en/5991-1236/When_Good_Disks_Go_Bad.pdf

Regards,
Asif Sharif
Regards,
Asif Sharif
Torsten.
Acclaimed Contributor

Re: How to check BadBlock on disk

Please note the new link to the current version of the document:

http://docs.hp.com/en/5991-1236/When_Good_Disks_Go_Bad_WP.pdf

BTW, bad blocks are handled at disk firmware level, no longer at LVM level, see also

man lvchange
(relocate option)

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Ganesan R
Honored Contributor

Re: How to check BadBlock on disk

Hi,

dd is the command to check if any media errors.

If you want to see the files affected by bad blocks you can try with tar.

Try to take the tar image of the filesystem in question. The file which is giving i/o error should be there in affected area of the disk.

Ex:
#tar -cvf /tmp/backup.tar /home
Best wishes,

Ganesh.
Dennis Handly
Acclaimed Contributor

Re: How to check BadBlock on disk

>Ganesan: #tar -cvf /tmp/backup.tar /home

If you are only going to test the reads, you might as well toss the output:
tar -cvf /dev/null /home
C_V
Frequent Advisor

Re: How to check BadBlock on disk

Thanks guys for the Info.