crazy content for mankind, great stuff for nerds

27 Jul 2018

Installing TVHeadend on RPi2 with Arch Linux

A Raspberry Pi is perfectly suited to run a TVHeadend server - for receiving Live TV, for example. In this post I explain, how such as server can be installed on an RPi2 with Arch Linux.

I would like to receive Live-TV via DVB-T2 and stream it into my LAN. As streaming server I would like to use TVHeadend. In my setup, the DVB-T2 signal is received by an antenna, which is connected to an USB tuner, which in turn is connected to the RPi. The RPi is connected to the LAN and streams the Live-TV.

Often, Raspbian is used as OS for a RPi, but since I am a fan of Arch Linux I wanted to use this as basis for my server. For this project I use the ARM port of Arch Linux. In a nutshell, the following steps need to be executed:

  1. Install Arch Linux
  2. Configure Arch Linux (this includes setting a static ip address and enabling sudo - which is needed for the subsequent steps)
  3. Install Yaourt
  4. Install TVHeadend from AUR
  5. Configure TVHeadend and run it as service

I use an RPi model 2, but this instruction could also be used to install Arch Linux and TVHeadend on other computers with an ARM board. Just download the appropriate version of Arch Linux ARM and follow the corresponding installation guidelines for Arch Linux ARM.

This Gist only contains the steps to set up the TVHeadend server. Since the configuration of DVB-T2 in TVHeadend is depending on the country, it is not covered here. A good instruction for Germany is [3].

Since I was asked which hardware besides the RPi I am using: As USB TV tuner I use the DVBSky T330 receiver which is currently sold in a bundle with a small antenna. The USB receiver is recognized by Arch Linux ARM out-of-the-box. But it needs firmware moduls in addition. They can be downloaded from the manufacturers’ web site. After you went through the entire installation instruction below, just unzip the downloaded firmware archive and copy the *.fw files via scp to the RPi to the directory /lib/firmware. Reboot and you should be done.

Install Arch Linux on Raspberry Pi 2

According to the howto on [1], Arch Linux ARM will be installed on the RPi2. Replace sdX in the following instructions with the device name for the SD card as it appears on your computer.

Start fdisk to partition the SD card:

$ fdisk /dev/sdX

At the fdisk prompt, delete old partitions and create a new one:

  1. Type o. This will clear out any partitions on the drive.
  2. Type p to list partitions. There should be no partitions left.
  3. Type n, then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +100M for the last sector.
  4. Type t, then c to set the first partition to type W95 FAT32 (LBA).
  5. Type n, then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.
  6. Write the partition table and exit by typing w.

Create and mount the FAT filesystem:

$ mkfs.vfat /dev/sdX1
$ mkdir boot
$ sudo mount /dev/sdX1 boot

Create and mount the ext4 filesystem:

$ mkfs.ext4 /dev/sdX2
$ mkdir root
$ sudo mount /dev/sdX2 root

Download and extract the root filesystem (as root, not via sudo):

$ wget
$ sudo bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
$ sync

Move boot files to the first partition:

$ sudo cp -r root/boot/* boot/.
$ sudo rm -rd root/boot/*

Unmount the two partitions:

$ sudo umount boot root

Configure Arch Linux on RPi2

Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power. Use SSH to the IP address given to the board by your router. Login as the default user alarm with password alarm (the default root password is root).

$ ssh alarm@<ip-address>

Configure Pacman and upgrade system

Initialize the pacman keyring and populate the Arch Linux ARM package signing keys:

$ su
$ pacman-key --init
$ pacman-key --populate archlinuxarm

Upgrade system:

$ pacman -Syu

Enable Sudo

Install sudo:

$ pacman -S sudo

Configure sudo:

$ nano /etc/sudoers

Remove the comment sign in front of the row

%wheel      ALL=(ALL) ALL

Save the file (CTRL+O, ENTER) and exit (CTRL+X).

To allow user alarm to use sudo, add the user to group wheel:

$ gpasswd --add alarm wheel

Configure network

Set static ip address

Adjust file /etc/systemd/network/ (replace eth0 with your interface):

$ nano /etc/systemd/network/

Remove line


Add the lines (replace the ip addresses with your addresses):


Save the file (CTRL+O, ENTER) and exit (CTRL+X).

Set host name

Edit file /etc/hostname:

$ nano /etc/hostname

Replace the default host name with your host name. Save the file (CTRL+O, ENTER) and exit (CTRL+X).


Reboot the system:

$ reboot

Install Yaourt

This installation instruction is taken from [2].

Login as default user via SSH (now, you have to use the static ip address of the RPi):

$ ssh alarm@<static-ip-address>

Prepare dependencies

Install dependencies:

$ sudo pacman -S --needed base-devel git wget yajl

Download and make package-query:

$ git clone
$ cd package-query
$ makepkg -si
$ cd ..

Download and make Yaourt

$ git clone
$ cd yaourt
$ makepkg -si
$ cd ..

Clean up

Source code isn’t needed anymore:

$ sudo rm -rd yaourt package-query

Install and set up TVHeadend

Install TVHeadend (this takes a while):

$ yaourt -S tvheadend

Set up TVHeadend as service:

$ sudo systemctl enable tvheadend.service
$ sudo systemctl start tvheadend.service

You should now be able to access the browser UI of TVHeadend via the URL http://<static-ip-address>:9981.

Have fun with TVHeadend!


[1] Arch Linux ARM on Raspberry Pi 2

[2] Install Yaourt in Arch Linux

[3] Howto: Setup german DVB-T2 channels

comments powered by Disqus