Bobcares

How to Use KVM to Boot Windows from a Physical Disk

by | Oct 27, 2024

Learn how to use KVM to boot Windows from a physical disk. Our KVM Support team is here to help you with your questions and concerns.

How to Use KVM to Boot Windows from a Physical Disk

Did you know that running Windows from a physical disk within a KVM environment lets us use an existing Windows installation on a physical hard drive as the virtual machine’s disk?

How to Use KVM to Boot Windows from a Physical Disk

In fact, this technique lets us run Windows virtually without creating a new disk image, benefiting from direct hardware access and improved performance.

In a typical KVM setup, a virtual machine uses a disk image file, such as QCOW2 or RAW format, as its virtual hard disk. However, with KVM, we can use a physical Windows installation directly from the physical disk—be it an internal drive or an external one.

This approach is called disk pass-through. It allows the VM to access the disk directly, providing full read and write access. Changes made in the VM will affect the physical installation.

An Overview:

Why Use a Physical Disk with KVM?

  • Direct disk access can significantly improve performance compared to using virtual disk images, especially for I/O-intensive tasks.
  • This setup leverages the full hardware capabilities, including specific drivers and hardware optimizations.
  • It simplifies the migration of a physical Windows installation to a virtual environment, as there’s no need to create or manage virtual disk images.

Before getting started, we need to meet these requirements:

  • Make sure KVM, QEMU, and related virtualization packages (e.g., libvirt) are installed on the Linux host.
  • Have a functioning Windows installation on a separate physical disk.
  • Always back up important data before proceeding.
  • We will need administrative privileges on the Linux host.

How to Boot Windows from a Physical Disk in KVM

  1. Run the following command to identify the disk containing the Windows installation:

    lsblk

    This command lists block devices, displaying drives and partitions. Locate the device name for your Windows disk (e.g., `/dev/sdb`).

  2. Before passing the disk to KVM, unmount it from the Linux host using:

    sudo umount /dev/sdb*

    This step ensures no partitions on the disk are in use, preventing data corruption.

  3. Then, make sure that KVM (or the QEMU process) has permission to access the disk. So, check the current user groups:

    groups

    If we are not part of the KVM group, we have to add ourself to it:

    sudo usermod -aG kvm $USER

    Then, log out and back in for the changes to take effect.

  4. Now, we have two options for configuring the KVM virtual machine: using Virt-Manager (GUI) or virsh (CLI).

Option 1: Using Virt-Manager (GUI)

  1. First, open Virt-Manager from the Linux desktop.
  2. Now, ti is time to create a new VM. So, select “Import existing disk image.”
  3. Then, choose the physical disk instead of an image file.
  4. Next, specify the path to the physical disk (e.g., `/dev/sdb`).
  5. After that, assign CPU and memory resources.
  6. Now, set the boot mode (EFI/BIOS) to match the Windows installation.
  7. Finally, complete the configuration and start the virtual machine.

Option 2: Using virsh (CLI)

  1. First, save the following XML as `win10-physical.xml` :

    <domain type='kvm'>
    <name>Windows10</name>
    <memory unit='KiB'>8192000</memory>
    <vcpu placement='static'>4</vcpu>
    <os>
    <type arch='x86_64' machine='pc-i440fx-2.11'>hvm</type>
    <boot dev='hd'/>
    </os>
    <devices>
    <disk type='block' device='disk'>
    <driver name='qemu' type='raw'/>
    <source dev='/dev/sdb'/>
    <target dev='vda' bus='virtio'/>
    </disk>
    <interface type='network'>
    <model type='virtio'/>
    </interface>
    <input type='mouse' bus='usb'/>
    <input type='keyboard' bus='usb'/>
    <graphics type='vnc' port='-1'/>
    </devices>
    </domain>

     

    We can adjust paths as needed.

  2. Then, define the virtual machine:

    sudo virsh define win10-physical.xml

  3. After that, start the virtual machine:

    sudo virsh start Windows10

Install Drivers for Enhanced Performance

To improve the VM’s performance, we need to install Virtio drivers for Windows, which optimize disk I/O and networking. Additionally, we can use SPICE with QXL drivers for better graphics performance.

Potential Issues

  • Windows may require reactivation due to hardware differences when running in a VM.
  • While faster than virtual disk images, performance may not be as high as a native Windows installation, especially for graphics-heavy workloads.

Furthermore, if we plan to dual-boot between native Windows and KVM, we have to address potential driver conflicts.

Also, modifying disk configurations always carries risks. So, we need to back up important data before making changes.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Booting Windows from a physical disk in KVM is an effective way to enhance virtual machine performance and leverage existing installations. With the above steps, we can successfully set up and run Windows directly from a physical disk within a KVM environment.

In brief, our Support Experts demonstrated how to use KVM to boot Windows from a physical disk.

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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF