Operating System - HP-UX
1834697 Members
2283 Online
110069 Solutions
New Discussion

Re: Mounting a disk with bad sectors

 
SOLVED
Go to solution
Rainer Becker
New Member

Mounting a disk with bad sectors

Hello,

if have the problem, that i have a disk with one bad sector. fsck does not set the disk state to clean because of this bad sector. But an unchecked disk may not be mounted, even not read only. What's to do, to preserve the data on that disk?

Cheers

Rainer
Nothing in the world can take the place of persistence.
6 REPLIES 6
Animesh Chakraborty
Honored Contributor

Re: Mounting a disk with bad sectors

Hi,
You can try pvmove command.

pvmove -n /dev/vg01/lvol2 /dev/dsk/c1t0d0
/dev/dsk/c2t0d0
See man pages pg pvmove for more details


Best of luck
Animesh
Did you take a backup?
Stefan Farrelly
Honored Contributor
Solution

Re: Mounting a disk with bad sectors


pvmove wont work either, it will fail with an I/O error. Same for dd. Im afraid there is no way to recover the data easily. The only way around a bad block is to mediainit the disk, newfs it and reload your data.

Saying that however, you may be able to recover some of the data. Try a dd if=/dev/vgXX/rlvolYY to a new lvol youve created and see how many blocks copy before the dd errors.
eg.
dd if=/dev/vgXX/rlvolYY of=/dev/vgNEW/rlvolNEW bs=1024k
Lets say dd reports;
I/O error
100+blocks in

So, in this example it copied 100 blocks (x1MB=100MB) before it errored. So if you recreate your new lvol to 100MB and only dd the 100MB before you get the error you may be able to salvage 100MB of data, eg;
dd if=/dev/vgXX/rlvolYY of=/dev/vgNEW/rlvolNEW bs=1024k count=100
Then you should be able to fsck and mount the new lvol. You can then try the same for the blocks after the error. Eg. error at 100MB, your lvol is 200MB, now copy blocks 101-200 (dd if=/dev/vgXX/rlvolYY of=/dev/vgNEW/rlvolNEW2 bs=1024k count=99 skip=101)

Good luck.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Frank Slootweg
Honored Contributor

Re: Mounting a disk with bad sectors

You did not mention your HP-UX release, nor the type of filesystem, but you may want to experiment with all four combinations of the "-r" (read-only) and "-f" (force) options of mount(1M) (with "-F ..."). "-r -f" is best, but perhaps (depending on release and type of filesystem) one or the other works as well.


Wodisch
Honored Contributor

Re: Mounting a disk with bad sectors

Hello Rainer,

you will have to block-copy that file-system's LVOL
to a working, "sane" one of at least the same size,
to be able to do the "fsck" there.
"dd" usually breaks upon the first bad block, but you
can tell it to continue starting one block "later" on
source and on target LVOLs:

dd if=/dev/vgXX/lvBAD of=/dev/vgYY/lvGOOD skip=xxx seek=xxx bs=1k # bs=1k for JFS,bs=8k for HFS

where "xxx" would be "0" on the first attempt, then,
after aborting, "xxx" has to be ONE BIGGER than the
number where it stopped!

HTH,
Wodisch
Bill Hassell
Honored Contributor

Re: Mounting a disk with bad sectors

Be careful with the rest of your server because using the -f option to force a mount cal easily cause a system panic. The bad sector may be in an unused area, part of a directory or maybe a super block.

The bad spot is going to cause a lot of problems and getting the data off successfully may require a professional service like OnTrack. Be prepared to weigh the value of your data (sounds like it was never backed up) versus the cost of a data recovery service. The cost could be as much as an entire computer.


Bill Hassell, sysadmin
Rainer Becker
New Member

Re: Mounting a disk with bad sectors

Thanks you for your answers. The OS version is 10.20 and the file system type is HFS. The -f option of the mount command didn't work. But I had success with dd, mentioned by Stefan Farrelly and Wodisch. But it was a hard work. Thanks for your help.

Under Solaris you can use the format command to mark disk sectors as bad. Afterwards you must use fsck to bring the filesystem in clean state. Is there anything similar for HP-UX?

Rainer
Nothing in the world can take the place of persistence.