下载
中文
注册

执行virt-install创建虚拟机时提示“ERROR --os-variant/--osinfo OS name is required, but no value was set or detected.”

问题描述

执行virt-install创建虚拟机时提示“ERROR --os-variant/--osinfo OS name is required, but no value was set or detected.”。

ERROR
--os-variant/--osinfo OS name is required, but no value was
set or detected.
 
This is now a fatal error. Specifying an OS name is required
for modern, performant, and secure virtual machine defaults.
 
If you expected virt-install to detect an OS name from the
install media, you can set a fallback OS name with:
 
  --osinfo detect=on,name=OSNAME
 
You can see a full list of possible OS name values with:
 
   virt-install --osinfo list         
 
If your Linux distro is not listed, try one of generic values
such as: linux2022, linux2020, linux2018, linux2016
 
If you just need to get the old behavior back, you can use:
 
  --osinfo detect=on,require=off
 
Or export VIRTINSTALL_OSINFO_DISABLE_REQUIRE=1

可能原因

根因:Ubuntu系统上安装非官方系统时,会因为UEFI Secure Boot而被阻止。

解决方案

  1. 通过virt-install创建虚拟机时,同时关闭os的需求,即在原有的创建指令后添加--osinfo detect=on,require=off参数,例如:

    virt-install --name=kylin --vcpus=4 --ram=8192 --disk path=/home/kvm/images/kylin.img,format=qcow2,size=100,bus=virtio --cdrom /home/kvm/Kylin-Server-10-SP2-aarch64-Release-Build09-20210524.iso --network bridge=virbr0,model=virtio --force --autostart --graphic vnc,listen=0.0.0.0,port=5906 --input type=tablet,bus=usb --input type=keyboard,bus=virtio --osinfo detect=on,require=off

  2. 进入虚拟机的BIOS界面,关闭Secure Boot。
    1. 执行如下命令,连接到虚拟机。

      virsh console kylin

      Cnnected to domain ‘kylin’
      Escape character is ^] (Ctrl + ])
       
       
       
       
      Press ESC in 1 seconds to skip startup.nsh or any other key to continue
      Shell>
    2. 在UEFI shell界面输入exit,按“Enter”键进入BIOS界面。
    3. 依次选择“Device Manager > Secure Boot Configuration > Attempt Secure Boot”,按“Enter”键将“Attempt Secure Boot”右侧的[X] 变为[ ])。

    4. 选择“Reset Secure Boot Keys”并选择“Yes”确认重置Secure Boot Keys。

    5. 连续两次按ESC键返回初始目录。
    6. 选择“Reset”,并按“Enter”键,使安全启动修改生效,完成安全启动设置。

  3. 在物理机上执行如下命令,打开虚拟化管理器。

    virt-manager

    1. 双击准备安装的虚拟机,打开图形化界面。

    2. 单击图标并选择“SCSI CDROM 1”。

    3. 单击“Browse”,根据物理机目录选择安装的镜像ISO文件。

    4. 依次单击“Choose Volume”和“Apply”完成镜像挂载。
  4. 重新进入虚拟机BIOS界面,依次选择“Boot Manager > UEFI QEMU QEMU CD-ROM”并按“Enter”键。

  5. 在下图中单击图标

  6. 参考虚拟机安装OS章节安装虚拟机OS。
  7. 安装流程结束后,单击图标
  8. 单击“Remove”后并单击“Delete”,删除挂载的镜像。