Thursday, April 16, 2009

Clone virtual server.

Physical OS: Suse Linux Ent. 11.0 (SLES).
Virtual machine OS: OpenSUSE 11.0

This documentation is base on OpenSUSE 11.1

When you setup physical server, your system (in this case : xen), will built Domain-0. Inside Domain-0 you can insert virtual server as many as you wish. For the first virtual server, you must install by using CD or by getting it form any source.
The system, let say you want to develop (create) ten virtual server in your physical server, it is not economic (in term of time saving), if you use manual ways. Setting up virtual server (xen for Open SUSE 11.0) on SLES 11.0 is about ten to fifteen minutes. This is my experience doing this technical works.
So, if you can clone the system, you just copy the template of virtual server and then just adjust the IP address and its name. For xen, this template is located in the /etc/xen/images//disk0.

For example;
I already created a virtual server named as MYSVR01_01, and I want to create ten vm's named as MYSVR01_02, MYSVR01_03,.........., MYSVR01_10, MYSVR01_11.

First, to make sure you can fully duplicate the template, you must shutdown the virtual server. If you copy the template while the server is running, you should get the full copy, but at the stage to create virtual machine, you can get an error message: Kernel not found!

Ok, to duplicate this you must login as root into your system (physical system, in this example, my physical system named as MYSVR01). Then insert this command;

cd /etc/xen/images

If you check the current template, it will tell you that MYSVR01_01 already there. And inside MYSVR01_01 there is disk0. The disk0 keep all data needed to built new vm.

Then you can copy disk0 to your vm lists from 02 to 11, by using this command

list='MYSVR01_02 MYSVR01_03 MYSVR01_04 MYSVR01_05 MYSVR01_06 MYSVR01_07 MYSVR01_08 MYSVR01_09 MYSVR01_010 MYSVR01_11'

Then do this command
for i in $list; do cp -r MYSVR01_01 $i done

Then you must wait a moment until disk0 is duplicated in each vm folder.

When the work done, turn to root, by typing

cd /etc


cd ..

Insert command

yast2 &

And select, Create Virtual machine.

Then select 'I have a disk or disk image from an installed operating system'

Then click forward, select the OS type.

Click forward, then write your setup for new virtual machine, such as name, memory, and Disk.

For Disk, please select hardisk, and find the template disk named as disk0 in the directory MYSVR01_02.

Then click OK.

Virtual machine console will be automatically run, and until you reach the login part for that virtual machine.

After signing in, just type command yast. And the blue windows will appear.

Select Network Device and then Network Setting.
Just rename the hostname, IP Address, and other necessary data in this windows.

When you replaced all needed part, you can check the configuration by using this command:


At this stage, the command prompt still remain as the old name, but when you exit (command: exit), the prompt name will be changed to the new name.