Tuesday 18 February 2014

Xen VM host hard drive access

I've now got my unRAID based Xen system fairly stable but getting my VMs to directly access physical hard drives has been a bit of a learning curve.

I have a Windows 7 VM that runs Mediaportal / ArgusTV server installs with my Octopus tuner cards passed through. This VM is my 'tvserver' and manages all TV scheduling, tuning and streaming.

I also have a Windows 8.1 client that runs MediaPortal and Netflix with GPU and USB passthrough. This drives my lounge TV via HDMI out from an AMD HD5xxx video card.

My biggest issue though has been arranging storage on the Win 7 tvserver for both timeshifing and recording storage.

Both VMs currently boot from .img files stored on my unRAID shares. I could set up another .img file there but don't want to as I'm sure I'll hit performance issues as the unRAID share is parity protected and thus has poor enough write speeds. 9I don't have a cache drive yet as I'm still in test build mode on a basic unRAID licence.


I have two SATA drives that were in my previous physical tvserver system, a 3TB unit for recordings and a 75GB seagate barracuda for timeshifting. My aim was to get these passed through top the Win 7 VM but this proved pretty tricky.

My first attempt was to pop them into an external 2x drive Firewire 800 caddy and connect this to a PCIe firewire card. I passed the card through to the Win 7 VM no problem but the drives were not always recognised. Sometimes the 75GB drive would show up but the 3TB never would. (I suspect the bridgeboard in the external caddy does not support >2TB drives). I tried various combinations of drivers etc. but could never get this to work reliably..

Next, I tried passing my onboard USB 3.0 controller through to the VM and connecting some external USB drives (1TB WD MyPassport and 4TB WD MyBook). Like with the Firewire attempt, the smaller 1TB drive would sometimes show up but the larger drive would stubbornly only show as a USB Mass Storage device in device manager but would not expose itself in any other way to the OS.

Next, I connected up the 3TB and 75GB SATA drives to a SiL based PCIe SATA card and pased that through. This was the worst of all - the VM froze during boot while querying the SiL card. (I understand this chipset is not supported by Xen).

Then a lightbulb: Do I need to pass through the controllers at all? Can I not just access the hard drives directly?

I switched off the passthrough of the Sil card in syslinux, booted up unRAID and started the array. Here's what I see;


There are my two drives sitting outside the array, registered as sde and sdf. I tried adding them to my VM config file as follows;

disk = [
        'file:/mnt/user/Xen/TVserver.img,hda,w',
'phy:/dev/sde,hdb,w',
'phy:/dev/sdf,hdc,w'
]

I booted up the VM and there they were. I formatted them, shared them and registered then in Argus TV as recordings and timeshift respectively. Been running like this for a few days now with zero problems.



Sometimes the simple and obvious solution is the best!
 

2 comments:

Anonymous said...

It looks like you're passing them based on the device name (sda, sdb, sdc, etc).

The problem is, is that those assignments are very trivial. They are assigned by the OS as each drive is detected. So one day if a drive takes a little bit longer to spin up you could see some real issues.

You may reboot Unraid (not just the win7 vm, but unraid itself) one day and you may find your 3TB is sdf, the next time you boot it up it could be sdc. This of course would be problematic in your case.


MediaServer8 said...

100% Agree. In setting this up, I found those device names changing all the time meaning I had to update my VM .cfg file after each boot.

Now that I've finalised the configuration, it's a lot more stable and the two drives in question persist as ssh and ddi from boot to boot.

If I encounter any issues with my TV service after a reboot, checking the device name is my first port of call.

However, if there's a better way to pass the devices through, I'd love to find it.