KVM how to add a physical Internal (windows) disk to a VM


jimbo45

Well-known member
Pro User
VIP
Local time
12:19 PM
Posts
4,033
Location
Hafnarfjörður IS
OS
Windows XP,7,10,11 Linux Arch Linux
Hi folks
I'm messing around trying to convert a Windows2Go system back to a physical one -- So I needed to copy the the windows to go system back to an internal HDD - and I'm running my OS (LINUX) the VM (which was defined originally as a WintoGo system so if just restored to an internal drive Windows still thinks its on a USB device.

So the problem is - how to copy the VM to a physicall windows disk -- once I've got a physical disk initialised in the VM then standard tools e.g macrium can clone it and I can work on converting it back to a "standard" windows system. I really don't want to re-install fresh Windows when I don't need to.

You can't do this specifically in the GUI - you need to enable xml editing from the Virtual machine manager and then simply add this in the appropriate place
<disk type="block" device="disk">
<driver name="qemu" type="raw"/> [this mens guest physical I/O routines used and not "Virtual ones"]
<source dev="/dev/sda"/> [your partition / disk]
<target dev="vdb" bus="virtio"/>
</disk>

save and apply and then ensure that's NOT the boot disk and boot your VM

Now in Windows GUEST you can see the disk drive

Screenshot_20230814_151707.png


the virtual machine manager will show it as :

Screenshot_20230814_151927.png


There might be easier ways but if you've only got at the moment one spare machine with an empty HDD and an external device running your KVM system plus a Windows VM - then you have to use the available tools.

Of course if I were at home I could just restore an image but I'm away currently !!!! and I need a Windows (physical) machine !!!!

Cheers
jimbo
 
Last edited:

My Computer

System One

  • OS
    Windows XP,7,10,11 Linux Arch Linux
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7
Thanks for the tip!
It's very comforting that it works like this.

<disk type="block" device="disk">
<driver name="qemu" type="raw"/> [this mens guest physical I/O routines used and not "Virtual ones"]
<source dev="/dev/sda"/> [your partition / disk]
<target dev="vdb" bus="virtio"/>
</disk>

I would try it with this as well:
Code:
<target dev="sda" bus="sata"/>
Should work in any cases.

But doesn't seem that important if it works with virtio; then Windows sees it if you have the virtio-win drivers installed.

Only other alternative I see is via a disk in an external USB hdd enclosure (different than topic's internal disk) but then it gets added through "USB Host Device" hardware.
Works fine with a lot of SATA / NVMe / USB external drives.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC
    CPU
    i3 8109U
    Motherboard
    Intel
    Memory
    16GB DDR4 @2400
    Graphics Card(s)
    Intel Iris Plus Graphics 655
    Sound Card
    Intel / Realtek HD Audio
    Monitor(s) Displays
    LG-32ML600M
    Screen Resolution
    1920x1080
    Hard Drives
    Intel SSD 250GB + Samsung QVO SSD 1TB
    PSU
    Adapter
    Cooling
    The usual NUC airflow
    Keyboard
    Logitech Orion G610
    Mouse
    SteelSeries Rival 100 Red
    Internet Speed
    Good enough
    Browser
    Chromium, Edge, Firefox
    Antivirus
    Windows Defender
  • Operating System
    CentOS 9 Stream / Alma / Rocky / Fedora
    Computer type
    Laptop
    Manufacturer/Model
    TOSHIBA
    CPU
    Intel i7 4800MQ
    Motherboard
    TOSHIBA
    Memory
    32GB DDR3 @1600
    Graphics card(s)
    NVIDIA Quadro K2100M
    Sound Card
    Realtek HD Audio
    Monitor(s) Displays
    Built-in
    Screen Resolution
    1920x1080
Thanks for the tip!
It's very comforting that it works like this.



I would try it with this as well:
Code:
<target dev="sda" bus="sata"/>
Should work in any cases.

But doesn't seem that important if it works with virtio; then Windows sees it if you have the virtio-win drivers installed.

Only other alternative I see is via a disk in an external USB hdd enclosure (different than topic's internal disk) but then it gets added through "USB Host Device" hardware.
Works fine with a lot of SATA / NVMe / USB external drives.

Sometimes you need to "Convince" Windows (in the Guest of course) that it's running on an internal HDD or you might find Windows won't update because it thinks it's on an external drive and running as a WintoGo system which has limitations.

If you attach a USB drive as a USB device then Windows knows it's external.

However if your external usb is say attached as /dev/sdx as a physical disk then Windows is"poodlefaked" into thinking that /dev/sdx is an internal drive and windows will install / update without a problem.

I usually update the physical windows install from within the VM - then boot on real machine and update drivers if necessary. You can use this method also to run on non supported hardware too.

Cheers
jimbo
 

My Computer

System One

  • OS
    Windows XP,7,10,11 Linux Arch Linux
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7

Latest Support Threads

Back
Top Bottom