r/VFIO•
TheEdes

Shared hard drive solution

I'm wondering what the best/most common solution people use for storage hard drives (steam library, for example) is. Are there any more reasonable alternatives to using network shares? Windows doesn't manage them very well.

Posted Dec 17, 2019, 3:21 AM UTC

26
BibianaAudris•

If you intend to use the storage on host and guest simultaneously, then no. Network shares is the only way.

Otherwise, you can just put the steam library on a separate virtual disk and mount it on your host.

3
TheEdesOP•

Can you network share the filesystem where the virtual disk is? A separate partition or a separate virtual disk isn't ideal, but it could work.

1
ChekhovsRPG•

I tried something similar. A shared library for multiple VMs running, so you only have to update games once and not on each VM. It can be done, LTT did it for a 10 VM machine, but I never got it to work.

1
vvorth•

There is a solution passthrough a partition as part of manually created block device. It works and i'm using this for several months now.

It only shares partition between VM and Windows on bare metal, you cannot use it simultaneously within host and guest!! I thought i have to mention this, because you did not explain what exactly you need to get at the end.

Can tell you that you have to know what you are doing and understand the risks. It took me 20 minutes of thinking how to do this in a better way - ended up with my own calculations of sectors/bytes to make it the way i want to.

Some fdisk -l info

#real disk

Disk /dev/sdb: 1.84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: TOSHIBA HDWD120
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 89C38D88-9C95-4A7B-93BF-B3995A576AD0

Device          Start        End    Sectors  Size Type
/dev/sdb1        2048     923647     921600  450M Windows recovery environment
/dev/sdb2      923648    1128447     204800  100M EFI System
/dev/sdb3     1128448    1161215      32768   16M Microsoft reserved
/dev/sdb4     1161216  208644536  207483321   99G Microsoft basic data
/dev/sdb5   208646144  209715199    1069056  522M Windows recovery environment
/dev/sdb6   209717248 1887438847 1677721600  800G Microsoft basic data
/dev/sdb7  1887438848 1904216063   16777216    8G Linux swap
/dev/sdb8  1904216064 3907029134 2002813071  955G Linux LVM

#made up MBR part
Disk /dev/loop0: 1 MiB, 1048576 bytes, 2048 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7e564c81

Device       Boot Start        End    Sectors  Size Id Type
/dev/loop0p1       2048 1677723647 1677721600  800G  7 HPFS/NTFS/exFAT


Disk /dev/mapper/qemu: 800 GiB, 858994507776 bytes, 1677723648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x7e564c81

Device                 Boot Start        End    Sectors  Size Id Type
/dev/mapper/qemu-part1       2048 1677723647 1677721600  800G  7 HPFS/NTFS/exFAT

Here sdb6 becomes qemu-part1.

And my script, dont use it without understanding what it's doing. All the math was applied to partitioning, which is inside that /vm/virmbr file, it holds MBR partitioning data i've calculated to make partition start on sector 2048 instead of 209717248 . And yes, original partitioning scheme is GPT and it's okay, because we are touching only data inside partition boundaries.

#!/bin/bash

PARTITION=/dev/disk/by-id/wwn-0x5000039fe5dce8c6-part6
MBRFILE=/vm/virmbr
size=`blockdev --getsz ${PARTITION}`

if [ `losetup -a | grep ${MBRFILE} | wc -l` -eq 0 ] ;
then
    loop=`losetup --show -f ${MBRFILE}`
else
    loop=`losetup -a | grep ${MBRFILE} | awk -F: '{print $1}' | head -n 1`
fi



if [ `dmsetup ls | grep qemu | wc -l` -eq 0 ] ;
then
    echo "0 2048 linear ${loop} 0
2048 ${size} linear ${PARTITION} 0" | dmsetup create qemu
else
    echo already exist
fi

Did this because using shared folders is so much slower, especially on small files.

1
vvorth•

Original wiki topic explains how to make it in a simple way, to represent made up device as big as real with MBR and partition on the same place as it resides on a physical disk. It's much simpler to do.

1
vvorth•

Also make sure partition is used only by one OSE at a time, don't keep it mounted in host and passthrough it to guest - you'll end up with corrupted data.

1