Change KVM boot order with multiple virtio disks in guest
Solution 1
Set the wanted disk as virtio-disk0, with target of /dev/vda. The order the disks appear in, in the XML is also important, so make sure the OS disk comes first
Solution 2
If you have multiple hard disks a better solution is to use
<boot order='1'/>
for the first device you want to boot and
<boot order='2'/>
for the 2nd etc You put this into each device you want to boot from. I did it as the last line of my config for the device.
My disks were different types and so I needed to use the boot order config.
It does not work with just changing disk names when they different e.g. a virtual disk and a hard drive partition.
You also have to remove the
<boot dev='hd'/>
From the os section
Related videos on Youtube
gregthegeek
I am a linux admin, intermediate php programmer, and a beginner iOS developer. :)
Updated on September 18, 2022Comments
-
gregthegeek almost 2 years
I just started playing with KVM, so learning quite a bit here. I have a guest running, finally got the OS setup the way I want with Virtio SCSI and Net drivers (Win2k3) and am very happy with everything. Then I shutdown the system and added a second data volume as Virtio as well. Once I did this, it bumped my original "Target device" from "VirtIO Disk 1" to "VirtIO disk 2" and now it won't boot unless I manually F12 and select the (now second) disk. Why did it make my original disk the 2nd one, when it was added first? And more importantly, how do I rearrange them? Maybe just remove them both and add them back in reverse order? Seems like there should be a config option or an edit in XML file for this.
I did try editing the vmname.xml file and found the option. I added that to each disk device in the order I prefereed, yet, it always comes up unbootable. Its like it will only try the first HDD and stops there. And it seems to ignore the boot order paremeters in XMl config.
I will go ahead and remove and re-add for now, but I am curious, shouldn't this be a configurable without removing devices?
I am running Ubuntu 14.04, its fairly up to date. I think libvirtd is 1.2.2. Any other specs that may help, just let me know. Thanks for the help! Greg
Quick Update: I tried removing both disks, closing virt-manager, and reopening. Then I added datavol first, then added OSVolume (which should be 1st disk), and it really insists on keeping that backwards order! It didn't work.
How do I get the guest to boot then if the disk order is backwards? (without manually booting to F12 option)
[EDIT: virsh dumpxml of the guest]
I see the boot order tags are removed now though, since I re-added the disks. I'd like this disk to be first:
/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>
-
David Corsalini over 9 yearsPlease post the domxml and which disk you want to be first
-
gregthegeek over 9 yearsI updated the xml and the disk dev I'd like first. Hopefully that xml dump of the guest what you meant by domxml. (correct?) Thank you for your help! :)
-
David Corsalini over 9 yearswell, it obvious, set the wanted disk as virtio-disk0, with target of /dev/vda. The order the disks appear in, in the XML are also important, so make sure the OS disk comes first
-
gregthegeek over 9 yearsYep... easy! Just swapped the position and vda and vdb targets, changed the alias names. Then in virt-manager I disabled any boot options, and it booted perfectly! thanks! Hey, add an answer below so you get credit for this.
-
David Corsalini over 9 yearsyou've got it :)
-