Add physical partition to QEMU/KVM virtual machine in virt-manager

The solution appears to be passing the whole block device, like /dev/sda or the equivalent from /dev/disk/by-id/, to the <source dev=''> setting.

This allows the Windows setup to see the existing partitions, including the root partition in the host.

There should not be any conflict, as long as:

  • you don't try to mount/modify a partition in the guest that is already mounted in the host; and

  • you don't mount/modify the partition currently in used by the guest from the host, while the VM is powered on.

Regarding the first point, it is of course necessary to unmount the ESP (EFI System Partition) from the host prior to launching the VM. I first wrote a script for that, and then came up with a better solution in the form of a QEMU automation hook. I'm making available at https://gitlab.com/ranolfi/rvirtesp.

What's cool about this is that you can also boot the virtualized OS natively, as in dual-booting, by selecting its new entry in the motherboard's boot menu.

I'm not exactly sure this is "supported". But been using it for almost a year now, without a problem.


If you want to pass a partition as a raw device you can just put /dev/sdaX as a raw image filename it will use it. However if you use ieg sda1 it wont understand which partition it is and consider this partition as a whole disk. If you cant give /dev/sda as source for obvious reasons (using other /dev/sdaY on host machine) you may try iscsi.. But it may also make partition seen as whole disk. Meaning you cant see your files and contents.

To tackle this best option seem to be sharing via samba. Another option is to map the partition on a virtual disk. Another option is share mounted partition as folder, qemu has this option ... Fedora virtio drivers may have this like vmwares vmtools.

I am using ISCSI beyond 4GB/s speeds on virtio network. But i have changed mtu of virbr and virbr-nic0 to 9000 and increased txqueulen. No need to change guest mtu ...

Anyways if you wanna give a try to iscsi here it is :

you first install open-iscsi and tgt

sudo apt-get install open-iscsi tgt

then you configure it

nano /etc/tgt/conf.d/iscsi.conf

put your partition name instead of sdb1 (target name will be different):

<target iqn.2019-11.example.com:lun1>
     # Provided device as an iSCSI target
     backing-store /dev/sdb1                             
     initiator-address 192.168.0.102 
    incominguser iscsi-user password
     outgoinguser iscsi-target secretpass
</target>

then restart the service

sudo systemctl restart tgt 

then check it

tgtadm --mode target --op show

open windows and use iscsi initiator to connect it. Windows will see it as an internal disk ,have fun with high speed block access.

if you add a NAT nic and set it virtio installing virtio redhat drivers it probably will be lightning fast. Do not forget to connect via 192.168.123.XXX Instead of your bridge LAN ip.

Notes: Be careful and first test with a test partition .... iqn must be a-z or 1-9 you can. Leave passwords and secretpass blank There is a standard for these they may not accept space or underscore ...