Installing MythTV on Fedora

From MythTV Official Wiki
Revision as of 09:21, 12 September 2014 by Darcy (talk | contribs) (Set $KVER variable: Removed KVER as not used anywhere else in wiki)

Jump to: navigation, search

This "How-To" guide is for installing MythTV on the latest release of Fedora.


Time.png Outdated: The information on this page may no longer be relevant to the current release of MythTV, 30.0. Please consider helping to update it.

Important.png Note: This installation guide is currently undergoing an overhaul to remove outdated procedures and reduce the overall size


Introduction

This guide is shamelessly based on Jarod Wilson's how to guide, which no longer exists.

Fedora provides updates for a release until two releases after that. At the time of this writing, the current release is Fedora 20, which means support for Fedora 18 was discontinued a month after Fedora 20 was released. Thus, it makes sense to update to the latest release at least every other version, if not every version.

You are welcome as a MythTV user and general wiki participant, to add to, and modify this document that will help the community the best way possible.

Getting Fedora

ISO images

The latest version of Fedora can be downloaded from the Fedora Download Page. Note that the Desktop edition has the default GNOME Desktop available whereas the DVD install has alternative desktop environments available. For the remainder of this installation guide, the default desktop environment GNOME will be used to avoid confusion. Other desktop environments should be similar.

Physical media

CD-ROM and DVD-ROM discs can be purchased from online and local vendors.

Installing Fedora

The official Fedora 20 installation guide is an excellent place to start when installing Fedora. There are a few modifications on the procedure given in the official documentation; user creation and filesystem partitions. The notes in this wiki will detail an installation from the Live Desktop Media. It should be noted that additional desktop environments are also available if the GNOME 3 desktop is not suitable. Some alternatives are listed in the Fedora spins page and installation is detailed here. Desktop environments other than GNOME 3 are outside of the scope of this wiki for brevity.

Date/Time

During installation you should adjust the date and time of the machine to the current date and time. To do this ensure the Network Time slider is set to on under the Localization options. Making sure the system is running to the correct time is important for timely scheduling of recordings.

Filesystems

Among the MythTV community, it is highly recommend to use a custom partitioning scheme rather than auto-partitioning with a dedicated /video (or similar) partition for storage of all your recordings. If possible, for best efficiency, the video partition should be on a drive physically separate from the operating system partitions. Software RAID and LVM for your video partitions will only slow it down and should be avoided. LVM is no longer necessary for MythTV due to Storage Groups.

Currently EXT4 format is the default in Fedora and other distributions. Here's a partition setup example:


Partition Mount Point Size Format
/dev/sda1 /boot 500MB ext4
/dev/sda2 swap same as RAM (ex: 4096MB) swap
/dev/sda3 (for the OS) / 8-12GB ext4
/dev/sda4 /home 8-12GB ext4
/dev/sda5 /video Remainder ext4

User creation

When prompted during the installation, create a non-administrator user on the system with the username "mythtv". You can set the password for this user to anything you want. This should be a Strong Password that is different than the root password.

First boot

At this point Anaconda will ask you to remove the installation media from the drive and reboot the system. Once your system has finished rebooting you will be prompted to do some final configurations and be given a short tour of GNOME 3.

Gnome Terminal

Tasks in Linux are performed with greater ease through the command line and are therefore required in this How-To. In GNOME 3, the terminal is accessed by going to Activities and typing 'terminal' in the search box.

Some commands need to be run as the mythtv user, and some commands need to be run as the root user. The boxes below will indicate with a prompt which user should run the command. Commands with a "$" prompt should be run as the mythtv user. If you see a command that starts with a "#", you will need to use the su command to become the root user.

To execute commands as the root run "su -" and enter the Fedora root password.

[mythtv@machine_name ~]$ su -
Password:
[root@machine_name ~]#

Notice the way the username changes from mythtv to root and the prompt changes from "$" to "#". Be sure you run all of the following commands as the correct user. If you do not, you will likely run into problems sooner or later. To become the mythtv user again, type "exit".

[root@machine_name ~]# exit
logout
[mythtv@machine_name ~]$

Your screen should clear, and your prompt should be a "$" again. If this is not the case, keep typing "exit" until it is. You can copy and paste text in the terminal by using 'Control-Shift-C' and 'Control-Shift-V' respectively.

Update Fedora

Firstly get your system fully updated. Simply run the command from terminal:

# yum update

When you see the Transaction Summary, you will need to press "y" to begin downloading the packages.

 Transaction Summary
 =============================================================================
 Install      20 Package(s)
 Update      79 Package(s)
 Remove       0 Package(s)
 Total download size: 902 M
 Is this ok [y/N]: y

After the update has finished, reboot your computer for the effects to take place.

Network configuration

On the Network Configuration screen (Activities -> Network Connections), setting a static IP address is highly recommended (could be either a static, or statically mapped DHCP address). It really isn't a huge deal if you only have one Myth box (though you probably don't want MythWeb to be a moving target), but it could cause major headaches once you have more than one machine, since non-primary systems won't know where the master backend is, if the address changes.

Firewall

A basic MythTV box should not have any problems running with the default Public zone firewall settings. If there are issues with service access you will at the very least want to enable SSH, Secure WWW (HTTPS) and WWW (HTTP) checkboxes to enable those services under the appropriate Firewall zone with the Permanent configuration.

If you plan to run separate front end and back end servers you will need to allow those ports through on under "Other Ports". Add TCP ports 6543 and 6544 to allow the MythTV protocol access through the firewall and TCP 3306 for mysql.

SELinux

It is strongly recommended that SELinux is run in "permissive" mode by editing /etc/selinux/config. There are a few things that will not work properly if you set SELinux to "enforcing" such as the MythWeb plugin. If you think you might want to run with SELinux in enforcing mode in the future, choose the permissive mode which will only warn you of problems. This will enable you to quickly and easily set SELinux to enforcing mode at a later time.

Fedora 20 comes with the excellent setroubleshoot tool which will notify of denials whilst permitting you to leave SELinux enabled on your system. Audit2allow in permissive mode can also be used to catch SELinux denials and rules can be automatically created to allow program access in the future.

If you prefer running enforcing SELinux with mythweb, the following commands may be helpful:

$ /usr/sbin/setsebool -P httpd_can_network_connect=1
$ /usr/sbin/setsebool -P httpd_ssi_exec=1
$ chcon -R -t httpd_sys_content_rw_t /var/www/html/mythweb/data
$ semanage fcontext -a -t  httpd_sys_content_rw_t /var/www/html/mythweb/data

Fedora setup

The next section will require you to be logged in as the mythtv user.

Configure package repositories

Configuration of yum is needed to use the RPMFusion package repository. Follow the links below and install the RPMs for the latest version and correct architecture for your system. It should be noted ATrpms can also be used as an alternative to RPMFusion but they cannot be used simultaneously and ATrpms will require the priority of the repo file to be set higher as to not conflict with the official packages.

RPMFusion

 http://rpmfusion.org/Configuration

Note: You will need to download the packages rpmfusion-free-release and rpmfusion-nonfree-release and install with GNOME Software or rpm -ivh *.

Many MythTV installations require additional kernel modules to make all the hardware work. When installing firmware/drivers such as the proprietary nVidia graphics drivers the akmod or kmod packages can be chosen. The akmod packages automatically check and compile the driver on boot if required. This incurs a small penalty of having to install development packages. The kmod packages are built against a specific kernel version and if a new kernel is installed without the corresponding kmod then errors on boot may occur. Therefore for system safety the akmod packages are recommended.

NVIDIA

We recommend you use a card that supports VDPAU for video acceleration. See http://www.mythtv.org/wiki/VDPAU.

You can install binary drivers from NVIDIA, but in most cases it's simpler to use yum to get and install them from RPM Fusion. It is essential to get the proper version of the drivers. Start by running

/sbin/lspci -nn | grep 'VGA\|NV'

This will give you the chipset name and the PCI id (which is after the colon inside the bracket set before the rev number). Compare these to the NVIDIA docs. Unless your card is in one of the legacy lists, you can install the latest drivers. If you have one of the legacy products you will have to modify the yum package name to get the proper drivers. The newer drivers will NOT work on "legacy" cards.

To install from the RPMFusion repository, run:

# yum install akmod-nvidia

If you need a legacy package from RPM Fusion consult the available packages table at http://rpmfusion.org/.

Note for FC13 Users

This thread may have useful information: http://forums.fedoraforum.org/showthread.php?t=204752 (You may need to add vmalloc=256m after the nouveau blacklist on the grub.conf kernel line.)

If X does not start, consider hitting <ctrl> <alt> <F2> to get to a login screen.

Then use the following to see if the required components are loaded:

glxinfo

rpm -qa |grep nvidia

cat /etc/X11/xorg.conf

To see if the nouveau blacklist worked try:

lsmod | grep nouveau

To see if the nvidia driver loaded try:

lsmod | grep nvidia

If glxinfo returns nothing.

Try:

nvidia-config-display disable

nvidia-config-display enable

Or try using nvidia settings:

nvidia-settings

Note for FC14 Users

Edit /boot/grub/grub.conf as root and add the following to the end of the kernel line before rebooting:

rdblacklist=nouveau vga=0x318 vmalloc=256M

NOTE: Depending on your hardware, you may not need to set the vmalloc amount. However, many systems need this, and it's easier to experiment with taking it out later if needed, after you know everything is working. For more info, see the link above in the FC13 section.

After rebooting with the new driver, if you're using GNOME, you may find your font size has shrunk to be almost unreadable. To fix this, select System->Preferences->Appearance from the menus, choose the Fonts tab, click Advanced, then change the DPI to a larger value such as 96.

Note for FC15 Users

These notes apply for kmod-nvidia. As of November 2011, these drivers install on FC15 without problems, even making the necessary configuration updates to suppress nouveau. If you still experience problems, the following notes may be helpful.

Follow the steps above to install kmod-nvidia, and ensure nouveau is not being used (with lsmod, above). You may need to manually run dracut as well to change your initramfs to keep nouveau from loading, more detail can be found on http://blog.bodhizazen.net/linux/how-to-install-the-nvidia-driver-on-fedora-15 and http://forums.fedoraforum.org/showthread.php?t=204752

Notes for Gnome 3 on FC15

You may find you lose plymouth (graphical boot), and if Gnome 3 fails to load properly, you may find issues when you enter the GUI (hangs without fully loading, stops at splash, only mouse control after log in). One noted item from the fedoraforum post above tries to address a bug ( https://bugzilla.redhat.com/show_bug.cgi?id=694918 ) related to gnome-shell, it offers the advice of trying:

su
grep gnome-session-c /var/log/audit/audit.log | audit2allow -M nvidiaisbroken
semodule -i nvidiaisbroken.pp

If gnome still fails to load completely, you may attempt to force Gnome 3 fallback, discussed in the section "Is there a procedure to always use fallback mode?" @ http://fedoraproject.org/wiki/Features/Gnome3#Comments_and_Discussion

Should the resolution settings not pass properly into the gnome display preferences, configure your video settings in an x session (e.g. gnome terminal) by running:

nvidia-settings

Note for FC16 Users

Installing VDPAU drivers and disabling nouveau is similiar in FC16. You may be able to minimize the number of steps given the guide @ http://www.if-not-true-then-false.com/2011/fedora-16-nvidia-drivers-install-guide-disable-nouveau-driver/

Sound setup

Fedora uses PulseAudio by default, as do many Linux distributions. MythTV does work with Pulseaudio. However, if you wish to remove it, you can run the following command to revert to ALSA.

# yum remove alsa-plugins-pulseaudio

Remote desktop

Please ensure that only local access is allowed for the VNC ports for security reasons.

The remote desktop in GNOME can be enabled through the GUI from Activites > System Settings > Sharing. Turn on Screen Sharing and Allow Remote Control. It is strongly recommended that a secure password is set. After the remote desktop has been enabled the corresponding ports need to be allowed through the firewall (VNC-Server checkbox).

Install MythTV

MythTV has numerous required dependencies to function correctly, which are automatically taken care of with one simple command, using either repository:

# yum install mythtv

You may run into some problems with dependencies. These can usually be resolved by removing the offending package and re-running the above command. Dependency issues can be mitigated be keeping additional (third-party) repositories to a minimum. MythTV on Fedora requires only the default repositories plus RPMFusion to fulfil all requirements.

Setting up drivers/Modules

Install capture card drivers

Some capture card drivers have been included by default with Fedora. The IVTV drivers required for the PVR-150/250/350 and the drivers required for the Hauppauge HD-PVR 1212 are included, for example.

Fedora may also automatically detect and install the needed firmware for some TV cards (e.g. Hauppauge HVR-1600). If this occurs you will see a balloon in the top-right corner shortly after login, asking you to install needed firmware for devices. You can click the link in the balloon to complete the installation, or install the firmware manually. If manual installation is required then it is best to refer to linuxtv.org for support information.

Remote control

Many remote control mappings have been moved to the kernel but manual key mapping may still be desired. This can be achieved by installing the v4l-utils package for the ir-keytable command.

# yum install v4l-utils

Once v4l-utils has successfully installed you can run the following command to capture the input and button name of each keypress.

ir-keytable -t

The mappings can be changed by finding your corresponding keymap in /lib/udev/rc_keymaps. Be sure to comment out the original mappings in case an error is made during the file modification.

If your remote control does not exist in the kernel then you will have to install LIRC.

Install LIRC

Note for Fedora 12 + users the default LIRC socket file name has changed to /var/run/lirc/lircd , so you will need to update MythTV Settings -> General from /dev/lircd ->/var/run/lirc/lircd and then restart mythfrontend.

Check first if lirc is installed before proceeding below...(eg find / -name lircd)

# yum install lirc

This will install the Linux Infra-Red Control package. This is a daemon which translates infra-red key presses into keyboard events, therefore you will need to configure your remote control accordingly. Some examples of the lircrc file can be found under /usr/share/doc/mythtv-$VERSION/

Setup MariaDB

In Fedora 20, mySQL has been replaced with MariaDB but backwards compatibility is maintained such that the following commands should still be applicable. We'll need to enable MySQL to load at startup, set some passwords, and create the MythTV database, which we'll populate shortly. The population of this database is handled by mythtvsetup in the next step, and all MythTV add-on module database additions must be done after running mythtvsetup at least one time.

# systemctl enable mariadb.service
# systemctl restart mariadb.service

Set the MySQL root password.

mysql_secure_installation

Now we create the MythTV database (called mythconverg) to get us started:

$ mysql -u root -p < /usr/share/doc/mythtv-docs/database/mc.sql
Enter password:

At this point, enter the password you just set above (ROOT_PWD) when prompted.

The above command gives users access to the database (see the main documentation) with the commands

$ /usr/bin/mysql -u root -p mythconverg
mysql> GRANT ALL ON mythconverg.* TO mythtv@"%" identified by  "mythtv";
mysql> flush privileges;

Again, all subsequent database population for MythTV's add-on modules must now be done after running mythtvsetup at least one time. It's worth customizing some parameters in /etc/my.cnf for optimal performance with MythTV.

In the event the mythtv-setup fails (current in Fedora 20), it may be because the time zone tables are not loading. See the wiki on the time zones. This entry fixed the problem:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

These adjustments to my.cnf under the [mysqld] section improve performance with both MythTV (especially in the GUI) and MythWeb:

key_buffer = 16M
table_cache = 128
sort_buffer_size = 2M
myisam_sort_buffer_size = 8M
query_cache_size = 16M 

Does /dev/video* exist?

Before going further it is wise to check whether things have worked so far. Has a /dev/video entry been created for an analog video source?

$ ls -la /dev/video*

If not, either you have a digital tv tuner (in which case you will have some entries in /dev/dvb/, and you should be reading https://fedoraproject.org/wiki/DavidTimms/DVB), or you have an analog source yet something has gone wrong with installing it (in which case you should look at /var/log/dmesg, and check whether udev, ivtv, and so on are working, and required modules are loaded). A useful quick test for USB video sources is to unplug them then plug them in again and look at the ends of whatever /var/log files get updated.

Setup MythTV

Recall what your video device was set up as (likely /dev/video0 for analog video sources; if you have a digital tuner see: https://fedoraproject.org/wiki/DavidTimms/DVB). Note that the actual device number is not what determines what order MythTV will use your cards in. What matters is the order that you enter them in mythtvsetup, so your best card doesn't have to be /dev/video0. If you set up /dev/video8 first, it'll be the first card used for recordings.

If you are in the US, you will need a paid account with [schedulesdirect.org]. The current pricing is $20 per year. This will give you television feed data that your myth box uses for scheduling once you have localized your acct to your zip code, chosen a content provider service and then set your channels from the webpage. There are a few other ways to get your data, but they are outside the scope of this document and the listings are not as accurate or as reliable.

Now on to launching the MythTV setup utility. For this part, you need to have an X running, as the setup utility is an X application. Fire it up like so:

$ mythtv-setup

I'm told that non-U.S. folks may have issues getting through the tv_grab_xx/xmltv part of the setup correctly if "focus follows mouse" is already set (in KDE's Control Center), so keep that in mind. Just set "focus follows mouse" after everything else is configured.

Note: If you receive an error involving permissions on a .so library, you may have SELinux installed and preventing you from accessing those libraries. You can either turn off SELinux, or allow access to the libraries with the following command as root:
chcon -t texrel_shlib_t /usr/lib/libmyth*.so*


Those using a dedicated /video partition, per my example, should obviously set /video/recordings for storage of recorded shows. However, you can do pretty much whatever you like here, such as recording to an NFS or Samba mount, a software RAID array. Just make sure your mythtv user has permission to read and write to whatever location you choose.

It is highly recommended that you go through the setup steps in order. Follow the on-screen instruction, with aid from the MythTV website documentation on this page:

http://www.mythtv.org/docs/mythtv-HOWTO-9.html

Note: your system may appear to hang at step 3. Give it time, it isn't locked up, that part takes a while!

Once you've gone through the setup, you have to populate the MythTV database with some program info. I spent a long time tweaking my channel lineup on schedulesdirect's site to remove all the junk channels I didn't really care to have show up. Once you have your listings to your liking, you're ready to fill your database with programming info. You must start up the backend first. We'll set it to autostart later.

$ mythbackend &

Assuming all goes well and the process doesn't exit on you (if it does, check out the troubleshooting section below), lets get some guide data:

$ mythfilldatabase 

If you're using a guide data source other than SchedulesDirect (i.e., anyone outside the U.S. and Canada), you may need to add a "--manual" flag to the end of that command to get it to work. Look at the output of "mythfilldatabase --help" for more clues if you have problems.

Also, be patient! This step can take a fairly long time, depending on your internet connection speed and how many channels your service provides. To get automatic updates of programming data daily, see below for configuration in mythfrontend.

Now start up the MythTV front-end (I recommend doing this in a separate shell window, so you can distinctly see the different output for the backend and frontend processes)...

$ mythfrontend 

There are various options within mythfrontend that you can tweak...a lot of this is covered by other parts of the wiki.

It is recommended to use the built in features of MythTV to have mythfilldatabase updated automatically. After starting up mythfrontend, enter the Setup > General screen and advance to "Mythfilldatabase", the fourth screen. Select the checkbox, then complete the options as you see fit. If using SchedulesDirect for programming data, selecting the option to allow the scheduler to recommend the next mythfilldatabase option and changing the allowed update time to be from 0 to 24 is best, as it allows SchedulesDirect to balance the load on their servers. After setup the mythbackend program will now run mythfilldatabase for you.

Configure startup

The necessary init script for the MythTV backend to automatically start at system boot is already in place for you, just simply turn it on:

# systemctl enable mythbackend.service

If the backend isn't already running, save yourself a reboot and issue this command:

# systemctl restart mythbackend.service

(If the backend fails at boot see: Systemd mythbackend Configuration (Works for Fedora 17))

You can list which scripts are started by issuing the command:

# systemctl list-units

It might be worthwhile to kill a number of scripts that you not used. Each script in /etc/init.d contains a short explanation of what they do. You can prevent the scripts from starting by issuing the command:

# chkconfig --del <name>

Now, because I have a few things that don't seem to want to play nice anymore (i.e., nvidia-settings don't load like they should, alsa volume levels aren't restored), I decided to create a quick little shell script in ~/.kde/Autostart/myth-load.sh to handle loading up all the extra goodies I need/want to auto-start, as well as force stubborn things to work. This script loads my nvidia settings, restores alsa volumes, launches irexec for my little power button script (on the Tips 'n' Tricks page), then launches mythfrontend, all in one fell swoop. Just copy and past all this into ~/.kde/Autostart/myth-load.sh (adjust accordingly for different desktop environments):

#!/bin/bash

# Only do this stuff if we're on the main display
# (i.e., don't do this in a vnc session)
if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ]
then
    # Load nVidia driver custom settings
    nvidia-settings --load-config-only &
    # Restore audio settings
    /usr/sbin/alsactl restore
    # Launch irexec for myth power button stop/start
    irexec &
    # Launch myth welcome 
    mythwelcome &
    # Disable dynamic power management (screen blanking)
    /usr/bin/xset -dpms
    # Disable screen saver
    /usr/bin/xset s off
fi
exit 

Don't forget to make it executable:

$ chmod +x ~/.kde/Autostart/myth-load.sh 

You'll also have to set autologin for your mythtv user. You'll have to get a root terminal open then:

Add the following lines to /etc/gdm/custom.conf

[daemon]
AutomaticLoginEnable=true
AutomaticLogin=mythtv (or whatever user you want)

If you want a timed login, try:

[daemon]
TimedLoginEnable=true
TimedLogin=mythtv
TimedLoginDelay=1 (Or however long you want to wait)

Fedora Version Specific Tips

Fedora 12/13

If analog sound doesn't work, try changing the audio device to ALSA:front, and change the ALSA:default mixer to control the Master control rather than PCM.