Virtual Machines with media on a separate data partition

Discussion and Technical Support for general software applications and utilities including OS related issues.
thinmintaddict
Member
Member
Posts: 25
Joined: March 24th, 2011, 6:35 am

Virtual Machines with media on a separate data partition

Post by thinmintaddict »

So to those of you using media servers in Virtual Machines (Particularly Ian), how do you have your VM access your data partition? I know the guide mentions using NFS, but has anyone messed with raw disk access? and if so with what results?

To Ian: what made you choose NFS instead of messing with disk access? do you feel any lag in performance since the data is being bounced through a router and back to the server?
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Virtual Machines with media on a separate data partition

Post by Ian »

What a thought-provoking question sir :clap:

I've not noticed any performance issues using NFS and it never occurred to me that the data was probably going across the network. Is it? I guess it probably is now you mention it. When I get a moment I will try copying stuff back and forth and noting the speed.

I'm intrigued! I'll also explore sharing the drives directly. Not sure it's possible but I'm up for a challenge! :twisted:
thinmintaddict
Member
Member
Posts: 25
Joined: March 24th, 2011, 6:35 am

Re: Virtual Machines with media on a separate data partition

Post by thinmintaddict »

I'm not sure, if you don't see any performance issues, then there's probably no reason to mess with it. Now I'm using Virtualbox, since my CPU doesn't support virtualization, so my experience is slightly different, but the the two things I'd been toying with were:

1. Virtualbox allows raw access to partitions via .vmdk files, but from what I've read, its risky unless you have it set up just right. As I really have never messed with it I'm not sure I want to risk my data with it.

2. Virtualbox allows a "host-only" connection that is entirely virtual, so I could just tell it to act as a 10G connection. I would have to have 2 NICs in the VM though, with one for the data connection and a separate bridged connection for actual network access.

But if you're not seeing a big performance issue, I'll probably just go with your way since it's easy. :-) lemme know how your experiments turn up! I'm going to be messing with everything on monday, so I'll let you know how it turns out.
thinmintaddict
Member
Member
Posts: 25
Joined: March 24th, 2011, 6:35 am

Re: Virtual Machines with media on a separate data partition

Post by thinmintaddict »

Ok, for those who are interested, I did a bit of testing as far as the direct testing vs. NFS was concerned:

I finally got the server all set up in a Virtualbox VM, accessing the data on the host through NFS. I did see a marked decline in access speed when browsing in PS3MediaServer (it was taking almost a full minute to scan a folder of tv shows before displaying the contents vs. the 2-3 seconds it took with the server directly on the host). This is probably because I'm not running gigabit lan yet.

So I did a bit of research into the raw disk access option and it seemed a bit too risky when the OS is on the same physical disk.

But I found a "shared folder" option in Virtualbox that shares a folder from the host to the guest. Ubuntu sees it as similar to NFS, but it doesnt require the data be routed through the network. All i had to do is install the guest additions, than I could mount the folder in fstab as filesystem type "vboxsf" and presto, it was as fast as I was used to.

If anyone is interested I can post a step-by-step how-to in this thread.
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Virtual Machines with media on a separate data partition

Post by Ian »

Thanks for reporting back. You beat me to it! I've not had the chance to try it out yet but the more I thought about your theory the more I was sure you were correct. And it seems you were :clap:

When I was researching the use of virtual machines I did read a few warnings about the risks of "sharing" resources such as drives. From memory the problem comes when one OS doesn't realise another OS is reading/writing to a drive and so the first OS won't "wait" for the 2nd OS to finish. The end result of this is file corruption. :roll:

I've come across many folk whose hardware does not support true virtualisation so if you could spare the time to explain how you get it working it would be great :thumbup:

Thank you.

Ian.
thinmintaddict
Member
Member
Posts: 25
Joined: March 24th, 2011, 6:35 am

Re: Virtual Machines with media on a separate data partition

Post by thinmintaddict »

As raw disk access as we previously discussed provides too much risk to our precious media, and NFS seems to cause our performance to take a hit, the solution is to use VirtualBox's "shared folder" functionality. when you use this with a Windows Guest, it shows up as a Samba Share. When you use it with linux, it does something more interesting. the shared folder becomes a new type of mount for the operating system, similar to NFS. the difference is that it doesn't route through the network, but instead talks directly to the host OS using special drivers provided by VirtualBox Guest Additions. Set-up is actually quite simple:

Alright, for the sake of this guide, I'll be assuming a few things:
a. You have installed VirtualBox on your host (My host is Ubuntu Server 10.10)
b. You have set up your guest VM the way you like, again with Ubuntu Server 10.10 as the OS.

To add the shared folder to the VM, you can pass it along with the VBoxManage command. In PuTTY for you Windows users, or through ssh for the linux users among us run this command as the user that controls your VMs on your Host Machine:

Code: Select all

VBoxManage sharedfolder add NameofVM --name whateveryouwanttonameit --hostpath /path/to/folder/to/share
my media resides in "/media/UserData" and my VM is called "MediaServer" so for me the command looked like this:

Code: Select all

VBoxManage sharedfolder add MediaServer --name UserData --hostpath /media/UserData
note that the "--name" can be whatever you like, it doesnt need to correspond to the name of the folder. I just thought it made sense to do it that way.

Now, we need to make it so the Guest can mount it. As I said, this is done through VirtualBox Guest Additions. installing them is pretty easy in ubuntu, as they are pre-packaged and in the repositories for our use, so we can install them with apt-get.
this time we need to pass commands to the guest, so get to a terminal however you access your Guest OS (PuTTY, ssh, or rdesktop) and pass along this command:

Code: Select all

sudo apt-get install virtualbox-ose-guest-x11
after this, you need to restart the guest OS, so the changes can take affect:

Code: Select all

sudo reboot
next we need to create the mount point, like any other mount:

Code: Select all

sudo mkdir -p /where/to/mount/it
I chose to mount it in the same place it was on the host to make things easy on myself, so I ran:

Code: Select all

sudo mkdir -p /media/UserData
now we can mount the shared folder with this command:

Code: Select all

sudo mount -t vboxsf nameyougavefolderearlier /path/to/mount/to
so in my example, the command is:

Code: Select all

sudo mount -t vboxsf UserData /media/UserData
this will mount it as owned by root:root. this isn't terribly important as the folder will naturally have rwxrwxrwx permissions, but if you want to own it as a different user you can:

Code: Select all

sudo mount -t vboxsf -o uid=1000,gid=1000 UserData /media/UserData

and to mount it automatically at boot you just add this to /etc/fstab:

Code: Select all

#VirtualBox Shared Folder
UserData /media/UserData vboxsf defaults 0 0
or

Code: Select all

#VirtualBox Shared Folder
UserData /media/UserData vboxsf uid=1000,gid=1000   0 0
That's it! you should be all set up.
Speccy
Member
Member
Posts: 5
Joined: February 5th, 2011, 8:17 pm

Re: Virtual Machines with media on a separate data partition

Post by Speccy »

Nice work thinmintaddict, just the thing i've been looking for!!
thinmintaddict
Member
Member
Posts: 25
Joined: March 24th, 2011, 6:35 am

Re: Virtual Machines with media on a separate data partition

Post by thinmintaddict »

No problem! glad i could help :-)
Mr. Noob
Member
Member
Posts: 2
Joined: February 14th, 2011, 1:03 pm

Re: Virtual Machines with media on a separate data partition

Post by Mr. Noob »

+1. My Server does not support true virtualization so this guide will come in very handy.

thx thinmintaddict :clap:
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Virtual Machines with media on a separate data partition

Post by Ian »

Yeah, great write-up thinmintaddict. Thank you very much indeed :thumbup:
Post Reply