Operating system virtualization-KVM

Source: Internet
Author: User

KVM (kernel-based virtual
Machine) is a fully virtualized solution. It has become a part of the Linux kernel since 2.6.20. That is to say, It is a virtualization Party officially supported by the Linux kernel.
Case. The hardware requirement of KVM is that the CPU must support virtualization. For Intel CPU, It is Intel VT, and amd cpu is
AMD-v. How are you sure your CPU supports hardware virtualization?

 
Egrep '(vmx | SVM)'/proc/cpuinfo

Vmx is Intel CPU, while SVM is amd cpu. My CPU returns the following:

 
Flags: fpu vme de pse tsc msr pae mce cx8 APIC Sep mtrr pge mca cmov Pat limit 36
Clflush dts acpi mmx fxsr SSE sse2 ss ht tm pbe syscall NX lm constant_tsc arch_perfmon pebs
BTS rep_good PNI dtes64 monitor ds_cpl vmx smx est TM2 ssse3 cx16 xtpr pdcm sse4_1
Xsave lahf_lm Ida tpr_shadow vnmi flexpriority
Flags: fpu vme de pse tsc msr pae mce cx8 APIC Sep mtrr pge mca cmov Pat limit 36
Clflush dts acpi mmx fxsr SSE sse2 ss ht tm pbe syscall NX lm constant_tsc arch_perfmon pebs
BTS rep_good PNI dtes64 monitor ds_cpl vmx smx est TM2 ssse3 cx16 xtpr pdcm sse4_1
Xsave lahf_lm Ida tpr_shadow vnmi flexpriority

Install the following software under Ubuntu:

 
Sudo apt-Get install KVM qemu-KVM

Add individual users to the KVM group to ensure that individual users can read/write/dev/KVM. Otherwise, individual users cannot run KVM:

 
Sudo adduser $ user KVM

To use a physical disk, add a user to the disk group:

 
Sudo adduser $ user Disk

Restart the computer now!

Next we will start to install the operating system. I have installed Windows XP and Windows 7. Next we will take Windows XP as an example to start installation.

Prepare a disk file in two common formats: qcow2 and raw, the latter is actually a continuous area on the disk.

Qcow2:

 
Qemu-IMG create-F qcow2 WINXP. IMG 10g

Raw:

 
Dd If =/dev/Zero of = WINXP. img bs = 1024 k count = 10000

Install the CD file WINXP. ISO. The installation instructions are as follows:

 
KVM-M 1024-CDROM = WINXP. iso winxp. IMG-boot D-localtime

XP is installed quickly. It takes about 20 minutes to install it, and Windows 7 takes about 40 minutes. Next we will start the following work, which will involve more parameters.

Virtio is a semi-virtualized mode that allows you to configure the hard disk and network in virtio mode. The speed is faster than the traditional mode. virtio is still advantageous according to the test in using virtio_net for the guest Nic.

Download the virtio Windows Guest DRIVER: storage driver and Network Driver from the VM, which already contain drivers such as XP and win7.

Install the driver as follows.

Create a temporary disk file:

 
Qemu-IMG create-F qcow2 fake. IMG 1g

Start the VM:

 
KVM-drive file = WINXP. IMG, if = IDE, boot = on-drive file = fake. IMG, if = virtio-M 1024
-Localtime-net Nic, model = virtio-Net user-USB-usbdevice Tablet

In the started virtual machine, find the virtio device and install the two drivers. After installation, shut down. Restart in the following ways:

 
KVM-drive file = WINXP. IMG, if = virtio, boot = on-M 1024-net Nic, model = virtio-Net user
-USB device tablet-soundhw es1370

To configure remote desktop access to Windows, you must first enable the Remote Desktop in windows of the Virtual Machine and add a password to the user. Windows XP and Windows 7 must be of professional or later versions. Run MMC to continue configuring Remote Desktop Access parameters.

After opening MMC, "Add/delete snap-in"-> "add"-> "Group Policy object Editor"->
"Local Computer ". Configure in: "Computer Configuration"-> "management template"-> "Windows Components"-> "Terminal Services"->
The maximum color depth is set to 24 bits. The default value is 16 bits.

Shut down and run it in the background in the new mode again:

 
KVM-m PC-drive file = WINXP. IMG, if = virtio, boot = on-localtime-M 1024-soundhw es1370
-Net Nic, model = virtio-Net user-VNC 127.0.0.1: 0-daemonize-redir TCP: 3389: 3389
-Name WindowsXP-USB-usbdevice Tablet

-VNC 127.0.0.1: 0 indicates to run in VNC mode,-daemonize indicates to run on KVM later,-redir
TCP: 3389: 3389 indicates that port 3389 of the VM is mapped to port 3389 of the host machine, so that remote desktop access can be performed on the rdesktop machine. If you want
You can use vncviewer or vinagre to view the status.

Now you can access rdesktop. The following is the rdesktop parameter:

 
Rdesktop localhost-u username-P password-F-D-z-p-r sound: local-clipboard

Here, the-Z parameter ensures that the mouse speed is not slow, and the-F parameter indicates full screen.

How can I use a USB device for a VM? First, ensure that the user can access the USB device. qemu supports USB device plugging in the VM on the qemu interface (or on the VNC access interface ), CTRL + ALT + 2 enter the qemu monitor command line control mode, and then

Usb_add HOST: vid: PID

View USB devices:

 
Info USB

The running and access parameters of Windows 7 are similar to those of Windows XP.

Below are some of my screenshots:

Windows XP:

Windows 7:

Rdesktop enables the font smoothing function for Windows 7 on Friday, published.

After rdesktop is connected to Windows 7, the font smoothing function is generally disabled. Therefore, the font is not very nice. You can add the following parameters to connect and enable the font smoothing function, in addition, the original Windows 7 desktop is retained. Unlike the black desktop that appeared after the connection, you need to set it again.

 
Rdesktop localhost-x 0x80-u username-P password-F-D-z-p-r sound: local-clipboard

Add the-x 0x80 option.

 

Http://www.heboliang.cn/archive/kvm-windows.html

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.