JP Vossen on 19 Oct 2007 19:40:36 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] How best to replace old drive with new drive


Date: Fri, 19 Oct 2007 12:36:34 -0400
From: Mike Leone <turgon@mike-leone.com>
Subject: [PLUG] How best to replace old drive with new drive

So I've got a mail server that has an old HD. And I wanna replace it with a
larger one, which I happen to have lying about. I know there's any number of
ways to clone the HD (me, I like Ghost, but I also have DriveImageXML, and I
suppose I could even do a dd). Anyways, if I were to Ghost to the new drive,
what would I need to do to make grub run on it? I seem to remember doing
this before, and getting a new drive with larger partitions, but grub
wouldn't run.

A pointer or clue, anyone? Something about booting a Knoppix LiveCD, and
running "grub-install", I believe?

"Simple" answer: ---------------- 1) Install the new hard drive in the old machine 2) Boot a LiveCD or into recovery or single user mode 3) partition and format the new drive, then mount it + 4) rsync the data over * 5) chroot into the new drive's root 6) Recreate dirs as needed: mkdir /dev /proc /tmp 7) run "grub-install" 8) Remove old drive and boot into new one

+ MAKE SURE YOU USE THE RIGHT DRIVE! It you have any question, disconnect the good/old drive and install only the new one until you get this right.

When I do this, and when I'm using multiple partitions, I'll do something like tis. It's a bit more work but it duplicates the final disk's structure, facilitating a later chroot for grub install.
cd /mnt
mkdir new
mount -t ext3 /dev/sda2 /mnt/new
mkdir new/boot
mkdir new/home
mount -t ext3 /dev/sda1 /mnt/new/boot
mount -t ext3 /dev/sda5 /mnt/new/home


* SAMPLE rsync command, tweak and test as needed:
	rsync -v -a --numeric-ids \
	  --exclude /mnt \
	  --exclude /var/cache/yum/base/headers/* \
	  --exclude /proc \
	  --exclude /dev \
	  --exclude /tmp \
	  --exclude other_stuff_as_needed \
	  /. /mnt/new

Since you are duplicating a disk, --numeric-ids isn't really necessary since the passwd files will end up the same. I only use it out of habit.

Depending on your distro, you might not want to skip /dev. Anything using udev should re-created whatever is needed in /dev at boot (someone correct me if I'm wrong). Anything older *not* using udev won't; in that case copy /dev too.



More complicated, multi-machine answer:
---------------------------------------
This is how I've done machine to (virtual) machine disk copies:
	http://communities.vmware.com/thread/22724#281540
	http://communities.vmware.com/thread/22724#281765

You'll see that these instructions are about copying disks into VMware, and that I started out overly complicated (I do that a lot). The process "devzero" outlined in #281540 worked for me, with trivial additions I noted in #281765.

While I have enlarged ext3 partitions in the past, that makes me nervous (yeah, I'm paranoid too). While my processes have more steps than some suggested, I consider it less risky (I'm conservative too). In your case, you obviously omit the VMware parts and just do the disk-to-disk parts.

Hope this is useful,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP            |:::======|        jp{at}jpsdomain{dot}org
My Account, My Opinions     |=========|      http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
Microsoft has single-handedly nullified Moore's Law.
Innate design flaws of Windows make a personal firewall, anti-virus
and anti-malware software mandatory. The resulting software arms race
has effectively flattened Moore's Law on hardware running Windows.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug