WARNING!! You may lose all of your data stored in the partition if you don't follow these steps correctly. Backup important data and use at your own risk. I strongly recommend you to start with an empty partition, or a loopback device backed by an empty image file.
This script will allow you to pass existing NTFS partition to windows running on KVM, which is also readable by bare-metal windows.
You can't simply pass existing NTFS partition to the VM since guest OS see the partion as a whole disk device with a partiton table.
The trick used here is sandwiching the partition with 2 loopback devices using software RAID (MD) device built with mdadm --build --level=linear
. First device stores main partition table in the beginning of disk, and second one stores backup table in the end of disk.
This idea is originally posted by a redditor ws-ilazki, I just converted it to the script: https://www.reddit.com/r/VFIO/comments/j443ad/pass_through_a_partition/g7hn38z/
Trim from guest OS seems to be not possible. I