Linux uses virt-manager to generate the qcow2 system image and start the virtual machine

1. Install virt-manager

First you need to install it virt-manager, the installation command is as follows.

imaginemiracle@:~$ sudo apt-get install virt-manager

After the installation is complete, check whether the installation was successful

imaginemiracle@:Ubuntu_Download$ virt-manager --version
2.2.1

After installation virt-manager, you need to install several other related libraries and tools. The installation commands are as follows.

imaginemiracle@:~$ sudo apt-get install qemu-kvm  libvirt libvirt-daemon-system libvirt-clients qemu-system

Enablelibvirtd

imaginemiracle@:~$ systemctl enable --now libvirtd

2. Download the Linux image file

Here the author is using the files Ubuntu20.10.isoused in this article ISOor downloading Ubuntuother versions, which can be downloaded here https://releases.ubuntu.com/20.10/

3. Generate qcow2the image and install the system

<1>.Open firstvirt-manager

# 用命令打开或者在应用列表中打开
imaginemiracle@:~$ sudo virt-manager

Insert image description here

<2> .Select in turnFile -> New Virtual Machine -> Local install media

Insert image description here

<3>. Select the downloaded ISOsystem image

Here, select the image downloaded locally
Insert image description here
and select the corresponding system type. If the system used does not have a corresponding version, just select the highest version supported by the software.
Insert image description here
As shown in the picture, my system here Ubuntu20.10does not have this version in the optional list. Select the highest supported version.Ubuntu20.04
Insert image description here

<4> .Set the system memory and core number

Insert image description here

<5> .Set the virtual machine disk size

Insert image description here

<6>. Confirm the completion of settings

Insert image description here

<7>. Start installing the system

The steps are the same as normal Ubuntusystem installation.
Insert image description here

<8>. Installation completed

Entering the installed system ubuntuis the same as normal.
Insert image description here

<9>. Get qcow2files

The path of the file will be given in the confirmation installation in the above steps qcow2. If it is the default, the file will be generated in the following path. ( 注: qcow2文件是生成的虚拟机镜像文件,该文件可以被qemu、virt-manager等虚拟机服务软件直接打开)

imaginemiracle:pool$ pwd
/var/lib/libvirt/images/pool
imaginemiracle:pool$ sudo ls -lh
total 8.1G
-rw------- 1 libvirt-qemu kvm 11G 6月  29 16:57 ubuntu20.04.qcow2

#Attachment: virt-managerRelated FAQs

Error 1:Error: No active connection to install on.

This is because libvirtdthe service is not started.
solution

imaginemiracle@:~$ sudo service libvirtd start

Error 2:libvirtError: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied

If libvirtdthe service has been started, you only need to modify the file permissions /var/run/libvirt/under the directory libvirt-sockto777

imaginemiracle@:~$ sudo chmod 777 /var/run/libvirt/libvirt-sock

Error 3:Error: Host does not support any virtualization options

There are various reasons for this error, here are some typical reasons and solutions.
1.BIOS This error occurs because the device does not support virtualization in the device .
Solution: Restart the system and enter BIOSthe settings, and enable virtualization support.
2. Due to /dev/kvmpermission issues.
Solution: Modify /dev/kvmpermissions and owner

imaginemiracle@:~$ sudo chmod 0660 /dev/kvm
imaginemiracle@:~$ sudo chown root:kvm /dev/kvm

3. There may be libvirtda problem with the service startup.
Solution: Check libvirtdthe status of the service

imaginemiracle@:~$ service libvirtd status

Check whether there is an error report, and solve it one by one according to the error report.

Guess you like

Origin blog.csdn.net/qq_36393978/article/details/118292678#comments_28569374