Duplicating LVM Backed Xen DomU

LVM’s snapshot feature enables us to duplicate an LVM backed Xen DomU in seconds rather than minutes. We no longer need to copy the entire file system image like backing up file backed Xen DomU. We just need to make a snapshot of the current Xen DomU in seconds. When there are changes to the file system of the new DomU, LVM will make a copy of the physical block of the logical volume write the the new volume. How to duplicate LVM backed Xen DomU is introduced in this post.


There are Xen DomU virtual machines in LVM logical volume /dev/vg_xen/vm-

Now we want to duplicate the virtual machine vm- to vm- which we want to stored in logical volume vm- in volume group vg_xen. vm-‘s IP will be There are three steps to duplicate this virtual machine:

1) Duplicate the LVM logical volume

We can duplicate the LVM volume group 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/vg_xen/vm-

Here the size of the new logical volume is 20G as the same of the original one. We may change the content in all the storage space in the new DomU so we create a logical volume that has the same size.

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) Change the profile for new DomU

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:vg_xen/vm-,xvda,w' ]
vif=[ 'bridge=eth0' ]
bootloader = "/usr/bin/pygrub"
on_reboot = 'restart'
on_crash = 'restart'

The name and disk entry are changed.

3) 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 specify HWADDR 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 is running now. This process can be written into one script and the overall time for duplicating the Xen DomU can be as short as number of seconds.

For more tutorials about Xen, please refer to Xen Solution.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.


  1. Hi Eric,

    Actually we can make some changes at original or old domu and it won’t make some changes to the new domu or snapshot. I had tried it, when I made the old domu shutdown then start the snapshot. All changes I made on the old domu didn’t happen at the snapshot.

    Best regards.

Leave a Reply

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