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


提示:不翻牆,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/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM