After the first virtual machine and Ubuntu server were created in the previous article,
The vm1.xml file is displayed in the/etc/libvirt/qemu/directory. The content is as follows:
<!-- WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE OVERWRITTEN AND LOST. Changes to this xml configuration should be made using: virsh edit vm1 or other application using the libvirt API. --><domain type='kvm'> <name>vm1</name> <uuid>75a471b9-8243-72e2-b0bb-c9ffa8c53c42</uuid> <memory>262144</memory> <currentMemory>262144</currentMemory> <vcpu>1</vcpu> <os> <type arch='x86_64' machine='pc-1.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/vm1/ubuntu-kvm/tmpTvdl9x.qcow2'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/vm1/ubuntu-kvm/tmpyGLuor.qcow2'/> <target dev='hdb' bus='ide'/> <address type='drive' controller='0' bus='0' unit='1'/> </disk> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'> <mac address='52:54:00:6a:d1:90'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> </graphics> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </memballoon> </devices></domain>
This XML file manages the configuration of devices such as memory size and network interface. It is very useful for management. Here we can see files representing two disks:
Tmptvdl9x. qcow2 and tmpygluor. qcow2 are both in the/var/lib/libvirt/images/VM1/Ubuntu-KVM directory.
Now create the second Vm and Ubuntu server.
Create VM2 and its subdirectories:
mkdir -p /var/lib/libvirt/images/vm2/mytemplates/libvirt
Copy necessary files:
cp /etc/vmbuilder/libvirt/* /var/lib/libvirt/images/vm2/mytemplates/libvirt/
You can copy the vmbuilder. Partition file in the VM1 directory and change it. Then run the command in the previous article.
If you do not change it, you do not need to create the VM2 directory. Run the following command:
cd /var/lib/libvirt/images/vm1/vmbuilder kvm ubuntu --suite=precise --flavour=virtual --arch=amd64 --mirror=http://de.archive.ubuntu.com/ubuntu -o --libvirt=qemu:///system --ip=10.112.18.192 --gw=10.112.18.1 --part=vmbuilder.partition --templates=mytemplates --user=chenshu --name=chenshu --pass=123456 --adpkg=openssh-server --addpkg=vim-nox --addpkg=unattended-upgrades --addpkg=acpid --mem=1024 --hostname=vm2 --bridge=br0 -d vm2-kvm
I don't like this because it creates the vm2-kvm directory to the VM1 directory. It is better to separate virtual machine directories.
So I created the VM2 directory and sub-directory as described in the previous article, and then run the following command:
vmbuilder kvm ubuntu --suite=precise --flavour=virtual --arch=amd64 --mirror=http://de.archive.ubuntu.com/ubuntu -o --libvirt=qemu:///system --ip=10.112.18.192 --gw=10.112.18.1 --part=vmbuilder.partition --templates=mytemplates --user=chenshu --name=chenshu --pass=123456 --addpkg=openssh-server --addpkg=vim-nox --addpkg=unattended-upgrades --addpkg=acpid --mem=2048 --hostname=vm1 --bridge=br0
Create the third VM in the same way. The IP address is 193.