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

Re: What is the best way to migrate a server to new hardware?



Aniruddha wrote:
> Bob Proulx wrote:
> > I like booting the new machine with a live cdrom and then using rsync
> > to clone the old system onto the new system's disk over the network.
> > Then install grub and boot the new system.
> 
> > At other times I will move the new disks onto the old system, mount
> > them and do the copy locally, then move them back into the new machine
> > and boot it.
> 
> Thank you for you help. Which rsync command do you use? And how you
> restore grub? With the live cd? Or manually with a random livecd?
> Which command do you use to copy them them locally? I'm curious how
> other users solve this :)

I should have mentioned it but the only interesting rsync option that
is needed is --numeric-ids.  That uses the owner and group ids
verbatim without the default name mapping to the uids of the currently
running system.  Using --numeric-ids is normal for backup and verbatim
data transfer such as this.

  rsync -av --numberic-ids --exclude /proc --exclude /dev oldhost:/ /target/

Normally I would explicitly copy any individual filesystem such as
/home or /usr/local individually.  The -x, --one-file-system option
may be useful in the multiple partition case copying from a live
filesystem.

/dev is a little problematic.  What you want there is a raw version
but the running system has a cooked version.  I will usually copy that
from a debootstrap'd /dev that is idle.  I will leave this as a little
bit of an exercise for the reader.

Copying from a local disk to a local disk is the same but then since
the local disk is idle there isn't anything in the proc and dev is the
idle dev and so this is simpler.

  rsync -av --numberic-ids /mnt/olddisk/ /mnt/newdisk/

Again, individual filesystems on individual partitions would need to
be created and copied individually.

  rsync -av --numberic-ids /mnt/olddisk/var /mnt/newdisk/
  rsync -av --numberic-ids /mnt/olddisk/home /mnt/newdisk/
  rsync -av --numberic-ids /mnt/olddisk/usr/local /mnt/newdisk/
  ... and so forth ...

There is much other documentation on restoring grub so I won't go into
detail there.  I boot a live cd and then chroot into the system and
run grub-install there to install grub onto the MBR.

I also make good use of a live cd that uses grub itself.  Then I can
interactively tell grub booting from the cdrom to boot the new system.
This way the new system is booted exactly as it will once grub is
installed on the new disks.  Then I run grub-install on the newly
booted system to set up the MBR and reboot to test it.  However most
live cdroms use syslinux instead and so locating a grub booting cdrom
boot system can be challenging.  You may end up resorting to building
your own grub based cdrom system instead.  In my case for this
scenario I don't care about what is actually on the disk.  I just want
to get to an interactive grub session so that I can interactively boot
the new system.

Sorry that the information here is a little "fuzzy".

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: