Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Right now we have a HD failure (bad sectors). Only certain files are affected. Our DC is giving us 72 hours to migrate the the content from the primary harddisk to a secondary harddisk.

The problem is that the primary HD has not just a lot of data, but custom softwares, configs etc that we would hate to redo again.

Would it be possible to just mirror the HD content and fix the corrupted data from the primary HD to the secondary HD? Would everything work fine? What is the best way to do this?

Looking for advice, thank you!

share|improve this question
add comment

4 Answers

If the drive is failing already (read errors) then dd is not enough.
You should use ddrescue (the gnu version).

eg

ddrescue -n  /dev/failing /dev/replacement /path/to/logfile
ddrescue -r3 /dev/failing /dev/replacement /path/to/logfile

The first pass skips ahead on read errors, the second tries hard to fill in the gaps. The logfile is very important !

If you can't turn the machine off then try a hard drive usb adapter. It's not the writes that will be slow, but reading the damaged sectors.

share|improve this answer
add comment

Yes, it's possible to "mirror" the HD to a new disk, and there's a number of ways to do it. As far as "the best way" to do it - well, that's subject to ones environment, your level of experience, etc.

If you are looking for tools that can help, look at the GParted Live disk. Then there's Ghost 4 Linux, etc.

If your data isn't being actively accessed, you can also simply copy (cp -pr ..., rsync, etc) the data from the failing HD to the new HD, you just have to omit things like {dev, lost+found, sys, proc, ...} depending on your distro and the like. Once the copy has completed, you have to re-run Grub (or lilo) and add it back to your master boot record et al. Obviously there's a bit more to the manual route... but it's not as bad as one might think.

In our environment, I've even created a live cd that pulls down archived data from TSM (Tivoli Storage Manager) that can be used to effectively do "bare metal restores".

You really have a number of options. It ultimately boils down to your level of comfort and the function of the box in question. Have a peek at GParted live, for certain. It has a number of features that make these kinds of things cake; like copying and pasting partitions ;).

share|improve this answer
add comment

if you have access to the machine, plug another blank hard drive in it, and run:

dd if=/dev/<crashing harddrive> of=/dev/<blank harddrive>

that going to clone the crashing hardrive to the blank one block by block. you can then reuse the new harddrive as your primary and fixe the files that might be corrupted.

If I understand your questions properly, secondary harddrive would be the blank harddrive (make sure it's empty before your start the cloning, it's a block by block copy so it won't care if anything already exist on the target).

Grandma tip: when hard drive is crashing and throwing errors, put it in the freezer (yes, freezer) for two hours then retry the cloning process.

share|improve this answer
1  
I would suggest using ddrescue instead of plain dd for this purpose. –  Teddy Sep 6 '10 at 16:48
add comment

Just an additional hint. If your failing HDD has faulty sectors, you may end up with a few scenarios:

  1. Any copying of data may hang at the faulty sectors.
  2. If the copy process doesn't hang, you may (probably will) get faulty data on the new HDD.
  3. If the bad sectors are really bad (e.g. partitioning table affected) you may get a whole load of nonsense on the target drive (happened to me after a RAID controller error).

Be prepared for quite a bit of repair work after the copying is done.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.