Home » Virtualization

How to duplicate Xen DomU virtual machines

By: Zhiqiang Ma On: Jan 13, 2010 Views: 275 Comment: 1 Print Email
Tags: , , ,

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:

Digg del.icio.us Stumble Techorati Facebook Newsvine Reddit Twitter
Mixx LinkedIn Google Bookmark Yahoo Bookmark MySpace LiveJournal Blogger RSS feed
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

One Comment »

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.