HTPC #1 (EPIA @ home)

January 4th, 2010 Leave a comment Go to comments

Table of contents

  1. Introduction
  2. Hardware installation
  3. Software installation
  4. Impressions
  5. Links

Introduction

- from time to time I started to dislike the thought that my windows PC was directly connected to the internet without any router or firewall inbetween. Additionally I wasn’t very happy with the power consumption of my dual core intel and it’s ATI graphic card running 24h hours a day.
You now maybe get a feeling about where this is leading to…

So here are the aims for my project:

  • I want a device that acts as a router
  • it has to be nearly inaudible
  • routing has to be as performant as on a embedded device
  • QoS (quality of service) would be nice
  • low power consumption
  • downloading (hdd connection) should be possible

And this is what it has become:

  • very performant routing device with NAT and QoS, DHCP and DNS
  • downloading machine which can be used by clients in or outside of the local net
  • server providing apache and mysql4/mysql5 services
  • storage for the tv-receiver (dbox via nfs)
  • backup storage for PCs connected to the local network
  • media center / pvr (MP3, video, tv, radio, weather, …)and MP3 player, connected via SPDIF (chinch) and composite TV out
  • phone answering machine for analog phones
  • X10 home control of lights, doors and whatever is connected via X10 bus
  • print server (via CUPS)
  • more, more, more…

Sounds very pleased? You’re right – and that’s exactly why I want to show you how I built the device and afterwards installed, configured and enhanced my system. I hope you enjoy it.

Hardware

First of all I got myself a VIA EPIA SP1300 mainboard including CPU, a cheap barebone case including ~100 watts power supply, DVD rom and 200gb IDE hard disk and a set of insulators from beQuiet.

Toshiba Digital Camera Toshiba Digital Camera Toshiba Digital Camera

I started insulating the case and installed the board. The insulation was very easy but – as I’m kinda perfectionist (more or less) – it took about 1-2 hours. But finally (as I also replaced the – a bit noisy – 40mm fan by a silent 80mm fan) it was nearly inaudible. And also very good looking. Or?

Toshiba Digital Camera Toshiba Digital Camera Toshiba Digital Camera Toshiba Digital Camera

And here’s the final product:

80_bild2

Software

First try

My first try was based on a windows XP installation. And surprisingly I got everything going well after one day – including a complete media center software (using mediaportal – which really is a great piece of software! If you use windows, give it a try, it will definitely impress you!). But you can’t compare the cpu of the board with a standard pentium cpu at the same clock. Instead it is sensibly slower and so – if I played a DVD – it was at 100% CPU load. As the barebone was only planned as a routing device I didn’t mind about that (because I was using my standard PC as media center these times).

The right operating system

So – what OS do you expect a router should run on? Exactly. Linux! Which linux? Well… As I don’t want to end up as a freak (what I maybe am a sometimes) I decided to use the ubuntu server edition (instead of some hardcore distris like slackware or even a BSD).

DSL / ISP connection

The installation of gutsy gibbon (ubuntu 7.10) didn’t take more than a hour. After that it was necessary to setup the DSL connection with pppoeconf (I hope you don’t mind that I don’t explain every step in detail – but the standard things can be found in one of the already existing ubuntu sites/wikis/forums – one goot but german example is http://wiki.ubuntuusers.de).

DNS and DHCP

As my DSL was working I used the package dnsmasq to add the DHCP and DNS functions. Very easy. But now – how to add the routing and “quality of service” function?

Routing

To enable the routing you NO special software. Instead you just have to understand iptables. There are lots of sites and books about iptables available. But – trust me – for the router you want to use at home you just DON’T have to read all of these. I instead used a already existing script called minifire (get it from here). What you have to do? Well – it is explained in german there very well. But this script is rather self-explanatory. Download, extract and copy it to /etc/init.d. Then edit the values in the configuration section as explained in the script, add it to the startup scripts and – voilà – you’re done.

QoS – quality of service

Okay, routing’s done. What next? Well – I want to have a proper ping even when I’m downloading. Is it possible? Yes! How to achieve? By using traffic shaping! Traffic shapping is another thing that’s already part of your kernel. And yes, you’re right – I only needed another script to get it going. And – as you already guessed – I didn’t want to create everything from the scratch. So I used “yats”, yet another traffic shaper (to the yats homepage). Grab the script, set it up properly (please read the manual on the homepage first and be prepared that it takes about 30 minutes to get everything right) and link it so it’s started automatically each time the machine is restarted.

Downloading

Another important thing was the download functionality. What I didn’t want to have to do is using the console to add downloads or having many download clients running at the same time. So I installed mldonkey, which is a really handy download manager. It can handle different networks like emule, torrent, ftp/http downloads and more! Once installed you can control it either per command line interface or via a very cool webinterface.
The real nice thing is you can have a graphical user interfaces on other PCs (I’ll call them clients from now on) that is able to add downloads to the mldonkey core which is running on the router. It’s name is sancho (to the homepage). And there’s also a plugin for firefox which directly sends downloads to the mldonkey core on the router. Great, isn’t it?

Sharing files with a windows PC

For sharing files in a windows network I had to install the samba package. In the smb.conf I was able to add each share – you can find an example for one of these shares below:

[www]
comment = WWW-Root share
path = /var/www
writable = yes
available = yes
browseable = yes
guest ok = no
force user = www-data # <= write the directory’s user here (for writing)
force group = www-data # <= write the directory’s group here (for writing)

It was necessary to restart/reload samba after the configuration of a new shares.

Sharing files with linux devices via NFS (e.g. DBOX)

Sharing files with other linux devices is very simple. I installed the nfs-kernel-server package, edited /etc/exports and added one row for each folder I wanted to share.

Example: /mnt/hda4/dbox_nfs      dbox(rw,sync,no_root_squash)

There’s one trap I got stuck into. If you want to use the shared folder you have to have exactly the same user id on the remote machine than on the server. So make sure the user-ids are equal.

Beware: it is not allowed to share folders as root! So if you want to have root access via NFS (and that’s exactly what I needed for my dbox) you have to add the no_root_squash option as I did above.

Apache, PHP and MySQL

I was used to have an AMP (apache/mysql/php) server for web development running on my main pc. Now it was time to transfer the AMP to the barebone also. First I installed the apache2, php and mysql package. If you need a special version of MySQL (like I did) I’d suggest you read the following article in the debianhowto). Everything else regarding the AMP installation is very standard, so you can find many step-by-step guides somewhere in a ubuntu wiki/forum.

Media center

Usage as a media center was the greatest challenge of the whole project. I decided to get it up and running in small steps and doing backups after each step was done.

First step was the sound device. Luckily alsa was already installed and the corresponding snd_via82xx module was already loaded (you can check this by lsmod | grep via). So the only thing I had to do was to start alsamixer and enable the IEC958 (bear this name in mind as it is the name of the SPDIF output device). When I ran speakertest -D iec958 there was noise coming out of the speakers – so driver and hardware setup was right!

Second: graphic card. I installed the xfce4 (a really unbelievably lightweight gui) and the xserver-xorg-video-openchrome package and edited my /etc/X11/xorg.conf as follows:

Section “Device”
Identifier      “ViaUniChrome”
Driver          “via”
BusID           “PCI:1:0:0″
Option      “ActiveDevice” “CRT,TV”
#        Option      “ActiveDevice” “TV”
#        Option      “ActiveDevice” “CRT”
#        Option      “UseBIOS” “true”
#        Option      “VBEModes”      “true”
Option      “DisableIRQ”
Option      “TVType” “PAL”
#       Option      “TVOutput” “S-Video”
Option      “TVOutput” “Composite”
#       Option      “TVOutput” “RGB”
Option      “TVDeflicker” “1″
Option      “TVVScan” “over”
#       Option      “TVVScan” “under”
#       Option      “TVDotCrawl”
#       Option      “DisableVQ” “true”
#       Option      “NoDDCValue”
#       Option      “HQVManualSwitch”
#       Option      “NoHQVVFilter”
#       Option      “CaptureOverScanOff”
#       Option      “Cap0Deinterlace” “Bob”
Option      “Cap0Deinterlace” “Weave”
#       Option      “Cap1Deinterlace” “Bob”
Option      “Cap1Deinterlace” “Weave”
#       Option      “Cap0FieldSwap”
#       Option      “NoCap0HFilter”
#       Option      “NoCap1HFilter”
Option          “EnableAGPDMA” “true”
VideoRam        65536
EndSection

Section “Screen”
Identifier      “Default Screen”
Device          “ViaUniChrome”
Monitor         “Standardbildschirm”
DefaultDepth    24
SubSection “Display”
Viewport        0       0
#               Modes           “1024×768″ “800×600″
#               Modes           “720×576Over”
#               Modes           “720×576Noscale”
#               Modes           “720×576″
#               Modes           “800×600Noscale”
#               Modes           “800×600″
Modes           “800×600Over”
#               Modes           “1024×768″
EndSubSection
EndSection

Section “Monitor”
Identifier      “Standardbildschirm”
Option          “DPMS”
#       Option          “NoDPMS”
#       Option          “NoDDC”
HorizSync       30-100
VertRefresh     50-160
DisplaySize     400     300
EndSection

Section “ServerLayout”

Identifier      “Default Layout”
Screen          “Default Screen”
InputDevice     “Generic Keyboard”
InputDevice     “Configured Mouse”

# Uncomment if you have a wacom tablet
#       InputDevice     “stylus”        “SendCoreEvents”
#       InputDevice     “cursor”        “SendCoreEvents”
#       InputDevice     “eraser”        “SendCoreEvents”
EndSection

Now XFCE started without any problems (starting command is startxfce4).

In third I struggled two hours with the remote control. Getting lirc up and running was really horrible (at least the first time)!
If you own the same RC as I do (have a look at the beginning) – you’re lucky, I’ll sum up the steps you have to do now. :)

fb-mmcpc

First of all get yourself the lirc package (apt-get install lirc). Also download the lirc sources from the official homepage to /usr/src. Then do the following:

apt-get install linux-source libusb-dev
cd /usr/src
tar xvjf linux-source-2.6.22
ln -s linux-source-2.6.22 linux
cd linux
cp /boot/config-2.6.22-14-generic .config
make oldconfig
make prepare
cd /usr/src
tar xvjf lirc-0.8.2.tar.bz2
cd lirc-0.8.2
./setup.sh
=> choose 1-8-4 (driver -> USB device ->ATI USB)
=> save and configure

make
make install

Another important step is to add the module ati_remote to the blacklist. Opened /etc/modprobe.d/blacklist and added a line containing ati_remote – after a reboot there was the new lirc_atiusb module available and no ati_remote was left (use lsmod | grep ati to check). To configure the buttons of the remote control it was necessary to record each button by using irrecord. Use this command: Irrecord -H default -d /dev/lirc0 configurationfile

The tool itself asks you to do some buttonpresses. After you pressed every button once you have to copy the configurationfile (which was the output of the irrecord tool) to /etc/lirc/lircd.conf and restart lirc. Now you can check if everything works fine by starting irw. you should now see the name of the button whenevery you press it at your remote. Don’t mind if there are two lines and you pressed the only once. That’s ok.

Fourth and last point was to get a media center software onto the barebone. And I decided to use mms – because it’s very lightweight, uses already existing tools for what they can do best, and it’s completely configured in less than 10 minutes. The package I needed was mms-standard. The mms configuration has to be done in at least one file in /etc/mms directory. For a complete guide please have a look into their wiki.

Since then I had everything I ever expected from my barebone. I can watch my movies or dvds with it, hear music from the HDD or internet radio, can watch pictures during that… And it’s also doing the other tasks like routing, downloading,… without any impacts. Great thing, isn’t it

Impressions

Toshiba Digital Camera Toshiba Digital Camera Toshiba Digital Camera Toshiba Digital Camera

Links

  • Share/Bookmark
  1. No comments yet.
  1. No trackbacks yet.