This article explains how to install and use KVM to create and run virtual machines on the Ubuntu12.04LTS server. I will introduce how to create an image-based Virtual Machine and how to create a virtual machine using a logical volume (LVM. KVM is a kernel-based virtual machine that fully utilizes hardware virtualization technology. That is to say, you need to support hardware virtualization processors, such as Intel VT or AMD-V. I do not guarantee that the steps described in this article are applicable to your situation! 1. Home Page notes I use the host name in this article
This article explains how to install and use KVM to create and run virtual machines on the Ubuntu 12.04 LTS server. I will introduce how to create an image-based Virtual Machine and how to create a virtual machine using a logical volume (LVM. KVM is a kernel-based virtual machine that fully utilizes hardware virtualization technology. That is to say, you need to support hardware virtualization processors, such as Intel VT or AMD-V.
I do not guarantee that the steps described in this article are applicable to your situation!
1. Home Page notes
In this article, I use the host name server1.example.com and the IP address 192.168.0.100 as the KVM host.
Because we will run all the steps described in this article with the root user permission (root privilege), we can use the string sudo to prefix all the commands in this tutorial, or just enter the following command, become the root user immediately.
Sudo su
2. Install KVM and vmbuilder
First, check whether your processor supports hardware virtualization. If yes, run the following command:
Egrep '(vmx | svm)' -- color = always/proc/cpuinfo
The following content should be displayed:
Root @ server1 :~ # Egrep '(vmx | svm)' -- color = always/proc/cpuinfo
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat limit 36 clflush
Mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3 dnowext 3 dnow rep_good nopl extd_apicid
Pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3 dnowprefetch lbrv
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat limit 36 clflush
Mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3 dnowext 3 dnow rep_good nopl extd_apicid
Pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3 dnowprefetch lbrv
Root @ server1 :~ #
If nothing is displayed, your processor does not support hardware virtualization. You must stop here.
To install KVM and vmbuilder (create a script for a Ubuntu-based Virtual Machine), run:
Apt-get install ubuntu-virt-server python-vm-builder kvm-ipxe
Then, we must add the user as the current login user (Root User) to the group libmongod:
Adduser 'id-UN' libmongod
Adduser 'id-UN' kvm
You need to exit and log on again so that the new group membership takes effect.
Check whether KVM is successfully installed and run
Virsh-c qemu: // system list
The displayed content should be like this:
Root @ server1 :~ # Virsh-c qemu: // system list
Id Name State
----------------------------------
Root @ server1 :~ #
If it shows an error, what is wrong.
Next, we need to build a bridge on the server so that we can access our virtual machine from other hosts, as if the virtual machine is a physical system in the network.
To this end, we have installed the package bridge-utils ......
Apt-get install bridge-utils
Configure the bridge. Open/etc/network/interfaces:
Vi/etc/network/interfaces
Before the change, my file looks like the following:
# This file describes available network interfaces on the system,
# And how to activate these network interfaces. For more information, see interface (5 ).
# Delivery network interface
Auto lo
Iface lo inet loopback
# Primary Network Interface
Auto eth0
Iface eth0 inet static
Address 192.168.0.100
Netmask 255.255.255.0
Network 192.168.0.0
Broadcast 192.168.0.255
Gateway 192.168.0.1
Dns-nameservers 8.8.8.8 8.8.4.4