Bobcares

“No Bootable Device” Error in KVM for Windows VMs | Fixed

by | Oct 19, 2024

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.

"No Bootable Device" Error in KVM for Windows VMs | FixedThis 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

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

  1. If we are using Virt-Manager, open the VM’s settings by right-clicking on the VM and selecting Show Virtual Hardware Details.
  2. Then, in the Boot Options tab, check the boot sequence.
  3. 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>

  4. In this example, the hard drive hd is the first boot device, and the CD-ROM cdrom is the second.

2. Verify Disk Attachment

  1. Ensure the virtual disk is correctly attached in the Storage tab of Virt-Manager.
  2. Confirm the disk format is compatible with KVM (e.g., QCOW2, RAW).
  3. If missing, add the disk via Add Hardware > Storage.

3. Configure the Correct Disk Controller

  1. Disk Controller Type:
    • For older Windows versions, use IDE/SATA during installation.
    • For newer versions, use **Virtio** but ensure drivers are installed during installation.
  2. Switch from Virtio to IDE/SATA in the Storage section if the VM fails to recognize the disk.

4. Repair or Reinstall Windows Bootloader

  1. Boot from a Windows installation ISO and enter “Repair your computer”.
  2. Run these commands in the Command Prompt:

    bootrec /fixmbr
    bootrec /fixboot
    bootrec /rebuildbcd

  3. This will repair the MBR, boot sector, and rebuild the BCD.

5. Disk Initialization and Partitioning

  1. Boot from the Windows installation ISO and initialize/partition the virtual disk.
  2. Proceed with the installation, ensuring the disk is the primary boot device.

6. Inspect VM Logs for Errors

  1. Use virsh to access VM logs:

    sudo virsh console <vm_name>

  2. Check system logs for specific errors:

    sudo journalctl -xe

7. Final Steps: Reinstalling Windows

If the issue persists, we may need to reinstall Windows:

  1. Attach the Windows ISO to the virtual CD-ROM.
  2. Set the CD-ROM as the primary boot device.
  3. Complete the Windows installation.
  4. After installation, ensure the boot order is set to prioritize the virtual hard disk.

Tips for Disk Management in KVM

  1. 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.
  2. Use RAW format when performance is more critical than storage efficiency, as RAW is faster but lacks advanced features.
  3. 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.
  4. Ensure proper device mapping by setting the right device type (Virtio, SATA, IDE) and specifying the correct bus type.
  5. When adding new disks, always verify the changes in the VM’s storage settings before starting it.
  6. 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

  7. Always create a backup before making format changes to avoid data loss.
  8. Use Virtio drivers for optimal performance, as they provide higher throughput and lower latency compared to other controllers like IDE or SATA.
  9. Install Virtio drivers during the Windows installation process or add them later using the Windows device manager.
  10. For performance-critical applications, consider enabling writeback caching or using dedicated disks for log files to reduce I/O latency.
  11. 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

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.