在客户机中使用多个 virtio 磁盘更改 KVM 启动顺序

在客户机中使用多个 virtio 磁盘更改 KVM 启动顺序

我刚开始使用 KVM,所以在这里学到了很多东西。我有一个客户正在运行,最终使用 Virtio SCSI 和网络驱动程序(Win2k3)按照我想要的方式设置了操作系统,并且对一切都非常满意。然后我关闭系统并添加了第二个数据卷作为 Virtio。一旦我这样做,它就会将我原来的“目标设备”从“VirtIO 磁盘 1”移动到“VirtIO 磁盘 2”,现在它不会启动,除非我手动按 F12 并选择(现在是第二个)磁盘。为什么它会将我的原始磁盘设为第二个磁盘,而它是第一个添加的?更重要的是,我该如何重新排列它们?也许只需将它们都删除,然后以相反的顺序将它们重新添加回来?似乎应该有一个配置选项或 XML 文件中的编辑。

我确实尝试编辑 vmname.xml 文件并找到了该选项。我按照我喜欢的顺序将其添加到每个磁盘设备,但它总是无法启动。它似乎只会尝试第一个硬盘并停在那里。而且它似乎忽略了 XMl 配置中的启动顺序参数。

我现在将继续删除并重新添加,但我很好奇,这不应该是在不删除设备的情况下进行配置吗?

我正在运行 Ubuntu 14.04,它相当新。我认为 libvirtd 是 1.2.2。如果有任何其他规格可能有帮助,请告诉我。谢谢您的帮助!Greg

快速更新:我尝试移除两个磁盘,关闭 virt-manager,然后重新打开。然后我先添加了 datavol,然后添加了 OSVolume(应该是第一个磁盘),然后它真的坚持保持倒序!这没用。

如果磁盘顺序是反向的,我该如何让客户机启动?(无需手动启动到 F12 选项)

[编辑:客人的 virsh dumpxml]

不过,由于我重新添加了磁盘,所以我看到启动顺序标签现在已被删除。我希望此磁盘是第一个: /dev/zvol/dpool/vm/kvm/disk/alinos/osvol

<domain type='kvm' id='80'>
<name>alinos</name>
    <uuid>a161efe4-245a-953b-89e3-04fa3b914f79</uuid>
  <memory unit='KiB'>3145728</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='i686' machine='pc-i440fx-trusty'>hvm</type>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>SandyBridge</model>
    <vendor>Intel</vendor>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='dtes64'/>
    <feature policy='require' name='vmx'/>
    <feature policy='require' name='erms'/>
    <feature policy='require' name='xtpr'/>
    <feature policy='require' name='smep'/>
    <feature policy='require' name='pcid'/>
    <feature policy='require' name='est'/>
    <feature policy='require' name='monitor'/>
    <feature policy='require' name='smx'/>
    <feature policy='require' name='tm'/>
    <feature policy='require' name='acpi'/>
    <feature policy='require' name='osxsave'/>
    <feature policy='require' name='ht'/>
    <feature policy='require' name='pdcm'/>
    <feature policy='require' name='fsgsbase'/>
    <feature policy='require' name='f16c'/>
    <feature policy='require' name='ds'/>
    <feature policy='require' name='tm2'/>
    <feature policy='require' name='ss'/>
    <feature policy='require' name='pbe'/>
    <feature policy='require' name='ds_cpl'/>
    <feature policy='require' name='rdrand'/>
  </cpu>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm-spice</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <target dev='hdc' bus='ide' tray='open'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <disk type='file' device='floppy'>
      <driver name='qemu' type='raw' cache='none'/>
      <target dev='fda' bus='fdc'/>
      <alias name='fdc0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source dev='/dev/zvol/dpool/vm/kvm/disk/alinos/datavol'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source dev='/dev/zvol/dpool/vm/kvm/disk/alinos/osvol'/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='fdc' index='0'>
      <alias name='fdc0'/>
    </controller>
    <controller type='scsi' index='0'>
      <alias name='scsi0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb0'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb0'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb0'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:89:65:18'/>
      <source bridge='br0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5901' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>
      <model type='vmvga' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='none'/>
</domain>

答案1

将所需磁盘设置为 virtio-disk0,目标为 /dev/vda。磁盘在 XML 中的显示顺序也很重要,因此请确保操作系统磁盘排在第一位

答案2

如果你有多个硬盘,更好的解决方案是使用

<boot order='1'/>

对于要启动的第一个设备,

<boot order='2'/>

对于第二个等,你将其放入要从其启动的每个设备中。我将其作为设备配置的最后一行。

我的磁盘类型不同,所以我需要使用启动顺序配置。

当磁盘名称不同(例如虚拟磁盘和硬盘分区)时,仅更改磁盘名称是行不通的。

您还必须删除

<boot dev='hd'/>

来自 os 部分

相关内容