Cloning a Physical Linux PC that uses LVM

I know this isn’t virtualization related, but a colleague of mine was attempting to clone 20 HP x4600 desktops running RedHat Enterprise Linux 5 and was having a heck of a time.  Using Ghost or Altiris would image the disk but during boot it would get a kernel panic. Reason being, the LVM wasn’t being copied properly with these tools.  After doing some quick research I recommended using Clonezilla, an open source tool that has support for a number of different partition types, including most Linux, Windows, Mac and LVM2.

There are two options for Clonezilla, a Live edition which boots via CD (or local install) and allows a disk to disk copy or even partition to partition copy.  The other edition is SE, which includes a DRBL server and allows multicasting of the cloning – basically allowing you to image multiple desktops at the same time from a single source.

As I type this, I’m thinking of a cool use for this product. Because ESX guests support PXE, you can connect to a DRBL server and do a quick and easy P2V of your Linux based machines.  Perhaps I should test this on my own! (Maybe P2V a Mac to ESX?)

Created on January 21, 2009 by Rick Scherer

Posted under Good Reading.

This blog has 24,684 views.

Tags: , , , , ,

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

5 Comments so far

  1. Maish
    3:21 am on January 22nd, 2009

    I had the same issue by the way. I wanted to convert a Xen 3.2 Guest configured with 2 disks running RHEL 4 and with an LVM. What would happen was that the first disk would be migrated over, but it would not recognize the second one at all. I was using Converter 4.0 to do it. When rebooting the machine it would konk out because it could not find the 2nd disk. what I did was to remove the mount of the second disk in /etc/fstab. Got into the OS.
    Added a second disk to the vm and then dd’d the disk over. Was planning to put up a post on it.

  2. Maish
    1:19 pm on January 29th, 2009

    I have added a post and how-to on cloning a Linux VM with LVM

  3. Henno
    2:24 am on August 31st, 2009

    I needed to clone physical live (running) RHEL5 server into VMware ESX environment. Spent 2 weeks and developed a very cool solution. The beauty is that you don’t have to reboot running server and the server can be running on the other side of the Internet (you do need root access to the source server, of course.)

    It basically boils down to this:
    1) You install minimal linux on your target
    2) You tar the entire source server’s filesystem to the pipe (ssh tunnel) and on the other end you unpack it on the fly.
    3) To make things easier I use a intermediate virtual machine to touch things up before overwriting files on the target.

    1) Make a temporary virtual machine that has enough space to contain all the files of the source machine. Must be running linux (any kind). Make a /tmp/source directory (or any other place where you have plenty of space)

    2) SSH to the source server and make an exclusion file to list directories that we dont want to copy over: vi /tmp/nocopy. You’d put proc, dev and sys into that file, perhaps some other directory as well that you don’t want to include (e.g. backups). Now:
    cd /
    tar cvpf – -X /tmp/nocopy –numeric-owner * | ssh -C tempserver “cd /tmp/source; tar xvpf – –numeric-owner”

    3) Look at the size of /tmp/source and decide how big virtual hard drives you want.

    4) Create your virtual machine. Install THE SAME Linux distribution and the same version as your live server is. Very minimal install is the best but ssh server and tar must be installed. Leave the console logged in if you want to reset your password.

    5) Now go to your temp linux. Move the following files and folders out of the /tmp/source directory:
    You might want to check etc/aliases and change root email aadress, if required.

    6) Now issue the following commands:
    cd /tmp/source
    tar cvpf – –numeric-owner *| ssh -C target “cd /; tar xvpf – –numeric-owner”

    7) On your console. Type passwd if you want to reset the password.
    * There could be typos in my commands since I typed them here by heart. Someone who tries this can correct me.
    * Be sure to use the exact same version of Linux. For example if source has

    * –numeric-owner is required because the target server might (initially) not have the same users in it’s passwd file. Without it I ended up all files being owned by root.

  4. Andy
    2:06 pm on October 1st, 2009

    Henno – I really wanted to try your solution but there seems to be a problem with the tar syntax. This is what I get when I try to pipe tar to ssh:

    [root@ghdev1 /]# tar cvpf – -X /tmp/nocopy -numeric-owner * | ssh -C testvm “cd /tmp/source; tar xvpf – -numberic-owner “tar xvpf – –numeric-owner”

    tar: You may not specify more than one `-Acdtrux’ option
    Try `tar –help’ or `tar –usage’ for more information.

    I can’t seem to figure out why tar doesn’t like this command. I’m using tar (GNU tar) 1.15.1 on RHEL 5.2. Any suggestions?

  5. Mario Toro
    4:04 am on February 12th, 2012

    Hello, people.

    I had clone machines in production environment on the fly, with only kickstart, ssh and tar.

    Look at this:

    1) Recreate the skeleton from source server in destination server vía kickstart (15 min, max).
    2) Logon in the management console of destination, and start with linux rescue cd. Mount the existing system in /mnt/sysimage.
    3) Always in destination, start the eth nic with a network address that can reach the source server, and change dir to /mnt/sysimage. Tipe the following command:

    ssh source_server_ip ‘cd /; tar -zcvf – –listed-incremental=/var/tmp/`hostname`.snar –exclude=dev –exclude=proc –exclude=sys *’ | tar -zxvf –

    ..and voilá.

    4) reboot destination server in single user, repair any little detail if exist (nothing in more cases).

    5) shutdown source server and boot in multiuser destination server !!

    Obs: It is possible to take more incremental syncs with tar, if the source server is not inmediatly available to stop.


Leave a Comment

Name (required)

Email (required)



More Blog Post