KVM 开启UEFI支持

KVM 开启UEFI支持

官方文档:


环境:CentOS7.1 x64

一.配置firmware源

wget http://www.kraxel.org/repos/firmware.repo -O /etc/yum.repos.d/firmware.repo


二.安装ovmf

yum install edk2.git-ovmf-x64


提示:不FQ,yum无法安装,这里给出另一种解决方案,直接下载社区已经编译好的OVMF.fd文件,或者花点时间直接从源码编译

http://sourceforge.net/projects/edk2/files/OVMF/


到以上站点下载最新的对应版本OVMF-X64-r15214.zip

解压后会看到如下几个文件,其中OVMF.fd就是我们要加载的UEFI rom,README也提供了非常详细的参数解释,有时间可以看看

BUILD_INFO LICENSE    OVMF.fd    README


README中就提到了UEFI变量的支持情况

* QEMU 0.12.2 or later is required.

* Be sure to use qemu-system-x86_64, if you are using and X64 firmware.

  (qemu-system-x86_64 works for the IA32 firmware as well, of course.)

* Use OVMF for QEMU firmware (3 options available)

  - Option 1: QEMU 1.6 or newer; Use QEMU -pflash parameter

    * QEMU/OVMF will use emulated flash, and fully support UEFI variables

    * Run qemu with: -pflash path/to/OVMF.fd

  - Option 2: Use QEMU -bios parameter

    * Note that UEFI variables will be partially emulated, and non-volatile

      variables may lose their contents after a reboot

    * Run qemu with: -bios path/to/OVMF.fd

  - Option 3: Use QEMU -L parameter

    * Note that UEFI variables will be partially emulated, and non-volatile

      variables may lose their contents after a reboot

    * Either copy, rename or symlink OVMF.fd => bios.bin

    * Use the QEMU -L parameter to specify the directory where the bios.bin

 

      file is located.

对于CentOS7.1,可以直接把OVMF.fd拷贝到/usr/share/qemu-kvm下,该目录存放的是centos发行版qemu目录所有的启动rom


三.配置 libvirtd以启用UEFI

Configure libvirtd to advertise UEFI support

Libvirt needs to know about UEFI->NVRAM config file mapping, so it can advertise it to tools like virt-manager/virt-install.

As root, edit /etc/libvirt/qemu.conf, and add this section at the top of the file:

 nvram = [

    "/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd:/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd",

 ]


具体的目录以实际OVMF.fd存放的目录为准,我这里指定的是

 nvram = [ "/usr/share/qemu-kvm/OVMF.fd:/usr/share/qemu-kvm/OVMF.fd]

 

四.重启libvirtd

systemctl restart libvirtd


五.创建虚拟机

virt-manager

Create a new VM in virt-manager. When you get to the final page of the 'New VM' wizard, do the following:

  • Click 'Customize before install', then select 'Finish'
  • On the 'Overview' screen, Change the 'Firmware' field to select the 'UEFI x86_64' option.
  • Click 'Begin Installation'
  • The boot screen you'll see should use linuxefi commands to boot the installer, and you should be able to run efibootmgr inside that system, to verify that you're running an UEFI OS.

KVM <wbr>开启UEFI支持

KVM <wbr>开启UEFI支持
KVM <wbr>开启UEFI支持

KVM <wbr>开启UEFI支持

更精细的参数控制就需要个性VM对应的配置文件,如uefi变量的支持情况况及模板位置等就需要在os段加入如下内容来精细控制

virsh edit rhel7.0

KVM <wbr>开启UEFI支持



virt-install

Add --boot uefi to your virt-install command. Example:

 sudo virt-install --name f20-uefi \

   --ram 2048 --disk size=20 \

   --boot uefi \

  --location https://dl.fedoraproject.org/pub/fedora/linux/releases/22/Workstation/x86_64/os/

posted @ 2015-12-13 02:39  李庆喜  阅读(7400)  评论(0编辑  收藏  举报