How to duplicate Xen DomU virtual machines
Tags: domu, tutorials, Virtualization, xen
Assumption:
There are VBD based Xen DomU virtual machines stored under /lhome/xen/vm-f11-sample/. There are two files under vm-f11-sample: vm0-f11.run (The configuration file) and vmdisk0 (The virtual disk).
Now we want to duplicate the virtual machine vm0 stored under vm-f11-sample to vm213 stored under vm213. And vm213′s ip will be 10.0.0.213. The steps to duplicate this virtual machine:
1) Duplicate the virtual disk and configuration files
# cp -rf vm-f11-sample vm213
For security reason, the owner of the virtual machine’s files is root. So we need to copy these files as root. The destination directory is vm213. And here we assume that vm0 is power off. If vm0 is power on before this step, we need to shut it down first.
2) Change the file names and the configuration file
# cd vm213 # mv vmdisk0 vmdisk213 # mv vm0-f11.run vm213-f11.run # vim vm213-f11.run
This is the content of vm213-f11.run:
name="vm213" memory=1024 disk = ['tap:aio:/lhome/xen/vm213/vmdisk213,xvda,w' ] vif = [ 'bridge=eth0' ] bootloader = "/usr/bin/pygrub" vcpus=2 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
# xm create /lhome/xen/vm213/vm213-f11.run
# xm console vm213
After log in to vm213:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Change the IPADDR to 10.0.0.213. Then restart eth0:
# ifdown eth0 # ifup eth0
Log out of vm213 and then use “Ctrl + ]” to exit the xm console.
Reset vm213 on Dom0:
#xm reset vm213
The new virtual machine vm213 is running now.
Updated on Feb. 10, 2010. Format the text.
Updated on Feb. 8, 2010. Change loopback backed driver to blktap backed one.
Updated on Feb. 23, 2010. Change some typo and format.
Updated on Apr. 16, 2010. Format the text.
Read more:
- Create and manage virtual machines on Xen
- Unified Xen DomU configuration file
- Automatically backing up Xen File-backed DomU
- A simple CPU and memory performance test of xen Dom0 and DomU
- Setting up Stable Xen DomU with Fedora: Unmodified Fedora 12 on top of Xenified Fedora 12 Dom0 with Xen 4.0.0
- Managing Xen Dom0′s CPU and Memory


















[...] This virtual machine can be duplicated to get more VMs: How to duplicate Xen DomU virtual machines. [...]