Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CENTOS server running and i want to make identical copy of it(all software,users), like twin server for mirroring purposes. how do i do that?

share|improve this question
up vote 5 down vote accepted

While dd will copy one mounted drive to another, the copy will be inconsistent. The filesystem is constantly changing, and if you are using a journaled filesystem, even more so. Using dd works best when the drive is static, i.e. read-only. Most of the time, this isn't an option, but if you do have it read-only, this will work fine.

There are other tools to perform this cloning function. But the easiest is to simply use LVM's mirror functionality. The caveat is that you will need to have the existing filesystem on LVM already. Using an LVM mirror, you can make hot copies of the filesystem, and when you break the mirror to obtain your second drive, the filesystem image will be in a consistent state, because all the recorded changes will be sent consistently. It requires little work other than starting the mirror process and stopping it once the original has replicated completely.

If for some reason you don't want to use the mirror function, you can always create a snapshot of the filesystem and replicate the read-only snapshot to another drive. While this is not as automatic as mirroring, and it is a bit messy (extra steps), it can be made to work just fine.

Last, you can always try to rsync your way into this. This sounds like a strange way to do it, but I've used this to successfully replicate a server 400 miles away to a local drive. The catch was that I had to make a manual change to the /etc/fstab file (the paritions were different) but otherwise it boots fine.

That leaves a single sore point: making the drive bootable. Using dd will copy the boot loader over (as it is a block-by-block copy) but if you use the LVM or rsync methods, you'll need to re-install the bootloader. Fortunately, this isn't too hard and can be easily done to drives other than the current (original?) root filesystmem.

share|improve this answer

I think 'dd' will do what you are looking for -- check out the below articles.

Linux Backup: Hard Disk Clone with "dd"

dd: the ultimate disk cloning tool

Wikipedia: dd


If what you're looking for is more of a system template, where multiple systems are setup and configured the same way, instead of an exact copy then Cobbler may be what you are looking for:

Cobbler is a Linux installation server that allows for rapid setup of network installation environments. It glues together and automates many associated Linux tasks so you do not have to hop between lots of various commands and applications when rolling out new systems, and, in some cases, changing existing ones.

share|improve this answer
Remember - dd is a bit level copy tool. If you want to go that route, you need to shut the server down, boot from a live cd and then make the dd image. Otherwise the image will be useless. – Michael Kohne Aug 20 '09 at 19:05

I read about Hotcopy in Linux format a few issues back. Should do the trick.

share|improve this answer
That sounds cool... – Kyle Brandt Jul 27 '09 at 19:31

To build a server as was from the original install you can use the anaconda provided kickstart file in /root/anaconda-ks.cfg, you'll need to edit it for the partitioning and probably the networking/hostname.

This will give you a good reproducible baseline server config, and makes it easy to rapidly build machines. See the CentOS Installation Guide for more details. I can't advocate enough how automating your build process is a great practice.

For software/configuration you want done on top of that, you can use the %packages section and the %post scripts in kickstart but I personally use a configuration management tool - for me this is principally puppet. This allows you to alter things across the life of a machine and will ensure those changes are made to a system are preserved (most usually in source control). Even if you only have a few servers this can help hugely in a DR scenario as you ensure all changes are captured in configuration.

To get started puppet provides a tool called ralsh that can take the resources of a system (such as users or packages) and spit out snippets of the puppet language that can be used to build a replica of the system.

Moving to configuration management can be a big step and involves changing the way that you work. For a direct clone you might also take look at SystemImager

share|improve this answer
+1 cos we all love the puppet :) – David Pashley Jul 27 '09 at 20:13

More details would help...

If this is a production, public facing system, I would recommend doing a fresh install, and figuring out how to clone it manually. The reasoning is that you will know how your system works, and can probably design better fail over once you have that knowledge. For instance, if this is a web app with a database back end, having two installations won't really give you a good mirror, you will want to look into various database replication.

The other main options I am aware of are:

  1. Image the partition using something like dd
  2. Do a fresh CentOS install, and just rsync the old install over the new one with the -a option. This actually works pretty well, you will want to exclude the /proc directory and maybe a couple others
share|improve this answer

dd will copy the hard-drive directly to create an identical version. However, you would need to setup a regular to job to do that, and have ther drives cross-mounted, or physically move them.

share|improve this answer

Others have taken care of most of the solutions, but there is one more that covers the cloning part. For a one-time copy, I would suggest using Clonezilla. ( It's like Norton Ghost, but free. As long as the destination drive is at least as big as the source (I don't believe you can clone to a smaller disk), it can do all the cloning for you. You would have to login after booting to change the IP/hostname and some other things if you intend to have both systems running in parallel.

share|improve this answer

You might want to look at a solution integrating DRBD and Pacemaker; DRBD acts kind of like a network-level RAID-1 configuration. From there you can have two servers with identical data partitions, then when/if one system fails pacemaker will fence off the old system and the other server picks up the slack.

This depends on whether you're looking for high availability or load balancing, too...DRBD and Pacemaker is meant for availability, but recent versions added a "primary-primary" configuration so it can work with load balancing as well, but it depends on how you architect the application. You can also find examples on the web for using Xen to create a virtual machine that is balanced on two systems with DRBD and that may give you what you're looking for.

share|improve this answer

Read about LVM and snapshots here. I think that this is what you need.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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