The official version of KVM is a virtual machine software designed for Linux systems. The latest version of KVM is a kernel-based open source virtualization that can help users simulate Windows systems in Linux systems and realize the freedom of installing software across systems. KVM virtualization requires Intel
The hardware support of VT technology or AMD V technology is complete virtualization based on hardware.
KVM software introduction
Kvm is the abbreviation of kernel-based virtual machine. It is an open source system virtualization module. Since Linux
After 2.6.20, it will be integrated into all major Linux distributions. It uses Linux's own scheduler for management, so compared to xen, its core source code is very small. kvm has now become one of the mainstream vwm in academia.
KVM installation method
1. Installation preparation
1. Make sure the machine has VT
Terminal input command: grep vmx /proc/cpuinfo (INTEL chip)
Grep svm /proc/cpuinfo (AMD chip)
If you don’t know the manufacturer of the chip, enter: egrep '(vmx|svm)' /proc/cpuinfo
If there is vmx or svm in flags:, it means VT is supported; if there is no output, it means your CPU does not support it and you will not be able to successfully install the KVM virtual machine.
2. Make sure VT is turned on in the BIOS
Intel(R) Virtualization Tech [Enabled]
If necessary, you need to enable VT-d in the BIOS
3. Make sure the kernel version is newer and supports KVM
Use uname -r to check the kernel version. If the Linux version is below 2.6.20, you need to upgrade the kernel.
2. Install KVM
The following is an introduction to the installation and use of KVM virtual machines under Ubuntu and CentOS:
Ubuntu uses guest to log in. The command to install KVM is:
sudo apt-get install kvm qemu qemu-kvm virt-manager kernel-package
linux-source kqemu-source build-essential
After kvm is installed successfully, there will be /dev/kvm. If you do not need a graphical manager, you only need to install the first three.
Let’s check if KVM is installed successfully, execute: virsh -c qemu:///system list
If the input result is like the following, then it is successful:
Connecting to uri: qemu:///system
Id Name State
Note 1: When installing in CentOS, you must first select Selinux as enable and use the command
#system-config-securitylevel-tui
You can view or modify the status of selinux.
Note 2: When logging in as root in CentOS, the installation command is:
yum install kvm kmod-kvm qemu
Then load the kvm module: modprobe kvm-intel (Intel machine) or modprobe kvm-amd (amd machine)
Note 3: You can use the following command to check whether the kvm module is loaded:
/sbin/lsmod | grep kvm
If information about the kvm version is output, the kvm module has been loaded.
Note 4:
After installation, you can use the qemu-kvm command and enter the command. If the system displays an unknown command, you can check whether there is a qemu-kvm executable file in /usr/libexec. If so, copy it to the /bin directory. Can. If you have followed the above steps but cannot find the qemu-kvm executable file in /bin, /usr/libexec, /usr/bin, or /usr/sbin, you can execute the following command:
#yum provides "*/qemu-kvm"
Note 5: After installing the new kernel, some software versions may be too old and incompatible. For example, Firefox cannot be started because the version is too low.
You can use the following command to update the software under CentOS (take firefox as an example):
#yum update firefox
3. Install virtual machine under KVM
1. Use QEMU to create a disk image
sudo qemu-img create –f qcow windows.img 8G
Note: In CentOS and the new version of Qemu: qemu-img create –f qcow2 windows.img 8G
2. Use KVM to install Guest VM
CD installation:
sudo kvm –localtime –cdrom /dev/cdrom -m 512 -boot d win2.img
Hard disk installation:
sudo kvm –localtime –m 512 –hda windows.img –cdrom winxp.iso –boot d –clock
–rtc –no-acpi
Note: The official recommendation is to use the -no-acpi parameter because qemu/kvm does not support it, which may cause high CPU usage.
Note 1: The hard disk installation under CentOS is qemu-kvm –localtime –m 512 –hda windows.img –cdrom
winxp.iso –boot d –no-acpi means that the -clock rtc option needs to be removed, otherwise the clock will not be initialized.
Note 2: CentOS quest mouse: export
SDL_VIDEO_X11_DGAMOUSE=0 can solve the problem of USB mouse not being recognized in VM.
Note 3: When installing win 7, the -no-acpi option cannot be used.
KVM usage instructions
KVM starts Guest
① sudo kvm –boot c –m 512
–hda windows.img
② sudo kvm -boot c
-m 512
-hda /home/lm/kvm/winxp.img
-localtime
-net nic,vlan=0,macaddr=52-54-00-12-34-01 -net
tap,vlan=0,df=h,ifname=tap0,script=no
-clock rtc
-soundhw es1370
-smp 2
Note: Under KVM-87, please remove df=h
-m 512 allocates 512MB of memory
-hda /home/lm/kvm/winxp.img
-localtime uses local time (this parameter must be added, otherwise there will be problems with the virtual machine time)
-net nic,vlan=0,macaddr=52-54-00-12-34-01 -net
tap,vlan=0,df=h,ifname=tapo,script=no
Use the network and connect to an existing network device tap0. Note that the mac address must be compiled by yourself, especially if you virtualize multiple systems and want to run them at the same time, otherwise there will be a MAC conflict. Remove df in KVM-87 =h
-boot d Boot from the CD (this is also used to boot from the image. -boot c to boot from the hard disk)
-smp 2 The number of smp processors is 2. If you have a 4-core processor, the number after it is 4
-clock rtc
KVM update log
1.Fix BUG, the new version has a better experience
2. Some pages have been changed
Huajun editor recommends:
KVM is a conscientious product with guaranteed performance. I personally tested it and I believe you can try it on my children’s shoes! Our Huajun Software Park has more useful software Nut Cloud (32bit) For Linux, mining systems, and .NET!