OH DEAR! THIS IS A BIG DOCUMENT AND IT IS LARGELY OUT OF DATE. I WILL UPDATE IT IN THE FUTURE, PROBABLY BASED ON MYTHBUNTU
So here I go again with another
MythTV prototype. However, this time I am
going try and get things close to a production system so I can use it in my
home cinema, this means I will need an HTPC case which matches my A/V
equipment.
I am also going to switch from
KnoppMyth to Ubuntu and try to create a minimal
install with just what is required to support my
MythTV on my hardware.
HTPC Cases
These are the dimensions of my existing A/V equipment I want to match closely
too.
| Device | Length | Width | Height
|
|---|
| Arcam AVR250 | 420mm | 435mm | 145mm
|
| Arcam DV78 | 350mm | 435mm | 80mm
|
These are the dimensions of the case I found which have the features I wanted
and are supported by Linux, although the reports of Linux compatibility are
unconfirmed as of October 2006 but some forums are reporting success.
| Case | Length | Width | Height
|
|---|
| SilverStone LC10M | 429mm | 430mm | 163mm
|
| Zalman HD160 | 435mm | 420mm | 160mm
|
| Zalman HD135 | 435mm | 425mm | 135mm
|
I prefer the slimmer Zalman HD135, but some PSU's may be a problem according
to online reviews. The
SilverStone LC10M is well supported, the dimensions
are a better match to my A/V kit and it is far less expensive than either of
the Zalman case. So I chose the LC10M.
As quiet running is a design requirement I have opted for the
SilverStone
TruePower 300W Silent Fanless Aluminium PSU to go in the case.
Online Shops (UK)
References
Hardware
Existing Components
Soyo SY-K7V Dragon Plus - Socket "A"(462)
- DRAM Clock - 133MHz
- DRAM Timing - manual
- DRAM CAS Latency - 2T
- Bank Interleave - 4-way
- Precharge to Active - 2T
- Active to Precharge - 6T
- Active to CMD - 3T
- DRAM Queue Depth - 4 level
- Write recovery time - 1T
- DRAM Command Rate - 2T
- DRAM DQS Length - Default
- AMD Athlon XP 2000+ 266mhz FSB
References
Sony Sony DRU-710A or Sony DRU-700A
XFX GeForce FX 5200 256MB DDR (PV-T34K-UA)
Hauppauge WinTV-Nova-T PCI Freeview receiver (909)
USB 2.0, Firewaire PCI Card
Required Bits
- SilverStone LC10B-M+ Black Aluminum case + VFD + IrDA w/o PSU
- SilverStone TruePower 300W Silent Fanless Aluminium PSU
- Zalman CNPS7000B-ALCU Super Flower Cooler
- Hauppauge WinTV-Nova-T PCI Freeview receiver (909)
- Compact Flash IDE Adapter - Dual H2
- Compact Flash IDE Adapter - Direct IDE with DMA Support
- CompactFlash (CF) Memory Card - 2GB - Sandisk Extreme IV
Optional Bits
- 266MHz 184Pin 1GB PC2100 DDR RAM DIMM 2.5V 2.1Gb
- Samsung 300 Gb HD300LD Spinpoint T, IDE (PATA), 7200 rpm, 8MB Cache
- Samsung 400 Gb HD400LD Spinpoint T, IDE (PATA), 7200 rpm, 8MB Cache
- Edimax EW-7128G 54Mbps Wireless PCI Card
- 3xUSB2 PCI card with 3.5" 3 port USB & 2 Port Firewire Combo USB internal Hub
- ASRock K7NF2-RAID
- MicRacer 1D-X
Ubuntu and MythTV Resources
Hardware Resources
Install Ubuntu 7.04 Alternate
The following steps are just a guide to installing a Ubuntu command-line system:
- Install a command-line system
- Choose a language: English
- Choose a location: United Kingdom
- Detect keyboard layout: No
- The origin of the keyboard is: United Kingdom
- Keyboard layout : United Kingdom
- Hostname: pvr
- Disk space to partition: Manually partition
- Create new 2.0G partition for "/" of type "ext3" and bootable
- Create new 1.0GB partition for swap (your RAM size)
- Create new partition using the remaining space for "/var" of type "xfs"
- Select a city in your time zone: <your city>
- Is the system clock set to UTC?: Yes
- Full name for the new user: Personal Video Recorder
- Username for your account: pvr (Do not use "mythtv")
- Choose a password for the new user: <secure password>
Compact Flash and DMA
Very few Compact flash to IDE adpaters support DMA!
If your compact flash to IDE adapter does not support DMA then you need to use the "ide=nodma" kernel option otherwise the system will encounter timeouts when accessing the compact flash card.
- During the install press F6 and add "ide=nodma" to boot parameters.
- During the reboot, interrupt Grub by pressing 'ESC' and add 'ide=nodma' to the kernel options to prevent the DMA timeouts on the compact flash card delaying the boot process.
Why XFS?
XFS is my recommended filesystem for storage of media files based on some background reading I did. See the references below. Putting everything in /var on the hard disk reduces the activity on the Compact Flash drive.
References
Post Installation
The first thing to do is install SSH so the remainder of the setup can be conducted from the comfort of a Workstation.
apt-get install ssh
Hostname
echo pvr.home.flexion.org > /etc/hostname
/bin/hostname -F /etc/hostname
vi /etc/hosts
127.0.0.1 localhost
127.0.1.1 pvr.home.flexion.org pvr
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Boot Configuration
Essentially the Myth box has no console so it is essential to edit /etc/default/rcS and set FSCKFIX=yes, to prevent fsck problems from hanging your boot waiting for you to press "y" on a nonexistant console.
References
Essentials
apt-get install less file ntp tree psmisc vim dnsutils pciutils bzip2 zip unzip telnet
If you need e-mail delivery use this combo, otherwise the installation mailutils will also install exim4.
apt-get install nullmailer mailutils
Wireless
sudo vi /etc/network/interfaces
auto ra0
iface ra0 inet dhcp
wireless-essid YourSSID
wireless-key s:YourASCIIWEP
References
Relocate '/tmp'
As I am running from a 2GB compact flash card I want to ensure that anything which might want to write to /tmp is writing to somewhere with plenty of storage. So I create a sym-link as follows...
sudo mkdir /var/tmp/relocated-tmp
sudo chmod 777 /var/tmp/relocated-tmp/
sudo chmod +t /var/tmp/relocated-tmp/
sudo rm -rf /tmp
sudo ln -s /var/tmp/relocated-tmp /tmp
Repositories
sudo -s -H
echo "## Essential repos" > /etc/apt/sources.list
echo "deb http://gb.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://gb.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse" >> /etc/apt/sources.list
echo " " >> /etc/apt/sources.list
echo "## Updates and bug fixes" >> /etc/apt/sources.list
echo "deb http://gb.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse " >> /etc/apt/sources.list
echo "deb-src http://gb.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo " " >> /etc/apt/sources.list
echo "## Security Updates" >> /etc/apt/sources.list
echo "deb http://security.ubuntu.com/ubuntu feisty-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://security.ubuntu.com/ubuntu feisty-security main restricted universe multiverse" >> /etc/apt/sources.list
echo " " >> /etc/apt/sources.list
echo "## Backports" >> /etc/apt/sources.list
echo "deb http://gb.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://gb.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo " " >> /etc/apt/sources.list
echo "## Proposed" >> /etc/apt/sources.list
echo "#deb http://archive.ubuntu.com/ubuntu/ feisty-proposed restricted main universe multiverse" >> /etc/apt/sources.list
Medibuntu
wget http://medibuntu.sos-sts.com/sources.list.d/feisty.list -O /etc/apt/sources.list.d/medibuntu.list
wget -q http://medibuntu.sos-sts.com/repo/medibuntu-key.gpg -O- | apt-key add -
echo "## MythTV 0.20, libdvdcss, mplayer and more" > /etc/apt/sources.list.d/superm1.list
echo "deb http://home.eng.iastate.edu/~superm1 feisty all" >> /etc/apt/sources.list.d/superm1.list
echo "deb-src http://home.eng.iastate.edu/~superm1 feisty all" >> /etc/apt/sources.list.d/superm1.list
wget -q http://home.eng.iastate.edu/~superm1/80DF6D58.gpg -O- | apt-key add -
sudo apt-get update
sudo apt-get upgrade
Kernel
Lets grab all the relevant kernel stuff since we will need this later and
it will also ensure we don't get any unneeded i386 kernel packages when
the 'nvidia-glx' package is installed.
apt-get install linux-generic linux-headers-generic linux-image-generic linux-restricted-modules-generic
reboot
Kernel Clean up
You will end up with unneeded kernel packages the following will remove them.
apt-get remove linux-headers-2.6.20-15-generic linux-image-2.6.20-15-generic linux-restricted-modules-2.6.20-15-generic
Tweaking Grub
My Mythbox will be connected to a 1024x768 display so I enable that video resolution ASAP.
vi /boot/grub/menu.lst
Change...
timeout 3
...to...
timeout 1
Change...
# defoptions=quiet splash
...to...
# defoptions=quiet splash vga=791
update-grub
reboot
Hard Disk Tuning
Disable DMA for CF adapter?
I use a compact flash card for /dev/hda to reduce power consumption and noise. But my old IDE to Compact flash adapter didn't support DMA (although the compact flash card I have does), therefore I needed to disable DMA in the kernel options and then then optimise hard disk and optical drive options using hdparm during the boot.
If your CF adapter does support DMA, then these changes are not required.
So, edit /boot/grub/menu.lst and add 'ide=nodma' to the kernel options...
# kopt=root=/dev/hda1 ro ide=nodma
...and run...
update-grub
...to make sure subsequent boots aren't delayed by DMA timeouts on the CF card.
Now add the following to '/etc/hdparm.conf' to optimize disk performance.
# Compact Flash
/dev/hda {
mult_sect_io = 4
dma = on
interrupt_unmask = on
io32_support = 1
write_cache = off
}
/etc/init.d/hdparm restart
References
Xorg
apt-get install fontconfig openbox obconf xserver-xorg xterm xvattr xloadimage
Nvidia Graphics Cards and Xorg
If you have an NVIDIA graphics card you need to install the drivers.
lspci | grep nVidia
You should get the output similar to the following:
0000:01:00.0 VGA compatible controller: nVidia Corporation NV34 [GeForce FX 5200] (rev a1)
Install nvidia drivers.
apt-get install nvidia-glx libxvmc1
Choose the screen resolutions you want when prompted.
dpkg-reconfigure -phigh xserver-xorg
Choose the 'nvidia' driver when prompted.
nvidia-xconfig
apt-get install msttcorefonts ttf-freefont xfonts-base gsfonts-x11 xfonts-100dpi xfonts-75dpi
fc-cache -f -v
After these steps install check your '/etc/X11/xorg.conf' file is using the 'nvidia' driver instead of the open source 'nv' driver and that the nVidia logo is disabled.
vi /etc/X11/xorg.conf
Sample
Section "Device"
Identifier "Generic Video Card"
Driver "nvidia"
Option "NoLogo" "true"
EndSection
Now ensure that the
XvMC wrapper is pointing to the Nvidia
XvMC library.
cp /etc/X11/XvMCConfig /etc/X11/XvMCConfig.backup
echo /usr/lib/libXvMCNVIDIA.so.1 > /etc/X11/XvMCConfig
Setting up Remotes
My Hauppauge
WinTV-Nova-T PCI Freeview Tuners and
SilverStone LC10M case have Infrared receivers. I use the iMON Remote which came with the LC10M case, but I have instructions for setting up both remotes.
apt-get install mysql-server
mysqladmin -u root password <PASSWORD>
mysql -u root -p
Enter password: (the new mysql root password you just created above). You should see:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 5.0.22Debian_0ubuntu6.06log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit
Bye
cp /etc/mysql/my.cnf /etc/mysql/my.cnf.backup
cp /usr/share/doc/mysql-server-5.0/examples/my-small.cnf /etc/mysql/my.cnf
References
Install MythTV Prerequisites
These package include DVB, DVD and Audio/Video Players, Codecs and Utilties that
MythTV requires or are just generally useful, but not installed as dependancies.
apt-get install dvbstream dvb-utils xmltv xmltv-util
apt-get install libdvdcss2 regionset cdrecord
apt-get install mplayer-nogui mplayer-fonts w32codecs xine-ui libxine-extracodecs vlc
apt-get install transcode avifile-utils avifile-mad-plugin avifile-mjpeg-plugin avifile-vorbis-plugin avifile-divx-plugin avifile-win32-plugin avifile-xvid-plugin
apt-get install a52dec faad faac lame mpeg2dec sox toolame libdts-dev libxvidcore4
mplayer requires a little tweak to enable real time priority.
vi /etc/rc.local
Add the following line to the bottom of the file *before* the 'exit 0'...
echo 1024 > /proc/sys/dev/rtc/max-user-freq
apt-get install mythtv mythtv-frontend mythtv-backend mythtv-database mythtv-doc mythtv-themes
Enter the the password for the
MySQL administrator account 'root' when prompted.
Lets enhance the 'mythtv' user by adding the account to the useful groups, changing the shell to 'bash'.
sudo /etc/init.d/mythtv-backend stop
sudo usermod -G adm,audio,dialout,cdrom,floppy,dip,plugdev,lpadmin,scanner,video,admin mythtv
sudo usermod -s /bin/bash mythtv
Change the 'mythtv' shell account password to 'mythtv'
sudo passwd mythtv
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Change the 'mythtv'
MySQL user account password to 'mythtv'.
mysql -u root -p mysql
mysql> UPDATE user SET Password=PASSWORD('mythtv') WHERE user='mythtv';
mysql> FLUSH PRIVILEGES;
mysql> quit
sudo vi /etc/mythtv/mysql.txt
Sample
DBHostName=localhost
DBUserName=mythtv
DBName=mythconverg
DBPassword=mythtv
As the 'mythtv' user running the following to configure
MythTV.
startx
mythtv-setup
mythtv-setup must be run in order to complete
MythTV installation. You must
run mythtv-setup as the 'mythtv' user in order to complete mythtv configuration. Note that this program requires an X display, so you must either login to an X session as the 'mythtv' user, or otherwise arrange for that user to have access to your X display.
You must complete all four steps presented in the program.
Once you have done this, you may start the backend by executing the following command as root:
sudo /etc/init.d/mythtv-backend start
Setup
MythWelcome
mythwelcome -s
Change the command to start which starts 'mythfrontend' so it logs activity to a file.
mythfronted --logfile /var/log/mythtv/mythfrontend.log
sudo cp /etc/logrotate.d/mythtv-backend /etc/logrotate.d/mythtv-frontend
sudo vi /etc/logrotate.d/mythtv-frontend
change mythbackendend.log to mythtvfrontend.log
We should also make sure that the "Myth Transcode Daemon" starts up everytime
the system boots.
sudo vi /etc/rc.local
Add the following line to the bottom of the file *before* the 'exit 0'...
/usr/bin/mtd --daemon
Test the basic
MythTV system by running...
mythwelcome
...from the Terminal Window.
If everything works, lets move on to running
MythTV automtically at boot.
Minimal Graphical Auto Login
Complete these steps below as 'root'.
sudo -s -H
cd
apt-get install build-essential
echo -e "int main() { \n execlp( \"login\", \"login\", \"-f\", \"mythtv\", 0); \n } " > autologinmythtv.c
gcc -o autologinmythtv autologinmythtv.c
strip autologinmythtv
cp autologinmythtv /usr/local/sbin/
sudo cp /etc/event.d/tty1 /etc/event.d/tty1.bak
sudo vi /etc/event.d/tty1
Replace...
respawn /sbin/getty 38400 tty1
..with...
respawn /sbin/getty -n -l /usr/local/sbin/autologinmythtv 38400 tty1
exit
The execlp system call invokes the command "login -f mythtv" and replaces the current processing context with this invocation. The man page for login describes the action of the -f argument. Compile this tiny C program using the GNU C-compiler:
The above will cause the user 'mythtv' to be logged in automatically on the first virtual console. The -l <alternative login> argument to getty substitutes the default /sbin/login program with the one we compiled earlier. The -n tells getty to not prompt for a user ID.
If we reboot, the init process will automatically login the user 'mythtv' on the
first virtual console and a command shell will by started. User 'mythtv' must still type in the startx command to initiate the graphical desktop. Let's automate starting X.
Complete these steps as 'mythtv'.
If the 'mythtv' users login shell is /bin/bash, the first commands to be executed will always be listed in the file, ~/.bash_profile. We can add the startx command here but this causes problems, since the .bash_profile will be used in other situations such as when one is logging into a second virtual console or when opening an xterm. Instead we append the following lines:
echo -e "if [ -z \"\$DISPLAY\" ] && [ \$(tty) = /dev/tty1 ]; then \n startx \n exit \nfi" >> ~/.bash_profile
ln -s ~/.bash_profile ~/.profile
Any new login shell started on the first virtual console will automatically initiate a graphical desktop. The surrounding if statement ensures that login shells launched from the desktop, or initiated in virtual consoles other than the first one, do not immediately start up a new GUI desktop.
Now whenever the machine boots, user 'mythtv' is automatically logged into the first virtual console, a bash login shell is initiated, his ~/.bash_profile is sourced, and startx is invoked -- all without any user interaction or prompting for passwords. Neat, huh?
We can go further by making use of the ~/.xinitrc file to initiate particular desktop applications.
wget http://www.mythtv.org/wiki/images/c/c1/MythTV_logo.png
vi ~/.xinitrc
Sample
# Load the MythTV Logo
xloadimage -onroot -center /home/mythtv/MythTV_logo.png &
# Turn the monitor Power Saving Off
xset s off &
xset -dpms &
# Disable the blue chroma on TV out
# xvattr -a XV_COLORKEY -v 0
# Wait for the MythTV backend...
until [ -e /var/run/mythtv/mythbackend.pid ]; do
sleep 2
done
# Start mythwelcome
mythwelcome &
exec openbox
chmod +x ~/.xinitrc
The first two lines disable DPMS so your TV won't blank
The next line removes the blue chroma colour if TV-out is used.
Then mythwelcome is started and finally the openbox window manager is launched.
sudo reboot
References
Apache and PHP
Install Apache 2.0.x, PHP 5.1.x and phpMyAdmin 2.8.x. Useful for fixing any database issues should they arise and also ensure that when the 'mythweb' package is installed it will use PHP5 instead of PHP4.
sudo apt-get install apache2 php5 phpmyadmin libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql
sudo vi /etc/apache2/apache2.conf
TimeOut 45
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 2
ServerName yourserver.com:80
ServerAdmin webmaster@yourserver.com
<ifmodule>
StartServers 1
MinSpareServers 1
MaxSpareServers 2
MaxClients 32
MaxRequestsPerChild 384
</ifmodule>
Essential Plugins
I consider the plugins essential for my Mythbox.
sudo apt-get install mytharchive mytharchive-data
sudo apt-get install mythdvd mythvideo
sudo apt-get install mythgallery
sudo apt-get install mythmusic
sudo apt-get install mythweather
sudo apt-get install mythweb
Once mythweb is installed, you unfortunately have three more steps to complete.
Look at your /etc/mythtv/mysql.txt. Take note of the information listed in it. You will have to update the username and password in /etc/mythtv/mythweb-htaccess.conf.
sudo vi /etc/mythtv/mythweb-htaccess.conf
Edit /etc/group. You will have to add www-data to the mythtv group.
sudo usermod -G mythtv www-data
The ownership isn't properly set on /usr/share/mythtv/mythweb/data and mythweb-htaccess.conf.
Set them correctly by
sudo chown www-data /usr/share/mythtv/mythweb/data/
sudo chown mythtv.www-data /etc/mythtv/mythweb-htaccess.conf
Lets make some directories which are missing and fix up some broken directories...
sudo mkdir /var/lib/mythmusic
sudo mkdir /var/lib/mythpictures
sudo mkdir /var/lib/mythicons
sudo mkdir /var/lib/mytharchive
sudo mkdir /var/lib/mythvideocovers
sudo chown mythtv.mythtv /var/lib/myth*
sudo chmod 775 /var/lib/myth*
sudo chmod +s /var/lib/myth*
sudo rm /usr/share/mythtv/mythweb/data/tv_icons
sudo ln -s /var/lib/mythicons /usr/share/mythtv/mythweb/data/tv_icons
sudo rm /usr/share/mythtv/mythweb/data/music
sudo ln -s /var/lib/mythmusic /usr/share/mythtv/mythweb/data/music
sudo chmod 777 /var/lib/mythicons
Storage Locations
MythDVD
Within the Setup section of the
MythTV frontend, you need to specify the storage
location for your DVD rips
(
MythTV -> Setup -> DVD Settings -> Rip Settings
MythGallery
Within the Setup section of the
MythTV frontend, you need to specify your
image storage location
(
MythTV -> Setup -> Image Settings).
It should simply be a matter of setting up your audio storage directories
within the
MythTV Setup section
(
MythTV -> Utilities/Setup -> Media Settings -> Music Settings
Within the Setup section of
MythTV, configure your movie storage directory
(
MythTV -> Utilities/Setup -> Media Settings -> Video Settings -> General Settings
vi /var/www/index.html
Sample
<HTML>
<HEAD>
<TITLE>redirect</TITLE>
<META HTTP-EQUIV="refresh"
CONTENT="1;URL=/mythweb">
</HEAD>
<BODY>
This page has moved. You will be
automatically redirected
to its new location.
If you aren't forwarded
to the new page,
<a href="/mythweb">
click here</a>.
</BODY>
</HTML>
Non-essential Plugins
sudo apt-get install mythbrowser
sudo apt-get install mythcontrols
sudo apt-get install mythflix
sudo apt-get install mythgame
sudo apt-get install mythnews
sudo apt-get install mythphone
I do not install the
MythPhone plugin because the Dapper package for Myth 0.20 cause mythphone to segfault when mythfrontend starts.
Channel Logos
These a UK specific instructions, but 'mythautoicon' is designed for
use in other regions. Take a look at the authauoicon README if you
are outside the UK.
wget http://www.syzygy.eclipse.co.uk/files/mythautoicon_v0_2.tar.bz2
tar jxvf mythautoicon_v0_2.tar.bz2
cd mythautoicon_v0_2
vi mythautoicon.py
Change the 'icon_dir_mythtv' setting as follows.
icon_dir_mythtv = '/var/lib/mythicons'
./mythautoicon.py
Follow the prompts to match up the channels with logos.
cp -R icons/* /var/lib/mythicons/
sudo chown -R mythtv.mythtv /var/lib/mythicons/*
sudo chmod -R 755 /var/lib/mythicons/*
References
Shutdown and Wakeup
References
Mpeg Res detection
#!/bin/sh
mplayer -frames 0 -nosound -nolirc -nojoystick -nortc -quiet -identify -vc null -vo null -ao null $1
GBPVR
$Id: MythTV,v 1.11 2008/04/11 08:50:21 martin Exp www-data $