Migrating whole LINUX harddrive (including OS)

Posted on

Migrating whole LINUX harddrive (including OS) – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, hard-drive, , , .

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!

Solution :

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


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.

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 ;).

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *