For a simple disc layout, there's nothing wrong with using dd
to clone the hard drive, as Kevin and others have recommended. But if your partition layout is more complex, this may help.
Having done this recently, and with a CentOS system at that, I find the best way is to install a skeleton system on the new hardware, boot the new hardware off RO media, dump the old system and restore it on the new system (on top of the skeleton install), tweak a few hardware-specific settings on the restored system, and that's it.
In more detail:
- Make sure your existing system is fully up-to-date (
yum update
).
- Install a minimal CentOS installation of the same version and architecture on the new hardware. You will need to keep the same number of partitions on the same mount points, though they can be different sizes, on different devices, etc.
- Quiesce the existing system (ie, boot to single-user, and bring up the network).
- Boot the new system off rescue media (install media, in rescue mode), and have the recently-installed partitions mounted. Give it a temporary address on the network. Ensure that root can
ssh
in.
- For each partition on the old/new system pair:
dumpe2fs 0f - /partition | ssh root@newbox "cd /partition; restore2fs rf - ."
- Run
grub{,2}-install /dev/sda
or as appropriate, on the new system.
- Delete
/etc/udev/rules.d/70-persistent-net.rules
on the new system. Ensure that the contents of /etc/fstab
on the new system are consistent with the new hardware.
- Reboot the new system (the network will not come up).
- Log into the new system, look at the NICs that have appeared, and ensure the contents of
/etc/sysconfig/network-scripts/ifcfg-*
are consistent with the interface names and MAC addresses on the new hardware.
- Reboot. Fix all the remaining problems. Have a well-deserved BEvERage.
That's it, in a nutshell. If X
was running on the old hardware you will likely have to fix that as well, but why would you run X
on a server?