安装虚拟机(KVM)
这种KVM只能安装windows无法安装安卓
(From https://phoenixnap.com/kb/ubuntu-install-kvm)
A type 2 hypervisor enables users to run isolated instances of other operating systems inside a host system. As a Linux based OS, Ubuntu supports a wide range of virtualization solutions.
Aside from popular third-party apps, such as VirtualBox and VMWare, the Linux kernel has its own virtualization module called KVM (Kernel-based Virtual Machine).
In this tutorial you will learn how to install and set up KVM on Ubuntu 20.04.
![](https://img-blog.csdnimg.cn/img_convert/441ade6602499120a34adb902e2a0068.png)
Prerequisites
A system running Ubuntu 20.04
An account with sudo privileges
Access to the command line/terminal
Check Virtualization Support on Ubuntu 20.04
1. Before you begin with installing KVM, check if your CPU supports hardware virtualization via egrep command:
egrep -c '(vmx|svm)' /proc/cpuinfo
Check the number in the output:
![](https://img-blog.csdnimg.cn/img_convert/78ece6a99c1c7ebc4c17d662c300524b.png)
If the command returns a value of 0, your processor is not capable of running KVM. On the other hand, any other number means you can proceed with the installation.
2. Now, check if your system can use KVM acceleration by typing:
sudo kvm-ok
The output should look like this:
![](https://img-blog.csdnimg.cn/img_convert/73952a71e9367fe5e6114c033b012349.png)
If kvm-ok returns an error stating KVM acceleration cannot be used, try solving the problem by installing cpu-checker.
3. To install cpu-checker, run the following command:
sudo apt install cpu-checker
4. When the installation completes, restart the terminal.
You are now ready to start installing KVM.
Note: When it is performed for servers, hardware virtualization is referred to as server virtualization.
Install KVM on Ubuntu 20.04
To enable KVM virtualization on Ubuntu 20.04:
Install related packages using apt
Authorize users to run VMs
Verify that the installation was successful
Step 1: Install KVM Packages
1. First, update the repositories:
sudo apt update
2. Then, install essential KVM packages with the following command:
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
This will start the installation of four KVM packages:
![](https://img-blog.csdnimg.cn/img_convert/b8193a4aa9f94eb70e6e01e4ef8d239c.png)
3. When prompted, type Y, press ENTER, and wait for the installation to finish.
Step 2: Authorize Users
1. Only members of the libvirt and kvm user groups can run virtual machines. Add a user to the libvirt group by typing:
sudo adduser ‘username’ libvirt
Replace username with the actual username.
![](https://img-blog.csdnimg.cn/img_convert/a91f734a7659bf2c1412f4c2ba3a8e1f.png)
2. Now do the same for the kvm group:
sudo adduser ‘[username]’ kvm
![](https://img-blog.csdnimg.cn/img_convert/73133e9125869e5bfcf95bfca0040589.png)
Note: If you need to remove a user from the libvirt or kvm group, just replace adduser with deluser in the command above.
Step 3: Verify the Installation
1. Confirm the installation was successful by using the virsh command:
virsh list --all
You can expect an output as seen below: