HTPC - MythTV on Gentoo PDF Print E-mail
Tuesday, 29 August 2006 12:00

My roommates and I have begun the quest of creating an HTPC(Home Theatre PC) for our apartment.  We are hoping for the capability for it to act as a DVR(like TiVo) for our TV shows and also be able to rip and view our DVDs for viewing anytime.

The feature of the system is a Raid Array of 2 TB(yes Terabytes)!  This will be unlike anything I have done before, and will also be cooler than anything I have done before probably.

Here I will post the process and struggles we(I) went through to set this beast up. 

System Profile

Here is the specs for our system.  We couldn't be extremely ridiculous, as the funding for this project was not unlimited.  We are starving college students after all.

  • Intel Pentium D 805 2.66 GHz
  • 1 GB PC 5400 DDR2 SDRAM
  • 4 - Hitachi DeskStar 500 GB SATA HDDs
  • Hauppage PVR-500 TV Tuner Card
  • Jaton nVidia GeForce 7600 GS 256MB w/ HDTV PCIe
  • 1 DVD-R drive - NEC
  • MicroATX case
  • Snapstream Firefly RF remote
  • ECS 945G-M3 (1.0b) Socket T (LGA 775) Intel 945G Micro ATX Intel Motherboard

So everything but the motherboard has arrived, Newegg.com's Tennessee warehouse is super slow for some reason.

Operating System

Of course there is only one choice for the basis of such a cool system: Linux.  Of course it is my opinion.  Unless you don't want as many features, and/or want it done really easy.  I am going to load Gentoo Linux on this baby and use MythTV as the controller program.

The fact that we're using Linux dictated several of the hardware choices including nVidia because of it's superior Linux support for Linux over ATI(although ATI cards have surpassed nVidia in power).  Also in researching I've found the the Hauppage capture cards are the most widely supported for MythTV.

I chose Hitachi hard drives because I never have met a bad one, and they outperform other drives that I've compared them to.  I'm excited to see them work in a 2 Terabyte RAID 5 Array.

System Assembly

Putting together this system was a lot of fun, as it usually is.  Everything fits like a glove, yes, it is fairly tight, but there's plenty of space around components for airflow.  The only issue was the case was bent in the back around the PCI slots and the slots don't line up exactly with the motherboard, they are like 2mm off, so my graphics outputs are not centered in the slot perfectly, but it works. 

I also had to take out the power supply and the fan to get the motherboard in without breaking anything, as expected for a microATX case.  Thanks to some clever cable management, it doesn't feel so crowded in the case.

It is an amazing site to see the four hard drives hooked up and ready to go.  Do you ever get that feeling once you've put it all together, and thought, "What if it doesn't work?".  I get that every time.  But of course, I plug it in, and everything works as expected.

Installing Gentoo

I won't go into details about how to install Gentoo Linux, but I will point you to the Gentoo Handbook, where you can find the installation instructions if you are comfortable/daring enough to try Gentoo out.

What I did was in preparation for the machine, I used a spare HD in my computer that I use for various transient purposes(temp backups, distribution testing, Windows Vista curiosity).  I formatted it and started installing the base Gentoo system and needed base packages.  I bzipped my / directory up and transferred it over to my new system and extracted it. 

A hint for installing Gentoo... I found that unless you have an extra computer handy it is extremely helpful to use the Knoppix CD to install Gentoo instead of the boot CD that is from the Gentoo people.  Perhaps Gentoo purists will scoff at the suggestion.  I like the ability to use firefox and KDE(although I prefer gnome).  The newest Knoppix releases has all the tools I need and more.  I am actually writing this while in Knoppix.

Kernel Configuration

Once I get the system working with most of the things I need, I will post my kernel config options.  I am using the latest kernel available through Gentoo emerge-- Linux 2.6.17.  I keep hearing good things about the kernel getting better.  The 2.6.17 has improved RAID support as well, which makes me happy.

Hard Disk Configuration

How exciting, this will be the first real application for a RAID based storage system.  I've dabbled before, but we're serious now!  All the hard drives have been connected, and I paid special attention to making sure I connected them in the order that they are positioned in the case, so I can easily tell which drive maps to which device, especially if there's a failure I don't have to refer back to motherboard manual or get flashlight out and try to read printing on the motherboard.

Since the motherboard does not have an onboard RAID controller(hard to find for MicroATX at good price), we'll be using the software RAID that is built into the Linux kernel.  We will be using RAID 5 because it offers a good combination of speed(through striping) and redundancy(through parity).  Also it allows one drive to fail completely, and preserves data without needing double the capacity(as with RAID 1- mirroring).  The actual storage capacity for N drives of size S in RAID 5 is (N-1) * S.  So our total capacity will be around 1500 GB.

Partitioning

RAID partitions must be exactly the same size for all partitions involved in a RAID array.  I decided to also make the hard drives identical in partitions for simplicity.  Below is the partitioning setup for all the hard drives(sdx refers to either hda, hdb...). 

Mount Point Filesystem
Device
Size
RAID Device
RAID Size
Description
/boot
ext2
/dev/sdx1
 50 MB
NON-RAID
 N/ABoot partition to hold grub & kernel data
swap
swap
/dev/sdx2
500 MB
/dev/md1
1.5 GB
Raided swap
/
jfs
/dev/sdx3
15 GB
/dev/md2
45 GB
Root partition system/user files
/mnt/store
jfs
/dev/sdx4
484 GB
/dev/md3
 1.45 TB
Storage for media files

 The sizes are not exact and actual storage space will be less once filesystem is created.  Also please note that for all the RAIDed partitions, in fdisk you must set the type to Linux RAID Autodetect, not 82 or 83.  You format the filesystem after the RAID drive is created.

RAID Setup

I have found a couple of good references which outline setting up the RAID drives.

Allow yourself about 3 hours for the RAID to build the initial array.  That's about how long it took me.  If you have incredible hard drives it may be faster.  2 Terabytes is a lot of ground to cover, I think 3 hours is pretty impressive.  Oh and if you do other stuff, such as installing on the other partitions that are already built, the RAID will take even longer.

# cat /proc/mdstat
Personalities : [raid5]
md3 : active raid5 sdd4[4] sdc4[2] sdb4[1] sda4[0]
      1419511104 blocks level 5, 64k chunk, algorithm 2 [4/3] [UUU_]
      [===================>.]  recovery = 96.0% (454590464/473170368) finish=12.4min speed=24906K/sec
md2 : active raid5 sdd3[3] sdc3[2] sdb3[1] sda3[0]
      43977600 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]

md1 : active raid5 sdd2[3] sdc2[2] sdb2[1] sda2[0]
      1493760 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]

unused devices:

Software

Here are the major pieces of software that are needed(I am using) for this install, not including obvious system utilities. 

  • X11 X.org Server
  • Window Manager - I choose fvwm as it's lightweight
  • IVTV Drivers - to control TV Tuner
  • MythTV 0.19
  • LIRC - Remote control utilities
  • MySQL - MythTV backend requires MySQL database
  • Qt v.3 - MythTV uses Qt version 3 only, fails compile if you have version 4
  • nVidia drivers

Also I will post my /etc/make.conf and /etc/portage/package.keywords and /etc/portage/package.mask files as there are important USE variables and packages that need to be unmasked in order for everything to work.

I don't think I can include a command-line walkthrough as it would require a lot of typing.  I will try to detail specific points that need to be remembered for this build.  Please contact me if you would like me to create a step by step How-To.  I try to let Gentoo's emerge do most of the work.

 

 

Book Wish List

StackOverflow