I've spent ages installing my current Centos dedicated server (OVH, Kimsufi). I want to move it to another server which will have different hardware although OS will remain the same.

My question is: is there an easy way of copying entire system as it is to a new server without messing up it's existing hardware settings? Cloning entire disk is out of question, because new server will have different hardware (disk size will remain the same though).

Is it possible just to copy certain folders then? like /etc, /home, /usr, /var where all installed and configured stuff resides, or will that still break the new server? I haven't created any custom root folders.

  • 3
    Why is cloning the disk "out of the question?" Linux is not like Windows, it doesn't care what hardware it's running on. You may have to clean up a few things such as udev, et al., but it is definitely cleaner than copying a bunch of disparate configuration files and crossing your fingers. – Soviero Mar 23 '13 at 17:19

For Redhat derived systems (including CentOS), your hardware configuration is going to be mostly in /etc/modprobe.conf, /etc/sysconfig/hwconf, your initial ramdisk image (/boot/initrd-[kernel-version].img), and /etc/udev directory (this is where persistent device names are stored).

However, you may also want to record a list of your system tweaks. To help with this, you can use the RPM database to give you a list of configuration files that you have modified (it stores the MD5 sum of the original installed configuration files for any package, and you can compare this to the existing files in your filesystem to generate a list of what you had modified). Also, make a list of anything that exists in the filesystem that is not in the RPM database. Finally, make a list of all packages that were installed, possibly splitting this into two lists -- OS provided packages, and third party packages. This should give you a collection of minimum files that you need to put into your disaster recovery documentation, along with helping you clone your server when needed.


How would you recover this from a backup if your hardware died? You should at least know where your configuration files are, and one route in your situation might be working that out. (The fact that you value your tweaking implies that these won't all be in the default locations)

Alternatively this is a good example of how virtualisation is extremely beneficial. If you use something like vmware converter you can make a VM of your server that you can copy or move onto any hardware.


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:

  1. Make sure your existing system is fully up-to-date (yum update).
  2. 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.
  3. Quiesce the existing system (ie, boot to single-user, and bring up the network).
  4. 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.
  5. For each partition on the old/new system pair: dumpe2fs 0f - /partition | ssh root@newbox "cd /partition; restore2fs rf - ."
  6. Run grub{,2}-install /dev/sda or as appropriate, on the new system.
  7. 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.
  8. Reboot the new system (the network will not come up).
  9. 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.
  10. 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?


Take a look at kickstart, the automated installation system for RHEL/CentOS (and also Fedora). It lists packages to install (can get those by yum list installed, probably will need a bit of massaging) and other configuration, and can add local configuration in a script section. Perhaps it won't help much right now, but keeping a kickstart file up to date will save much work next installation (or when you need to clone an installation).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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