Freebsd – How to rebuild gmirror from bad hard drive

freebsdhard drive

On my freebsd box

$uname -rms
FreeBSD 7.2-RELEASE-p5 i386

hard disk want to die.
smartd daemon write in log:

Mar 29 21:25:04  smartd[935]: Device: /dev/ad7, 10 Currently unreadable (pending) sectors                     
Mar 29 21:25:04  smartd[935]: Device: /dev/ad7, 10 Offline uncorrectable sectors       

I insert new disk (ad5), and have this plan:

  1. create gmirror raid
  2. insert ad5 into raid
  3. after sync remove ad7 from raid
  4. disconect ad7 disk.

But looks like sync never will be done.
I always see:

mirror/gm1  DEGRADED  ad5s1e (79%)
                      ad7s1e

I tryed deactivate/activate ad5s1e. I tryed gmirror rebuild gm1 ad5s1e .
I was rebooted into single mode.
79% is always barrier.

How to finish this sync?

upd:

One more try to rebuild, and i see this in log:

Mar 30 01:33:03  kernel: ad7: FAILURE - READ_DMA48 status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=372929727
Mar 30 01:33:03  kernel: GEOM_MIRROR: Synchronization request failed (error=5). mirror/gm1[READ(offset=177321017344, length=131072)]
Mar 30 01:33:11  kernel: ad7: FAILURE - READ_DMA48 status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=372948031
Mar 30 01:33:11  kernel: GEOM_MIRROR: Synchronization request failed (error=5). mirror/gm1[READ(offset=177330454528, length=131072)]

after this 79% and frozen again.

Best Answer

You can't build a mirror from broken disk. Some sectors on it are unrecoverable. But not everything is lost by now. You can try to dump/restore your filesystems. If you're lucky, FS don't use bad sectors, or data on them is not significant. Refer to the FreeBSD FAQ that describe how to move fs from disk to disk: FreeBSD FAQ q.9.2