Recording to a NAS with Windows7 Media Center
For the last few years, I’ve wanted to move the Windows7 media center from a physical PC onto a virtual machine.
To accomplish this, I knew that I needed a few things setup and ready to go first.
- Virtual Machine Hypervisor that was stable and efficient
- TV Tuner device that worked from inside a VM
- Storage to hold the recorded files.
The Plan
KVM is the hypervisor that I want to use. The other options aren’t server-class or have proprietary licenses which make them unattractive for home use to me. KVM is stable and easy to use. VMs running inside KVM basically have unlimited uptime. I’ve been running VMs inside KVM for over a year and for the last 4 months in production mode. I’m convinced. It is ready for constant use.
The TV tuner used is a networked HD-Homerun HDHR3 which has dual QAM tuners. This device just needs to be someplace on the network to be accessed. The wired ethernet network here is all GigE, 1000base-tx, so pushing 10 HD streams isn’t an issue. With these devices, there isn’t any worry about PCI cards or USB passthru support in a VM. The HD recordings from the HDHR3 device are beautiful. I’ve been using this device on a physical PC for over 6 months with ZERO issues. It is definitely ready for use. They make CableCARD tuner devices with 3 and 6 tuners, so if you have encrypted cable, you probably want those models instead.
Storage was the last issue. When building a virtual machine, the goal is to provide the minimum storage required to accomplish the task. For most applications, this is 1 or 2GB of data storage. Most Linux servers running inside a VM here are 4GB total – OS, Apps and data. With video media, the storage requirements are completely different. I’ve seen HD movies require over 20GB alone, so there needs to be 60+GB available for recorded TV shows. These are conflicting issues that need to be solved. Before attempting this migration, I tested a few different video storage solutions.
Any Issues?
Before doing all the work to setup a new VM, connect the TV tuners to that VM, and setup storage, I figured I do a quick storage test to verify that having a Recorded TV/ folder on the network would work.
1st Attempt
Since I’m running the VM on Linux and I have a Linux storage server, I figured that using Samba to share some dedicated storage – about 400GB would be sufficient. I setup a samba share:
[7mc]
hosts allow = 127.0.0.1 192.168.10.1/24
hosts deny = 0.0.0.0/0
path = /Data/7mc
comment = 7mc
browseable = yes
read only = no
create mask = 0664
directory mask = 0775
valid users = %S
This shared the /Data/7mc storage as “7mc”, limits it to a specific subnet and requires user authentication to access. Simple.
For safety, I also mapped this disk to X: . If I don’t need the drive mapping, I can remove it, but it is better to just have it already. That was my though.
I logged into the normal 7MC box and verified that the storage was available as \\server\7mc, it works. Nice.
Next the setting inside 7MC Libraries was changed for the Recorded TV/ location. I restarted the 7MC related services and tried to record a show. No good. The recorded show was still written to d:\Recorded TV – a local disk. It was time for some *google-fu.
2nd Attempt
According to google, I needed to edit the registry.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Service\Recording]
“RecordPath”=“X:\\7mc\\”
“LastRecordPathSet”=“D:\\Recorded TV\\”
and add the new folder to the “watched folders” list. I also moved the old d:\Recorded TV to d:\Recorded TV-orig, so the programs wouldn’t be temped to use it this time. Saved the registry keys, restarted 7MC services, opened 7MC and tried to record a show. There was an error message notification with a huge negative number (like -2342934858778443534) … it happened so quickly that I couldn’t copy it down and there was no way to get more exact information. In short, it wasn’t working. Just for my sanity, I checked the remote folder for any files – none were created.
One of the links said that mapped drives are per-user, and since media center runs under a different account, I needed to use the UNC … \\server\7mc instead. Tried that. No joy. Perhaps it was a permissions issue?
3rd Attempt – need to try
I could create a new user account with zero network privileges and verified that it could connect and write to the network storage. With Linux controlling the storage, user permissions can be a hassle when coming from a non-POSIX system like Windows.
4rd Attempt – need to try
Ok, so the storage is shared, but perhaps 7MC runs under a service account – that would be smart, since we all want TV shows recorded even when nobody is logged into the machine. But which service account is being used? Certainly not Administrator, right? Time for some more google-fu. Well, at this point, my google-fu is weak. I didn’t find the answer, but I did find a few avsforum posts and support.microsoft.com posts which claim that using remote storage works fine and other posts that say you can’t do it (MS answer).
5th Attempt – need to try
iSCSI can be used according to the avsforums. It seems that Windows7 includes the iSCSI client, so this shouldn’t be too difficult. Having a SAN is nice. T
his method dedicates storage to a single server. If I’m going to do that, it would be easier to simply create another virtual HDD for the VM and connect it. That’s what I decided to do. It worked.
Since these recorded shows were not on a NAS yet, I scripted a little perl to teracopy move from the dedicated storage to a NAS every few hours. In this way, I can be certain that I never run out of storage available for recording shows.
So basically I set out to record TV with Windows7 Media Center and store the recorded file to a NAS. I failed at that.
Remaining Issues – HDD Performance
I need to write up the details about the final setup, but at this point there is still a HDD performance issue that I need to resolve. The read performance from the Vhdd is actually pretty fantastic. It is almost native hardware speed. OTOH, the write performance is really poor – about 10x less than native. I need to do more research on this. Hopefully, it is just that I need slightly newer virtio storage drivers for Windows. I know that the newest virtio drivers will not work due to kernel differences on the hypervisor side. More on this later.