MythTV home theater tutorial - backend

GUIDE TO THE WORLD OF MYTHTV HTPC

Backend installation section covers the installation of MythTV backend for Ubuntu 8.04 LTS. The actual installation process is quite easy due to the provided MythTV 0.21 installation packages via Ubuntu package management. However, this tutorial shows you howto set up backend on Xen virtualized linux guest domain.

The host server is running Ubuntu 8.04 LTS and I assume you have Xen running already. If not, refer my virtualization guide on how to do it. Of course you can follow this guide even if you are not going to install backend on virtualized domain. It should not differ too much from installing backend server on normal computer.

1. Creating MythTV backend guest domain
2. Pass DVB card to guest domain
3. Share data with guests using NFS
4. Install and configure MythTV backend

1. Creating MythTV backend guest domain

Setting up guest domains is easy and fast using tool called Xen-Tools. Visit their website and look for examples and FAQ for more information. Xen-Tools uses configuration file located in '/etc/xen-tools/xen-tools.conf' as a default base configuration. Take a look of the file and adjust it according to your preferences. Especially, you want to adjust the following parameters: 'dir', 'dist', 'mirror' and networking options. If you followed my RAID1 tutorial, at least change 'dir' to '/xen'. For example, I changed the following parameters:

/etc/xen-tools/xen-tools.conf ...
dir = /xen
dist = hardy
dhcp = 1
passwd = 1
mirror = http://fi.archive.ubuntu.com/ubuntu/
...

However, you can specify all settings in command line too. Refer xen-create-image manpage for all options. Let's create Hardy Heron guest domain:

$ sudo xen-create-image --memory=256Mb --passwd --size=5Gb --swap=256MB --ide --dist=hardy --dhcp --image=full --hostname=mythbackend

As an output you get information about the guest domain and the image creating process. I'm going to use the created partition image for livetv buffering. That's why I choose such large size for the image. Previously, I had some performance issues with parse disk image and livetv. Therefore, '--image=full' is better option for MythTV backend usage.

To get higher disk performance, it is recommended to use Xen's blktp driver instead of the loopback driver to handle virtual block devices. Therefore, you need to change the resulting configuration file '/etc/xen/mythbackend.cfg'. Under 'Disk device(s)' replace 'file:' with 'tap:aio:' in disk-parameter resulting the following:

/etc/xen/mythbackend.cfg ...
disk = [
 'tap:aio:/xen/domains/mythbackend/swap.img,hda1,w',
 'tap:aio:/xen/domains/mythbackend/disk.img,hda2,w',
]
...

To get more information about the parameters, visit Xen documentation.

Create and start the guest domain:

$ sudo xm create /etc/xen/mythbackend.cfg
Using config file "/etc/xen/mythbackend.cfg".
Started domain mythbackend

If you get errors like the following, you didn't replace 'file:' with 'tap:aio:' few steps backwards.

Error: Device 769 (vbd) could not be connected. losetup /dev/loop0 /xen/domains/mythbackend/swap.img failed

Log in to the guest domain using root as user name:

$ sudo xm console mythbackend

If you don't get login prompt, try pressing 'enter'. While logged in in the virtual machine you need to run:

$ mv /lib/tls /lib/tls.disabled

This is for the same reason as with the host domain: TLS (Thread Local Storage) causes problems with Xen, and you need to disable it. You need to remember to do this after every kernel update. You don't need to do this is you are running a 64-bit host operating system or have non-x86 platform.

You may also want to make sure your server runs the latest software version available:

$ apt-get update && apt-get upgrade

Log out from the guest domain:

$ exit

To detach console and return back to host domain, press 'CTRL+]'. Now you are done with setting up the basic Hardy Heron guest domain. In order to start guest domain automatically at every boot of the host domain, run:

$ sudo ln -s /etc/xen/mythbackend.cfg /etc/xen/auto/