New
#1
Using Physical Disk in KVM/QEMU Windows VM
Hi there
If you have a spare external (or even internal) HDD / SSD that you want to use as a "Physical" Disk drive say on a Windows VM using native ntfs for exampleso you can unplug it later and connect to a Windows physical machine etc to copy data etc then it's easy enough to do.
1) ensure the disk is not mounted on the Host
2) edit the Windows xml definition file in the libvirt/qemu directory (virsh edit or whatever you use to edit xml files)
and add the disk definition. File is in /etc/libvirt/qemu and the name is the name of your Windows VM.
</disk>
<disk type="block" device="disk">
<driver name="qemu" type="raw"/>
<source dev="/dev/sdg"/> <======= whatever the device is on your system -- lsblk will show devices
<target dev="vda" bus="virtio"/> (for 2nd virtio device then replace vda by vdb etc )
# <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/> this line is generated when the VM is booted so you don't enter this one
</disk>
3) if device hasn't been partitioned or whatever in windows then use in the Windows VMwindows as admin diskpart -> list disk ->select disk nn ->clean ->convert gpt ->create partition primary ->format fs=ntfs quick ->list vol ->selct vol xx ->assign
then exit
Now it's available as native NTFS drive (the GPT step is optional but I prefer using gpt drives)
on the Host you can see now the disk (after powering off the VM is indeed NTFS).
You will need to dedicate a whole disk for this though as a partition isn't a block device.
In this case the windows ntfs data is on /dev/sdg2 and it can be plugged in to any windows system.
This is useful when you need to capture things like WIM image, take system backup , copy large bits of data from the VM - where a USB stick is not large enough etc etc and want to use it on other Windows physical machines - saves defining large virtual disks and the other Windows machines you want to use the data on might not be "network acessible".
Cheers
jimbo