Duplicating and Backing Up LVM Backed Xen DomU from a Remote Server

LVM’s snapshot feature enables us to duplicate an LVM backed Xen DomU in seconds inside of the same volume group. When we want to duplicate LVM backed Xen DomU from a remote server, we need to make use of LVM’s snapshot function and tools like scp and dd. Backing up the DomU is only part of the process of duplicating one DomU. We can finish the backing up work after copying DomU’s image to remote server. How to duplicate and back up LVM backed Xen DomU from remote server is introduced in this post.

Assumption and our goal:

There are Xen DomU virtual machines in LVM logical volume /dev/vg_xen/vm- on server (remote server).

Now we want to duplicate the virtual machine vm- to vm- which we want to stored in logical volume vm- in volume group vgxen on server (local server). vm-‘s IP will be There are 6 steps to duplicate this virtual machine. If we just need to back up it, we can just use step 1 to setp 3.

1. Duplicate the LVM logical volume on remote server

We can duplicate the LVM volume group on remote server by making a snapshot of it. The snapshot is a clone of the logical volume. We can make a new logical volume vm- as the snapshot of logical volume vm-

# lvcreate -L20480 -s -n 'vm-' /dev/vgxen/vm-

Here the size of the new logical volume is 20G as the same of the original one.

Here we should make sure that vm- is power off to avoid the situation there are “write” that is still in DomU’s cache.

2. Save the snapshot to image file using dd tool on remote server

We can use dd command to save a image of the new created snapshot logical volume of the DomU:

# dd if=/dev/vgxen/vm- of=/lhome/xen-image/vm- bs=1k

This process may take several minutes or more depending on the size of the logical volume and the hard disk’s speed.

3. Copy the DomU’s image to the local server from the remote one

We can transfer the image from remote server after finishing the dd command on remote server.

# scp -c arcfour root@ /lhome/xen-image/

We set “-c arcfour” to get higher transfer speed of scp.

4. Create logical volume for the new DomU on local server

We can do this simultaneously with step 3. We create a new logical volume vm- under volume group vgxen on local server:

# lvcreate -L20480 -n 'vm-' vgxen

The size of the logical volume is the same as the one of the DomU in remote server.

5. Duplicate the data in the logical volume from the image

In this step, we use the dd command to copy data from the image file to the newly created logical volume:

# dd if=/lhome/xen-image/vm- of=/dev/vgxen/vm- bs=1k

This may also take some time to finish.

6. Change the profile for new DomU on local server

After making the clone of the VBD. We can create a profile for the new DomU. This is the content of /lhome/xen/vm-

disk=['phy:vgxen/vm-,xvda,w' ]
vif=[ 'bridge=eth0' ]
bootloader = "/usr/bin/pygrub"
onreboot = 'restart'
on_crash = 'restart'

The name and disk entry are changed.

7. Start the new virtual machine and configure the new virtual machine

We can start the new DomU and enter it’s console:

# xm create /lhome/xen/vm-
# xm console

Or directly:

# xm create -c /lhome/xen/vm-

After logging in vm-, we can edit the network configuration file:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Change the IPADDR to from Then restart eth0:

# ifdown eth0
# ifup eth0

Make sure this interface doesn’t have HWADDR by commenting out the line that specifyHWADDR if we use Xen bridge network.

Log out of vm- and then use “Ctrl + ]” to exit the xm console.

The new virtual machine vm- which is the clone of vm- except the IP and the Dom0 on top of which it is running is ready to use now. This process can be written into one script.


  1. Dear Rasho,
    Am from Kenya, I’ve gone through your post on “Duplicating and Backing Up LVM Backed Xen DomU from a Remote Server’ and i would like to thank you for your informative input.
    Am new to virtualization and xen to be specific and i was wondering if you would you mind sendme a link on how to install a centOS 6.4 minimal domu on a xen server. I’ve manage install the xen dom0 on centOS 6.4 but i was facing some challenges in installing the domu. Your assistance will be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Check Also
Back to top button