Learn how to fix the “No Bootable Device” Error in KVM for Windows VMs. Our KVM Support team is here to help you with your questions and concerns.
“No Bootable Device” Error in KVM for Windows VMs | Fixed
If you have been running into a “No Bootable Device” error while booting a Windows VM in KVM, you have come to the right place.
According to our Experts, this error indicates issues related to the boot device configuration or the integrity of the boot media.
This is how the error will look like:
Boot Failed: Could not read from cdrom (code 0003)
No Bootable Device
This error typically results from improper boot configuration or missing disk initialization.
An Overview:
- Understanding the Boot Process in KVM
- Common Causes of the “No Bootable Device” Error
- Troubleshooting the “No Bootable Device” Error
- 1. Check the Boot Device Order
- 2. Verify Disk Attachment
- 3. Configure the Correct Disk Controller
- 4. Repair or Reinstall Windows Bootloader
- 5. Disk Initialization and Partitioning
- 6. Inspect VM Logs for Errors
- 7. Final Steps: Reinstalling Windows
- Tips for Disk Management in KVM
Understanding the Boot Process in KVM
KVM, like other hypervisors, uses a specific boot sequence to load the operating system within virtual machines. The boot sequence involves checking each defined device (hard disk, CD-ROM, network) in a particular order until a bootable device is found.
Unlike physical machines, where boot errors can be linked to hardware faults, KVM boot errors are often caused by misconfigurations in virtual hardware, such as incorrect disk formats or missing boot files.
KVM requires well-defined device mappings to load the operating system, and any discrepancy (like misconfigured disk controllers or boot order) can result in the “No Bootable Device” error.
Depending on the guest operating system and VM configuration, KVM can use either BIOS or UEFI firmware for booting.
Common Causes of the “No Bootable Device” Error
- The boot sequence may not be configured properly, causing KVM to attempt booting from a non-bootable device.
- The virtual disk containing the Windows OS may not be attached to the VM or could be incorrectly configured.
- The virtual disk may not be initialized, or Windows installation may not start.
- An incompatible virtual disk format or controller type (SATA, IDE, Virtio) may prevent booting.
- A damaged or missing Windows bootloader can cause this error.
Troubleshooting the “No Bootable Device” Error
1. Check Boot Device Order
- If we are using Virt-Manager, open the VM’s settings by right-clicking on the VM and selecting Show Virtual Hardware Details.
- Then, in the Boot Options tab, check the boot sequence.
- Now, ensure that the virtual hard disk is the first boot device. Here’s how to arrange the boot order:
- First: Hard Disk (make sure the virtual disk with Windows is selected).
- Second: CD-ROM (if you’re using it for installation).
- Third: Network (optional).
If we are using the command-line tool virsh, we can edit the VM’s XML configuration file:
sudo virsh edit vm_name
Look for the <os> section and modify the <boot dev> elements to ensure the correct device is set to boot first:
<os>
<type arch='x86_64' machine='pc-i440fx-2.9'>hvm</type>
<boot dev='hd'/>
<boot dev='cdrom'/>
</os>
- In this example, the hard drive hd is the first boot device, and the CD-ROM cdrom is the second.
2. Verify Disk Attachment
- Ensure the virtual disk is correctly attached in the Storage tab of Virt-Manager.
- Confirm the disk format is compatible with KVM (e.g., QCOW2, RAW).
- If missing, add the disk via Add Hardware > Storage.
3. Configure the Correct Disk Controller
- Disk Controller Type:
- For older Windows versions, use IDE/SATA during installation.
- For newer versions, use **Virtio** but ensure drivers are installed during installation.
- Switch from Virtio to IDE/SATA in the Storage section if the VM fails to recognize the disk.
4. Repair or Reinstall Windows Bootloader
- Boot from a Windows installation ISO and enter “Repair your computer”.
- Run these commands in the Command Prompt:
bootrec /fixmbr
bootrec /fixboot
bootrec /rebuildbcd
- This will repair the MBR, boot sector, and rebuild the BCD.
5. Disk Initialization and Partitioning
- Boot from the Windows installation ISO and initialize/partition the virtual disk.
- Proceed with the installation, ensuring the disk is the primary boot device.
6. Inspect VM Logs for Errors
- Use virsh to access VM logs:
sudo virsh console <vm_name>
- Check system logs for specific errors:
sudo journalctl -xe
7. Final Steps: Reinstalling Windows
If the issue persists, we may need to reinstall Windows:
- Attach the Windows ISO to the virtual CD-ROM.
- Set the CD-ROM as the primary boot device.
- Complete the Windows installation.
- After installation, ensure the boot order is set to prioritize the virtual hard disk.
Tips for Disk Management in KVM
- QCOW2 is generally recommended for KVM due to its support for features like snapshots and compression, making it a good choice for most use cases.
- Use RAW format when performance is more critical than storage efficiency, as RAW is faster but lacks advanced features.
- Use the Virt-Manager GUI to attach or detach disks easily. Go to the “Add Hardware” option and select “Storage” to add a new disk or edit an existing one.
- Ensure proper device mapping by setting the right device type (Virtio, SATA, IDE) and specifying the correct bus type.
- When adding new disks, always verify the changes in the VM’s storage settings before starting it.
- Use qemu-img to convert between disk formats. For example, convert a VMDK to QCOW2 using the following command:
qemu-img convert -f vmdk -O qcow2 original.vmdk converted.qcow2
- Always create a backup before making format changes to avoid data loss.
- Use Virtio drivers for optimal performance, as they provide higher throughput and lower latency compared to other controllers like IDE or SATA.
- Install Virtio drivers during the Windows installation process or add them later using the Windows device manager.
- For performance-critical applications, consider enabling writeback caching or using dedicated disks for log files to reduce I/O latency.
- Use snapshots to create consistent restore points, especially before making major changes to the virtual machine or the operating system.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
The “No Bootable Device” error in KVM can be addressed by checking the boot sequence, verifying disk attachments, and repairing the bootloader. Ensuring correct configurations and monitoring logs can prevent this error from reoccurring.
In brief, our Support Experts demonstrated how to fix the “No Bootable Device” Error in KVM for Windows VMs.
0 Comments