Does anybody know of a way to clone a live linux system? I have a live installation running a production site. Problem is, I'm needing to clone it (without bring it down), and then move it over (restore) to a virtual machine. I'm basically migrating from physical hardware to virtual hardware.

  • You're going to have to bring it down regardless, to start it on the VM. – Ignacio Vazquez-Abrams Jan 21 '11 at 17:46
  • Physical hardware will be up -> cloning happens -> migrate to VM -> change address of URL -> done. I need specifics of best practice for cloning live systems. – drewrockshard Jan 21 '11 at 17:49
  • 4
    The first step is to try to determine what operating system it's running. – Paused until further notice. Mar 8 '11 at 11:11

On the source machine:

dump -0 -f - / | ssh -c blowfish root@target_machine "cd /; restore -rf -"

This will dump the fs on your source machine, copy it over ssh and on the target machine it will restore it.

Of course you need to repeat this for every fs.

'blowfish' is there just to make it for faster compression and decompression.

| improve this answer | |
  • This one seemed to work the most efficient. – drewrockshard Jan 25 '11 at 16:35
  • i can not get it to like the lower case r. i had part of this working by separating -rf to -r -f, but now restore: invalid option -- 'r' cat: invalid option -- 'r' – rjt Mar 13 '15 at 18:22
  • 5
    Is this answer still valid? What would happen if you were to have a running MySQL service on the box? – MirroredFate Jun 26 '15 at 21:13

VMWare Converter can do most modern OS's without shutting the server down, but as Dennis pointed out, we really need to know which OS you're running.

You'll end up with a virtual image of your server when you're done, rather than a raw disk image, but it's usually good enough for most work, depending on what you want to do with it once you've done it.

| improve this answer | |
  • It's running on Fedora. FYI, I'm planning to image it for virtualization later, probably in Xen. – Str Mar 8 '11 at 11:30
  • For virtualization purpose, if I'm not mistaken the image have to be in virtual image rather than raw disk image, right? – Str Mar 8 '11 at 11:31
  • 1
    @Str, if you know what the OS is please edit your question to say so and use appropriate tags. – John Gardeniers Mar 8 '11 at 11:44
  • @Str - that's correct, however you didn't mention if you were going to be virtualising the machine or not, just that you wanted to clone it. – Mark Henderson Mar 8 '11 at 20:32

Which VM platform are you migrating to? VMWare has a converter for Linux. It'll convert a powered on machine.

| improve this answer | |
  • In the end, it's in house, and VMWare based. The control panel is custom, so we'd basically be loading a live CD, and expanding/extracting/etc onto the VM. I'm not sure I can get access to the VM infrastructure to do the VMWare converter, but that all depends what is involved with this. To test however, I was going to try to migrate it over to a virtualbox vm just to see if this proof of concept worked at all. – drewrockshard Jan 21 '11 at 17:52
  • Do you think I could run the convertor on the physical machine and then "import" the converted vm into vmware (never used the convertor, so my terminology might be off). – drewrockshard Jan 21 '11 at 17:53
  • The converter doesn't really work that way. Check out this link. It should show you the basics of how a conversion works vladan.fr/how-to-p2v-linux-into-vmware-esx-server – Jason Berg Jan 21 '11 at 18:21
  • Is there a way to bypass the vmware infrastucture import so that I can keep the "converted" image locally on my system, or do I have to migrate to another infrastructure (no local ability)? – drewrockshard Jan 21 '11 at 18:59
  • Note that the VMWare Converter (currently) requires Windows, though it can migrate a Linux physical computer to a virtual machine. – Greg Glockner Jun 22 '16 at 19:42

Have a look at VMWare converter which I believe allows live system cloning.

| improve this answer | |

We generally do this:

  • Boot the target virtual host off a cd (or netboot it)
  • Prepare the filesystems on the virtual host (that is, prepare the disk(s), create the fileystems, and mount them).
  • Rsync the files from the physical host to the virtual host
  • Install the boot loader on the target host

This works great, as long as the data you're copying over is relatively stateless. If you're dealing, for example, with a database server, particularly one with a lot of activity, you will need to make sure that database is quiescent before you make the final cutover...so, something like this, after everything else is ready:

  • Stop the database
  • Perform a final rsync of the data
  • Shut down the physical host
  • Start up the virtual host
| improve this answer | |
  • 1
    What rsync command do you guys use? – drewrockshard Jan 21 '11 at 18:57

Look at VMware Converter (it's free if you have vCenter) or Plate Spin (one of their products is a converter).

Plate Spin will do a machine live, with minimal downtime to cut over.

With VMware converter, it'll do a live machine (if there's a database it might be out of sync) just don't have it boot the VM when it is finished. Then disconnect the vNIC and then boot the machine, log in via the console and change the IPs, etc. Then reconnect the vNIC.

| improve this answer | |

Its impossible to get a consistent snapshot without stopping all operations which may change the state of the system.

Unless the application has been explicitly designed to accomodate this kind of operation (i.e. all processing handled via queueable messages) it is be impossible to get a consistent snapshot without bringing the system down (or at least disabling the transactional component).

However it is possible to reduce the time window for snap-shotting the system significantly (e.g. by removing a mirror from a RAID set then remounting it elsewhere). And the shorter the time it takes to generate the snapshot, the less likely that transactions will span the operation.

And most filesystems / DBS will support some sort of journalling which should allow most broken operations to be either recovered or rolled back.

| improve this answer | |

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.