Sunday, January 20, 2013

Weekend Project: Setting up MythTV on Fedora 18


I have had a Windows 7 based media center PC sitting in my living room for the last few years.  Its primary function was to run Windows Media Center, where it recorded and played TV shows using a Ceton Infinitv4 CableCARD tuner, and played back music and videos from rips of my DVDs. 

It has always worked well enough that I wasn't driven to throw it out the window, but over the last year or so it  began to act up.  It was taking longer and longer to become responsive after a cold boot (something like 10 minutes at the worst,) and even starting Media Center was a four or five minute ordeal as it hung with a spinning blue circle, presumably trying to access the file server sitting next to it.  And over the past couple of months it started freezing, blue-screening and even hard-locking under load, indicating some kind of hardware issue. 

The computer was put together in 2007 as my main workstation, and had an Athlon-X2 5200+ with 6 gigs of RAM and two 320G Seagate hard drives.  Since then it's made a transition to a media center PC, as I use my laptop for most of the work I have to do.  Since the system has been so unstable, and because I'm no longer a poor college student, I decided it was time for an upgrade.  Of course, a hardware upgrade means that my Windows installation has a pretty good chance of falling on its face and never recovering.

I've been using Fedora exclusively on my laptop, and decided that I wanted to try to switch to a Linux-based solution for my media center setup as well.  I really didn't feel like going through the Windows 7 re-install/endless upgrade dance after updating the hardware.  And although Windows Media Center always mostly worked, it was never overly impressive.  Windows Media Center always seemed like a second-class citizen to me.  It was quirky, hung a lot, never seemed to get any updates, and its future is pretty bleak considering Windows 8 doesn't include it at all.  I also did some preliminary research on the capabilities of mythtv with my tv tuner, and it looked like it was possible to do everything I was doing with Windows Media Center with mythtv.  So Fedora 18 it was, and my little weekend project took shape.


This is not a step-by-step setup guide for MythTV.  Plenty of those already exist on the web, and I'm not nearly knowledgable enough to write my own.  This is a description of what I managed to set up with my new PC build, the gotchas I ran into along the way, all written from my recollection after the fact.  Hopefully it can fill in some gaps in the available online documentation, and give an insight into what it's like for a somewhat savvy user to set up a mythtv based media center.

New Hardware

The new system I'm setting up has the following:
- Intel i7 3770K
- Asus Maximus V Formula motherboard
- 32G Corsair Vengence DDR3 RAM
- Radeon HD 6450 (fanless)
- 850w Corsair PSU
- 128G OCZ SSD
- 2x 320G Seagate Hard Drives
- Ceton InfiniTV4 CableCARD PCI-e tuner
- USB Windows MCE Remote Receiver


Fedora Installation

Installing Fedora 18 was pretty straightforward once I got the new system put together.  I booted the Desktop Live image off of USB, and immediately clicked the Install to Disk option in the startup dialog.  I was happy that I got an opportunity to see the new Anaconda installer UI, and I really like where they're going with things.

The only hang-up I had was in the disk partitioning screen.  I managed to figure out how to get Anaconda to use a standard layout using ext4 (no LVM or brtfs) but the option to preview the partition layout seems to be gone.  I decided to trust it anyway.  It assigned 500M to /boot, 50G to /, and the rest to /home, which I'm happy with.  The rest of the installation was uneventful, and after reboot and going through firstboot I had a working Fedora 18 system.

Hardware Setup

Fedora doesn't enable TRIM support by default on SSD hard drives.  To do so, go into /etc/fstab, and add "noatime,discard" after "defaults" for all of the entries that are partitions on your hard drive (/, /boot, /home, and swap)

Mythtv uses a local disk as a buffer for live tv viewing, for pausing and rewinding live tv.  I didn't like the idea of it being on my SSD, so I set up one of my hard drives to auto-mount under /media/localstorage.  This hard drive happened to perform a similar function under my Windows setup (it just held TV recordings,) so I created a fstab entry using the UUID (found with blkid.)

Software Installation

I did a system upgrade to install all of the updates, then installed mythtv, mysql, the @development-tools group, and kernel-devel and kernel-headers. 

Ceton kernel driver

Ceton provides a Linux driver for their tuners on ther support site.  I downloaded the source, and followed the installation directions in the README.  The ctn91xx_* devices showed up in /dev, and everything seemed just peachy.

Ceton provides a udev rule that forces their devices to show up in a subfolder of /dev, /dev/ceton.  It does this by changing the NAME attribute.  Unfortunately, Fedora's udev doesn't  allow for changing the NAME of block devices, so a warning is printed and the devices are created in /dev.  Annoying, but an easy fix.  You can change NAME="ceton/%k" to SYMLINK="ceton/%k" in /etc/udev/rules.d/98-ctn91xx.rules.  This will cause udev to create the devices in /dev, and provide symlinks to them in /dev/ceton.  This is important: as I found out later, mythtv is hard-coded to look in /dev/ceton for the ctn91xx devices.

After the ctn91xx module is installed and loaded, you should see that NetworkManager has a new Ethernet interface, and its IP address will be on the subnet.  At this point navigating to in a browser will show the Ceton card's web interface.


Now it was time to set up the mythbackend.  Following the directions on MythTV's website, I set up the MySQL database.  Then I enabled it using systemctl enable mysqld.service, and starting it using systemctl start mysqld.service.

The next step was to run mythtv-setup and set up each of the categories.

Under the General tab, the only change I had to make was to switch the local and master backend IP addresses from to the IP address of the machine.

Under Capture Cards, I set up four individual cards using the Ceton Cablecard tuner card type.  Each has an ip address of, and a card number of 0.  The four capture cards each have tuner numbers from 0 to 3.

The video sources is the next menu option to work with.  I added a new video source using the SchedulesDirect DVB service (and forked over some cash for a subscription).  This service lets you pull down all of the channel listings and guide information for your area.

Under Input Connections I selected each tuner and chose the Schedules Direct video source.  Then I selected Fetch Channels from Listings Source to get a valid channel list for each tuner.  I didn't adjust any of the rest of the settings.

Finally, under Storage Directories, I selected each of the available groups and entered a file path for storage.  I selected a path in my /media/localstorage mount set up earlier so that the storage and caching won't happen on my SSD.

If you're going to be running mythbackend as a system service (e.g. systemctl start mythbackend.service), then that process is going to be launched under the "mythtv" user.  As such, all directories under Storage Directories need to be writable by the "mythtv" user.  Once you decide where you'd like mythbackend to store its files, you'll want to use chown and chgrp to assign ownership of the storage directories to the mythtv user and group.  If you'd like your login user to be able to edit and remove files, you can add your user to the mythtv group.

After everything was done, I set mythbackend to start on boot using systemctl enable mythbackend.service, and started it using systemctl start mythbackend.service.  Then I ran mythfilldatabase, which pulled tv listings from SchedulesDirect without any issues.

There's definitely a lot of other stuff you can adjust in here in terms of recording and transcoding profiles.  It's ok to ignore this stuff as everything is getting set up, but I'll definitely be digging into it after basic TV viewing is working well.


With mythbackend running, I can start mythfrontend and hopefully watch Live TV.  I got the TV working, but there wasn't any sound...

My PC is hooked up to a 5.1 channel receiver via HDMI for audio and video.  The video part obviously works fine, but audio wasn't.  I tried to open the sound settings and set the default output device to the radeon HDMI output, but there was no entry in the devices list.  It turns out that the radeon driver disables HDMI audio by default.  After adding "" to the kernel's bootargs, the device showed up in the list of output devices, and audio output started working properly. Yay!  To make this permanent, I edited /etc/default/grub and added to the end of the list of bootargs.

Remote xbmc

Feeling smug with my problem solving skills, I decided to push my luck and try to set up xbmc on my laptop to stream live TV.  I fired up xbmc, went to the settings->Live TV, and enabled live tv.  Then I enabled the mythtv addon as the livetv provider, and configured it with the IP address of the backend.  After doing so, I was faced with a bunch of pop-ups complaining that connecting to the PVR server failed.

Now I'm on a remote computer, so I need to open up some firewall ports on the backend system to connect to mythbackend and mysql.  Fedora 18 uses a new firewall-config program instead of system-config-firewall, so I had to figure out how to open up some ports in the new program.  First, I selected the "home" zone, and switched the Current View dropdown to Persistent configuration.  I clicked on the "Ports" tab, and added 3306 (mysql,) 6543 and 6544 (mythbackend.)  For the "home" group settings to work, the network interface for my LAN needed to be set to use the "home" group.  After going to Options->Change Default Zones of Connections, I selected my network interface and switched the firewall zone under the General tab to "home". 

After setting the firewall properly, xbmc pulled the channel list from mythbackend, and the Live TV options worked!  Hooray, now I can watch Iron Man 2 on FX in the kitchen while I'm cooking dinner!


The mythbackend with mythfrontend/xbmc setup is already light years beyond the capabilities Windows Media Center provided.  I can watch, record, and transcode live TV, and now I can stream it to remote PCs and use multiple frontend clients.  Unfortunately, setup was still a little bit bumpy.  I'm not sure a newbie could have figured all of this out inside of 6 hours.

I'm excited to play with the functionality I've thus far skipped over (tv recording and automatic transcoding, commercial skip, etc.), get my MCE remote working, and maybe see if I can get an xbmc frontend running on my raspberry pi.