本文主要出现的原因其实很简单,就是让目前创建的虚拟机支持UEFI引导。话不多说开始吧😳
环境信息
1 | [root@dev ~]# cat /etc/redhat-release |
查看当前主机Qemu支持机器类型
可以通过以下两种查询方法,或其他有效的方法
-
通过qemu-kvm进行查询
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16[root@dev ~]# /usr/libexec/qemu-kvm -M help
Supported machines are:
pc RHEL 7.6.0 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-rhel7.6.0)
pc-i440fx-rhel7.6.0 RHEL 7.6.0 PC (i440FX + PIIX, 1996) (default)
pc-i440fx-rhel7.5.0 RHEL 7.5.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.4.0 RHEL 7.4.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.3.0 RHEL 7.3.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.2.0 RHEL 7.2.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.1.0 RHEL 7.1.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.0.0 RHEL 7.0.0 PC (i440FX + PIIX, 1996)
q35 RHEL-7.6.0 PC (Q35 + ICH9, 2009) (alias of pc-q35-rhel7.6.0)
pc-q35-rhel7.6.0 RHEL-7.6.0 PC (Q35 + ICH9, 2009)
pc-q35-rhel7.5.0 RHEL-7.5.0 PC (Q35 + ICH9, 2009)
pc-q35-rhel7.4.0 RHEL-7.4.0 PC (Q35 + ICH9, 2009)
pc-q35-rhel7.3.0 RHEL-7.3.0 PC (Q35 + ICH9, 2009)
none empty machine -
通过libvirt进行查询
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22[root@dev ~]# virsh capabilities
<capabilities>
...
<guest>
...
<machine maxCpus='240'>pc-i440fx-rhel7.6.0</machine>
<machine canonical='pc-i440fx-rhel7.6.0' maxCpus='240'>pc</machine>
<machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
<machine maxCpus='384'>pc-q35-rhel7.6.0</machine>
<machine canonical='pc-q35-rhel7.6.0' maxCpus='384'>q35</machine>
<machine maxCpus='240'>pc-i440fx-rhel7.5.0</machine>
<machine maxCpus='240'>pc-i440fx-rhel7.1.0</machine>
<machine maxCpus='240'>pc-i440fx-rhel7.2.0</machine>
<machine maxCpus='255'>pc-q35-rhel7.3.0</machine>
<machine maxCpus='384'>pc-q35-rhel7.4.0</machine>
<machine maxCpus='240'>pc-i440fx-rhel7.3.0</machine>
<machine maxCpus='240'>pc-i440fx-rhel7.4.0</machine>
<machine maxCpus='384'>pc-q35-rhel7.5.0</machine>
...
</guest>
...
</capabilities>
通过以上内容可以看出,如果我们只是需要使用最新的机器类型只要选择 pc
或 q35
配置虚拟机使用Q35
1 | [root@dev ~]# virsh edit --domain alpinelinux3.8 |
将以上内容调整为 machine='q35'
即为完成
配置虚拟机支持UEFI
如果需要虚拟机支持
uefi
还需要edk2-ovmf
软件包的支持
- 安装
edk2-ovmf
软件包
1 | [root@dev ~]# yum search edk2-ovmf |
- 编辑虚拟机配置
1 | [root@ocloud-dev ~]# virsh edit alpinelinux3.8 |
找到以上节点添加对应的内容即可
注意:如果loader节点属性secure='yes’则必须开启smm