HTPC setup

Here is a description of my HTPC setup. The reason for yet another HTPC description is that I have made a few changes to many of the other setups that I have seen.

My setup consists of a backend server and the actual HTPC that is located under the TV. The backend server runs Ubuntu and Tvheadend. Besides Tvheadend the server runs quite a few other services like mail, web etc. The HTPC under the TV runs Ubuntu with XBMC.

Backend

The backend part is the easy part. It runs a standard Ubuntu installation. As I care for my data I run RAID1 with LVM on the top. This gives some great flexibility when I add or replace disks.

On the backend I use Tvheadend. In my PPA I have a version of Tvheadend. It is that version I use on my backend.

Frontend

The hardware is a cheap Intel Atom CPU with Nvidia gfx. The Nvidia gfx gives hardware accelerated playback of video. I have also bought this one to be able to power on the machine with my remote control.

On the frontend I run Ubuntu with XBMC on it. I use the XBMC package from Pulse Eight. The advantage og this build is that it contains PVR module. The PVR module makes it possible to use XBMC to watch my everyday TV. As I am using XBMC to watch TV I have really easy access to all my videos all the time as it is just a matter of jumping to the video menu while watching TV.

I have bought a Hauppage MCE remote controller. This remote works perfect with Linux and XBMC.

 

 

Duplicity HOWTO

I use Duplicity for backup of my local server. Backup is done to Amazon S3. I use Amazon S3 as storage is quite cheap. I currently pay less than 10$/month for more than 70GB of data.

Below is a description of my Duplicity setup. Feel free to use this for your own setup if you like. This guide is written for Ubuntu 11.10, but should work for any newer version and maybe for older versions as well.

Installation

First of all you need to create an Amazon AWS account with access to S3 storage. Signup page is found here. When you have signed up select “security credentials” in the management console. Write down access key ID and secret access key. You will need these later.

You need to install a couple of packages before you are ready to backup some data. The two required packages are duplicity and python-bobo. Install them from a console with the command apt-get install duplicity python-bobo.

Duplicity can encrypt data before upload to Amazon S2. This ensures that no one else can read your backup if your Amazon account is hacked. Duplicity use GPG to encrypt data. For that you need a key pair. Generate the key pair with below command.

gpg --gen-key

Select 1 for both RSA and DSA. If you don’t want your key to expire select 0 in “key is valid for”. Confirm the settings. Key in your name etc. Finally create a passphrase for your key. The key is now being generated. When key generation is completed remember the key (something like F43FB863). You need this later on. It is very important that you save your GPG key a safe place. Reason is that you will NOT be able to restore your backup without this key.

All the required software is now installed.

Configuration and backup

In my configuration backup is scheduled to run once a day. Duplicity makes it possible to make incremental backups. It even handles incomplete full backups. If your full backup is disrupted it will just continue with the full backup next time the backup script is executed.

I use a small shell script to start my backup. You can get the script here. Open the shell script in a text editor and change the values for AWS_ACCESS_KEY, AWS_SECRET_KEY, PASSPHRASE and GPG_KEY. Remember that you wrote down all the values during installation :-)

Around line 25 in the script you will see that the script takes backup of two different folders. That is etc and home. This is done by calling backup function. Backup function takes three arguments. That is the source folder, destination folder and how old a full backup can be. For instance it is 45 for etc folder. If last full backup os older than 45 days a new full backup is made. After the full backup have been created the old full backup, including all incremental backups are deleted. This ensures that there is always a full backup available.

You can of cource modify the script to take backup of other folders. After you have modified the scripts as per above and added the folders to take backup of copy the script to /etc/cron.daily. This ensures that your backup is executed once a day.

You are now successfully creating backup of your system.

Restore

If you get in a situation where you need to restore your data you can use this script to restore your data.

As with the backup script open the script in your favourite text editor and change the values of AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, PASSPHRASE and GPG_KEY. At the bottom you will see that the script restores etc and home to the the folder /mnt/etc and /mnt/home.

It is also possible to restore single files and files back in time as long as it is after creation of last full backup. Please see the man page for duplicity for details. At some point I might write a few notes about it here.

HDAPS guide / TP-Smapi guide

This is a guide to get hdaps and tp-smapi work on Lenovo laptops. The guide is written for Ubuntu. During the last couple of version of Ubuntu it has become a lot easier to get hdaps and tp-smapi to work.

Follow below steps to setup tp-smapi and hdaps. I have written this guide with Ubuntu Oneiric in mind, but it should also work on Precise. I also have a depricated uguide. That guide might be usefull for older Ubuntu releases. You can still read the guide here.

Setup apt

This is actually an optional step, but it is nice to have hdaps-utils package installed in order to verify that hdaps is working. Hdaps-utils is a small graphical utility that show how much you tilt your laptop. Hdaps-utils is no longer a part of Ubuntu, but I have created a package in my PPA. Open a terminal and add my PPA with the commandsudo apt-add-repository ppa:jonasped/ppa.

TP-Smapi

Install tp-smapi-dkms package. The package contains two kernel modules. One TP-Smapi interface and the other one is the hdaps interface. The package is part of the official Ubuntu repository. Install it with the command sudo apt-get install tp-smapi-dkms.

Hdaps

Hdapsd is a small daemon that parks the HD heads if the acceleration is too big. This is done to protect your harddrive against shocks. First you need to install the hdapsd package. You do that by typing in sudo apt-get install hdapsd. The installer starts hdapsd automatically.

Hdaps-utils

Further to above daemon there is a couple of small utilities that can show how you rotate your laptop in real-time. These utilities are found in the package hdaps-utils. This package is not a part of the official Ubuntu repository, but I have created a package and placed it in my PPA. Install this package by typing sudo apt-get install hdaps-utils. After package is installed you can either run hdaps-pivot or hdaps-gl. Try to run hdaps-gl command and you will get something like below. This is an easy way to verify that hdaps interface is working.

hdaps
As you can see above command is mostly to show that it actually works.

DCC

DCC is an anti-spam content filter and I have very good experience with it. DCC stands for Distributed Checksum Clearinghouses. I use it together with SpamAssassin to tag mails as spam on my mail server. I have been using DCC for several years and my experience is very good.

Unfortunately is DCC not included with Ubuntu (or Debian). Due to this I maintain a set of DCC packages in my PPA. Below you will find a guide to download, install and configure DCC on your Ubuntu box. It is assumed that you already have SpamAssassin configured.

Download and install

To download and install DCC follow below steps. As DCC is stored in my personal PPA you need to activate this PPA and you can then install it through apt, Ubuntu Software Center etc.

  1. Activate my PPA. You can find more details at or run the command apt-add-repository ppa:jonasped/ppa in a terminal.
  2. Update your package index with apt-get update from a terminal or use your fevourite GUI tool.
  3. Install DCC with the command apt-get install dcc-client or use your favourite GUI tool

Configuration

Configuration of DCC is really simple. All you need to do is to enable to the plugin in SpamAssassin.

  1. Edit /etc/spamassassin/v310.pre and enable the plugin Mail::SpamAssassin::Plugin::DCC.
That is it. You have now installed DCC and SpamAssassin will use DCC when tagging mail as spam.

HDAPS guide / TP-Smapi guide – old version

This is a guide I have written to get hdaps and the tp-smapi module to work on an Lenovo ThinkPad T500. Same guide should also work on the T400 model. These two models are more or less the same except for the screen size. Hdaps should also work on some Apple laptops.

This guide is written to work on Ubuntu, but it should also work on Debian.

Setup apt

The versions included in the Jaunty repositories are a bit outdated. Especially the hdapsd package. The easiest way to get the updated packages is to add another repository to apt. If you visit my PPA at https://launchpad.net/~jonasped/+archive/ppa you will find a pretty good guide on how to do this. Once you have added my PPA as a software repository you are ready to install the needed packages.

TP-Smapi

Now you are ready to install tp-smapi-source package. As the entire process requires some a console lets do all the installation from the console. Start up your favourite console. Start with installing tp-smapi-sources package. You do that by typing sudo apt-get install tp-smapi-sources. This will install the source code for tp-smapi. Next step is to compile the modules. Easiest way to do this is to type sudo module-assistant build tp-smapi. This will compile the source code and create a deb package with the modules. Next step is to install the modules. Easiest way to do this is to type sudo module-assistant install tp-smapi.

At this point we have the modules installed. Next thing is to load the modules. The T500 and T400 model needs a special option to the modules before it will load. What I have done is to make the modules load automatically when I boot my laptop. I have done this by addind a single line to /etc/modules. Fire up your favourite editor and open /etc/modules and add the following line to the file: thinkpad_ec force_io=1. We are now ready to actually load the modules. Do this by typing in sudo /etc/init.d/module-init-tools.

The modules are now loaded and you are ready to install the hdaps programs.

Hdaps

Hdapsd is a small daemon that parks the HD heads if the acceleration is too big. This is done to protect your harddrive against shocks. First you need to install the hdapsd package. You do that by typing in sudo apt-get install hdapsd. After installation it is time to start the hdapsd daemon. You do that by typing sudo /etc/init.d/hdapsd start. You can verify that hdapsd daemon is actually running by typing ps aux | grep hdapsd. The output should show a line containing /usr/sbin/hdapsd.

Further to above daemon there is a couple of small utilities that can show how you rotate your laptop real-time. These utilities are found in the package hdaps-utils. Install this package by typing sudo apt-get install hdaps-utils. After package is installed you can either runhdaps-pivot or hdaps-gl. Try to run hdaps-gl command and you will get something like below.
hdaps
As you can see above command is mostly to show that it actually works.

Ubuntu tips and tricks

Here you will find various tips and tricks for Ubuntu that I find useful. You will also find a link to my PPA and a short description of the packages that I have in my PPA.

Guides

You can find a few guides below for various tasks on Ubuntu Linux. Many of the guides can also be used for other distributions. You can also find links to the guildes in the menu to the right.

HDAPS

You can find a guide to get hdaps and tp-smapi to work on an Lenovo ThinkPad T500 here. The guide should also work on at least an Lenovo ThinkPad T400. The guide is written to work with Ubuntu.

Duplicity

A small guide on how my backup setup is. I use Duplicity and Amazon S3 for storage.

PPA

You can find my PPA at https://launchpad.net/~jonasped/+archive/ppa. I have these packages in my PPA because there are either bugs in the version found in Ubuntu, newer version is available or is simply missing from the official archive.i

Below is a list of packages that I currently have in my PPA.

hdapsd

This is an updated package. An updated version is required for it to work on newer Lenovo Thinkpad models like the T500. The package is available for Jaunty. You can find a setup guide here.

DCC

This is Distributed Checksum Clearinghouses. The package is not available in Ubuntu Jaunty. I have packed it for Intrepid, Jaunty, Karmic, Nattym, Oneiric and Precise and made it available on my PPA. I have created a seperate page with instructions on howto to use and install DCC.

Courier packages

I have a copy of the courier packages in my PPA as there is a minor bug in the version of courier included in Ubuntu 11.10 and Ubuntu 12.04. This minor bug causes IMP 5 to throw an error when showing certain mails. The patch fixes an UTF-8 encoding issue. Use this package if you have problems with IMP 5 and Courier IMAP server.

Note that if you are using Raring/13.04 the patch is included in the main Ubuntu archives.

Mediatomb

Mediatomb is a free UPnP mediaserver. This is a patched version that contains a patch so it supports Sony Bravia televisions. Use this updated package if you have issues with Mediatomb and Sony televisions. The package is available for Ubuntu 11.10 and Ubuntu 12.04.

Tvheadend

Tvheadend is a TV streaming server for Linux supporting DVB, IPTV etc. I use it for IPTV. I maintain a version that is based on the latest code in GIT and a few additional patches. The most important patch is the MPEG ts recording patch. Without this patch subtitles does not work on recordings for me.