UbuntuKVM usage summary

Source: Internet
Author: User
I have written a series of articles. here I will summarize them in a single article for ease of viewing. This article targets Ubuntu1310server. Host installation

I have written a series of articles. here I will summarize them in a single article for ease of viewing. This article is intended for Ubuntu 13.10 server.

Host installation check whether the CPU supports virtualization
root@kvmhost:~# egrep '(vmx|svm)' --color=always /proc/cpuinfoflags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidflags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpid
Install KVM and KVM Builder
apt-get install ubuntu-virt-server python-vm-builder kvm-ipxe  
Set user group
adduser `id -un` libvirtdadduser `id -un` kvm
Check

After reboot, log on again and run the following command to check

root@kvmhost:~# virsh -c qemu:///system list Id Name                 State----------------------------------
Configure the network

Set/etc/network/interfaces as follows

# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto eth1iface eth1 inet manualauto br0iface br0 inet static      address 10.150.140.103      network 10.150.140.0      netmask 255.255.0.0      broadcast 10.150.255.255      gateway 10.150.0.254      dns-nameservers 10.150.0.253 8.8.8.8      bridge_ports eth1      bridge_fd 9      bridge_hello 2      bridge_maxage 12      bridge_stp off

Note that the IP address of eth1 is now set to br0, and eth1 is set to manual.

Dns, netmask, and broadcast under br0 all come from the original eth1 settings.

After setting the KVM host, restart it.

KVM Builder patch

From Ubuntu 12.10, KVM Builder has a bug that causes the following error when creating a VM:

Selecting previously unselected package linux-image-virtual.Unpacking linux-image-virtual (from .../linux-image-virtual_3.5.0.17.19_amd64.deb) ..., stderr: grep: /proc/cpuinfo: No such file or directory
This is the bug of vmbuilder that comes with Ubuntu 12.10/13.10 because there is no mount/proc directory. Here we discuss this problem and provide a temporary solution:

Https://bugs.launchpad.net/ubuntu/+source/vm-builder/+bug/1037607

The patch command is as follows:

wget https://launchpadlibrarian.net/120169451/usr_share_pyshared_VMBuilder_plugins_ubuntu_dapper.py.diffcp /usr/share/pyshared/VMBuilder/plugins/ubuntu/dapper.py ./dapper.py_bkpatch /usr/share/pyshared/VMBuilder/plugins/ubuntu/dapper.py ./usr_share_pyshared_VMBuilder_plugins_ubuntu_dapper.py.diff 
Create a virtual machine

The/etc/apt/sources. list file of the created virtual machine needs to be modified. it is best to copy the file from the host machine.

Clone virtual machine installation software:
apt-get install virtinst

For example, if you already have a vm_base VM, use virsh shutdown to shut it down and start cloning.

First, create the directory to store

mkdir -p /var/lib/libvirt/images/infobright 
virt-clone -o vm_base -n infobright --file /var/lib/libvirt/images/infobright/a.img --file /var/lib/libvirt/images/infobright/b.img
apt-get install guestfish  
apt-get install libguestfs-tools 
update-guestfs-appliance 
Okay. now you can modify several files.
virt-edit -d infobright /etc/hostnamevirt-edit -d infobright /etc/hosts

Modify the network configuration. Note that other subnet configurations can be used inside the VM, which is not necessarily the same as that of the KVM host.

virt-edit -d infobright /etc/network/interfaces
auto eth0iface eth0 inet static        address 10.150.144.23        netmask 255.255.0.0        network 10.0.0.0        gateway 10.150.0.1        # dns-* options are implemented by the resolvconf package, if installed        dns-nameservers 10.150.0.253 8.8.8.8        up route add default gw 10.150.0.254        up route add -net 115.182.51.0 netmask 255.255.255.0 gw 10.150.0.1 dev eth1        up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.150.0.1 dev eth1
Copy to another host machine and manage and modify the xml file of the VM.

Run the virsh edit vm_name command to modify the corresponding xml file. to use emacs, set emacs as the default editor.

Add the following content to the/root/. bashrc file:

export EDITOR=/usr/bin/emacs
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.