Installing Tvheadend in unRAID

From Unraid | Docs
Jump to: navigation, search


Currently in V6 there are two equally brilliant options for installing TVHeadEnd.

1. Mettbrot's Plugin

2. Saarg's Docker Container

If using the docker then I can recommend [Saarg's DVB Check Plugin] to help ensure your Unraid system has the media tree and DVB drivers enabled and appropriate permissions set. This functionality is build in with Mettbrot's plugin so is only required for the docker container.

Media Build of Unraid V6

You still currently need a version of Unraid with media drivers enabled for use of DVB devices, I think, although I am not certain that homerun devices do not require this step.

I have been posting versions of these for Unraid V6 and will continue to do so at least until the V6 final. You can find them here, I'd recommend trying them first.

It is possible you may need to add additional drivers or firmware to the build so for that reason I'll outline how I currently do things. I use putty to connect to my Unraid box

Make A Directory To Work In

I use /mnt/cache/.unraid

mkdir /mnt/cache/.unraid

Go to this directory

cd /mnt/cache/.unraid

Get The Script

During my time working out how to accomplish this process, gfjardim very kindly gave me access to a script he wrote to accomplish this. I have adapted it slightly to suit this process a little better. It will download all the required packages, the appropriate kernel, slipstream modules and decompress and subsequently compress bzroot. In short it makes the process a whole lot easier.

Download the script


Change permission to enable it to run

chmod +x

EDIT: You can try my autobuild script. Still beta

chmod +x

Should be fairly self explanatory when used in conjunction with the instructions below, has options to create an Openelec, TBS or Digital Devices Experimental build.

Run The Script

You will then get asked a series of questions

1) Do you want to clean directories? 

Yes will clean any directories THAT THE SCRIPT CREATED on previous runs, it will not delete any folders or files that you have created. (Only deletes folders in /mnt/cache/.unraid named /kernel /bzroot /packages and the linux kernel download)

2) Do you want to install build dependencies? 

Yes you do!

3) Do you want to download and extract the Linux kernel?

Yes please!

3.1) Do you want to run Menu Config ?


For menuconfig there are only two relevant bits really. These are these two items below, in the subdirectory of Device Drivers. You can include them as modules or included in the kernel, doesn't seem to make much difference. Don't forget to delve into the subdirectories and their subdirectories to make sure you include everything you need. Personally I just include the whole lot.

Device Drivers --->
  Multimedia Support--->
  Sound Card Support--->
3.2) Do you want to compile the Linux kernel? 


3.3) Do you want to install Linux kernel modules?

Seems like a good idea..

4) Do you want to extract BZROOT?

Yes is the way forward here..

4.1) Do you want to slipstream compiled modules?

I do.

Add in any extra files

At this point I open an additional putty window from my windows machine and use that to add in additional fw files etc. I'll outline how I do my TBS drivers and how I do DVBSky drivers. You will need to alter things to suit your personal use case.

For TBS - This is the standard way to install TBS drivers No thanks to TBS for making these closed source so unable to be included in kernel

cd /mnt/cache/.unraid/
mkdir TBS
cd TBS
tar jxf linux-tbs-drivers.tar.bz2
cd linux-tbs-drivers
make -j $(nproc)
make install

Now to include them in our new bzroot

rsync -av /lib/modules/$(uname -r)/ /mnt/cache/.unraid/bzroot/lib/modules/$(uname -r)/
rsync -av /lib/firmware/ /mnt/cache/.unraid/bzroot/lib/firmware/

For CrazyCat TBS drivers Thanks to CrazyCat for these

cd /mnt/cache/.unraid/
mkdir TBS
cd TBS
make -j $(nproc)
make install

Now to include them in our new bzroot

rsync -av /lib/modules/$(uname -r)/ /mnt/cache/.unraid/bzroot/lib/modules/$(uname -r)/
rsync -av /lib/firmware/ /mnt/cache/.unraid/bzroot/lib/firmware/

For DVBSky

cd /mnt/cache/.unraid/
mkdir dvbsky
cd dvbsky
tar xvf dvbsky-firmware.tar.gz

Then to include in our new bzroot

rsync -av /mnt/cache/.unraid/dvbsky/dvbsky-firmware/ /mnt/cache/.unraid/bzroot/lib/firmware/

For Openelec Patch For More Tuners Thanks to CVH over at the Openelec forums for this

mkdir openelec
cd openelec
tar xvf dvb-firmware-CvH-1.5.tar.xz

Then to include in our new bzroot

rsync -av /mnt/cache/.unraid/openelec/dvb-firmware-CvH-1.5/firmware/ /mnt/cache/.unraid/bzroot/lib/firmware/

For DigitalDevices Experimental Build

hg clone
cd media_build_experimental
make download
make untar
make -j $(nproc)
make install

Then apply the ddbridge.conf fix

rsync -av /mnt/cache/.unraid/media_build_experimental/ddbridge.conf /mnt/cache/.unraid/bzroot/etc/modprobe.d/ddbridge.conf

To include in our new bzroot

rsync -av /lib/modules/$(uname -r)/ /mnt/cache/.unraid/bzroot/lib/modules/$(uname -r)/
rsync -av /lib/firmware/ /mnt/cache/.unraid/bzroot/lib/firmware/

Back To The Script

Now we've added in our additional drivers it's time to get back to our first putty window and finish things off..

4.2) Do you want to compress bzroot?

Yes - this will compress bzroot and you will find bzroot-mediabuild in /mnt/cache/.unraid/

5) Do you want to copy bzimage to /cache/bzimage-mediabuild?

Yes please.

Edit Syslinux.cfg

You should find two files in /mnt/cache/.unraid/ bzroot-mediabuild & bzimage-mediabuild, copy these to your flash drive, edit syslinux.cfg so it looks like this.

default /syslinux/menu.c32
menu title Lime Technology
prompt 0
timeout 50

label unRAID OS - Mediabuild
  menu default
  kernel /bzimage-mediabuild
  append initrd=/bzroot-mediabuild

label unRAID OS
  kernel /bzimage
  append initrd=/bzroot

label unRAID OS Safe Mode (no plugins)
  kernel /bzimage
  append initrd=/bzroot unraidsafemode

label Memtest86+
  kernel /memtest

Now reboot and if you've done it all right then you should be good to go!

Media build of unRaid V5

You need a version of unRaid with media drivers enabled. You can either go through the pages of the tvheadend plugin thread and see if someone has provided an image wth your specific driver. When your driver is implemented in kernel (search for your device here) you should be fine with a build with "media tree enabled". If your driver is not in kernel and noone has build an image with it yet you could always ask kindly :-P or compile it yourself:

compile yourself

You need unraid dev tools: download them and put them on your cache drive.

Here is a screenshot of the included packages for unRaid 5.0.5: Dev tools unraid5.0.5.png

Then follow the steps below:

How to compile and unRAID in minutes

# Put the unraid-dev.tar in /mnt/cache so you can cut and paste below.

cd /mnt/cache
tar xvf unraid-dev.tar

# Install all the Development Packages needed to compile a Linux Kernel

cd /mnt/cache/.unraid-dev/dev-packages
installpkg *.t*z

# Move default linux-3.9.11p-unRAID out of the way so we can create a new one. 
mv /usr/src/linux-3.9.11p-unRAID/ /usr/src/linux-3.9.11p-unRAID_original
tar -C /usr/src/ -xvf /mnt/cache/.unraid-dev/dev-packages/linux-kernel-3.9.11/linux-3.9.11.tar.xz
ln -sf /usr/src/linux-3.9.11 /usr/src/linux-3.9.11p-unRAID

# Copy over the all the unRAID stuff into our new Linux Kernel

cp -rf /usr/src/linux-3.9.11p-unRAID_original/* /usr/src/linux-3.9.11p-unRAID
cp -f /usr/src/linux-3.9.11p-unRAID_original/.config /usr/src/linux-3.9.11p-unRAID/

# Install Kernel Headers for our new Linux Kernel

installpkg /mnt/cache/.unraid-dev/dev-packages/linux-kernel-3.9.11/kernel-headers-

# Select the Linux Kernel Options you want compiled in the kernel or as modules
cd /usr/src/linux-3.9.11p-unRAID
make menuconfig <--- This is where you select what you want in the kernel or not. * = Compile into the kernel M = Module

# Compile Linux Kernel, Modules and install Modules into new Linux Kernel

make -j2 bzImage <--- Set -j to the number of processors you have
make -j2 modules <--- Set -j to the number of processors you have
make modules_install

# Compile new Linux Kernel to the new-bzfiles folder

cp arch/x86/boot/bzImage /mnt/cache/.unraid-dev/new-bzfiles/bzimage

# Preperation for new bzroot

rm -r /mnt/cache/.unraid-dev/bz-mod <--- Just in case, remove old directory
mkdir /mnt/cache/.unraid-dev/bz-mod
cd /mnt/cache/.unraid-dev/bz-mod

# unzip stock unRAID-5.0.5 bzroot into bz-mod folder

xzcat ../unRAID-5.0.5/bzroot | cpio -i -d -H newc --no-absolute-filenames

# Copy any new modules you created into our new bzroot folder

rsync -av --delete /lib/modules/3.9.11p-unRAID/ /mnt/cache/.unraid-dev/bz-mod/lib/modules/3.9.11p-unRAID/

# zip bz-mod folder into bzroot and copy to new-bzfiles folder

find . | cpio -o -H newc | xz --format=lzma > /mnt/cache/.unraid-dev/new-bzfiles/bzroot 


  • dont forget to copy you firmware files to /mnt/cache/.unraid-dev/bz-mod/lib/firmware/ right before the last step!
  • for menuconfig:
    • Enable Media
    • For some Realtec Ethernet cards you have to enable r8169 driver under Ethernet drivers
    • ALSA - PCI must be enabled

Replace bz-files and reboot

Finally Replace the bzimage and bzroot files on your flash drive with the new ones either from the forum or you own-compiled ones. Reboot.

Install Tvheadend package

You have two options:

Old Instructions

Use these instructions with discretion.

This guide is a walk through for unRAID users that want to be able to compile their own custom kernel in order to enable Multimedia features, and therefore compile and run Tvheadend on an unRAID server. Note that for compiling a kernel requires huge amount of RAM.

These steps made and tested only on unRAID 4.7 and might need to be altered for 5.x series.


First of all, you have to satisfy these dependencies:

a) Vanilla copy of Linux kernel;

b) gcc, glibc, binutils, make, patch, perl, ncurses, cpio, pkgtools, cxxlibs, libidn, curl, pkg-config, openssl and infozip packages;

c) Tvheadend source;

d) Vanilla copy of unRAID in the format downloadable from Lime-Technology

At the time of writing, using unRAID 4.7, all those packages can be found at the following locations:

Installing the kernel source and prepare for compiling

First, download and install all ".tgz" packages above. Make sure you're in the root directory:

$ cd

Create a folder for the packages, then go into this folder:

$ mkdir packages
$ cd packages

Download the above packages one by one:

$ wget <linksabove>

Install all the downloaded packages:

$ installpkg <filename>.tgz

You also need to create a temporary directory on one of your drives (instead of the flash drive), because symlinks are not supported on the FAT file system the flash drive formatted with. I used the cache disk for that purposes, but potentially you can use any drive for this.

$ mkdir /mnt/cache/.unraiddev

Unzip the downloaded unRAID package to this folder:

$ unzip unRAID* -d /mnt/cache/.unraiddev/

Go to "/usr/src" directory, and rename the folder "linux" to "linux_original".

$ mv /usr/src/linux /usr/src/linux_original

Now extract the vanilla kernel file (e.g. linux- ) into "/usr/src":

$ tar -C /usr/src/ -zxvf linux-

Link the new source directory (e.g. linux- ) to "/usr/src/linux" path:

$ ln -sf /usr/src/linux- /usr/src/linux

Copy all default drivers and configuration to the new source directory: Code:

$ cp -rf /usr/src/linux_original/* /usr/src/linux-
$ cp -f /usr/src/linux_original/.config /usr/src/linux-

Link kernel headers includes to the new source includes:

$ ln -sf /usr/src/linux/include/asm-generic /usr/include/asm-generic
$ ln -sf /usr/src/linux/include/linux /usr/include/linux
$ ln -sf /usr/src/linux/arch/x86/include/asm /usr/include/asm

Configure and Compile the new Kernel

Be prepared, because here comes the 2nd hardest part (the hardest comes later): you need to reconfigure the kernel config to enable Multimedia support:

$ cd /usr/src/linux/
$ make clean
$ make menuconfig

You're in the kernel configuration utility. Scroll down and select (press enter):

$ Device Drivers --->

Now go down to

$ Multimedia Support --->

and press an 'M' on it to compile it as a module. After that, go into Multimedia support (press enter), then configure

$ Video for Linux --->

to be compiled as a module as well by pressing 'M' on it.

After that press 'SPACE' on

$ Enable Video For Linux API 1 (DEPRECATED)

and leave only the new there.

Following that you have to enable the support for your tuner card. To be on the safe side first I suggest not to select your card specifically (unless you're a real expert), but enable the entire

$ DVB for Linux

as a module (unless you only have an analoge card whereas you might only need Video for Linux, but I cannot test this myself) by pressing 'M' once more. (I tried to be smart and selecting only the card I have, but it turned out at the end that DVB-S cards require a SEC controller to be configured as well which I didn't do and spent a week to figure this out)

Probably you also need to dig into

$ Video Capture Adapters and configure the appropriate Video Encoders according to what is on your card.

Once configured everything select 'EXIT' until you see a question: 'Do you wish to save your new kernel configuration?'. Select yes here.

$ make bzImage
$ make modules
$ make modules_install

Package new bzimage and bzroot files

Copy the fresh bzImage to your boot directory:

$ cp arch/x86/boot/bzImage /boot/bzimage_new

Create a temporary directory and extract the vanilla unRAID bzroot into it:

$ mkdir /mnt/cache/.unraiddev/bz-mod
$ cd /mnt/cache/.unraiddev/bz-mod
$ zcat ../bzroot | cpio -i -d -H newc --no-absolute-filenames

Backup the 'Extra' directory from it, because it will be removed during syncronization with the new kernel modules:

$ cp -r lib/modules/ /root/

Syncronize (overwrite) the extracted vanilla modules with the newly compiled modules:

$ rsync -av --delete /lib/modules/ /mnt/cache/.unraiddev/bz-mod/lib/modules/

Copy back the saved 'extra' folder after syncronization.

$ cp -r /root/extra/ /mnt/cache/.unraiddev/bz-mod/lib/modules/

...and here comes the hardest part: you will need to find and place a proper firmware file for your tuner card (note that you also need the firmware file according the firmware version in your card). You're alone with this. I can only use my card as an example here (Hauppauge WinTV-NOVA-HD-S2). This part will not work with another card, again, this is only an example.

$ cd /mnt/cache/.unraiddev/bz-mod/lib/firmware/
$ wget
$ unzip -jo Driver88/hcw88bda.sys
$ dd if=hcw88bda.sys of=/lib/firmware/dvb-fe-cx24116- skip=105768 bs=1 count=32674
$ ln -s /lib/firmware/dvb-fe-cx24116- /lib/firmware/dvb-fe-cx24116.fw

Finally to package the new bzroot:

$ cd /mnt/cache/.unraiddev/bz-mod/
$ find . | cpio -o -H newc | gzip > /boot/bzroot_new

Congratulations, now you have your new bzImage and bzroot files which supports Multimedia.

Installing Tvheadend

Make a directory to store your configuration (e.g. /boot/custom/htsconfig), then go into /boot/custom folder.

$ mkdir -p /boot/custom/htsconfig
$ cd /boot/custom/

Checkout the newest Tvheadend, then enter to its directory:

$ git clone git://
$ cd tvheadend

Configure it with:

$ ./configure --release --disable-avahi

To compile:

$ make

Running Tvheadend

glibc is a runtime dependency, so you will need to reinstall this package on every reboot.

$ mv /root/packages/glibc-2.7-i486-17.tgz /boot/custom/tvheadend

To have glibc reinstalled on every reboot, edit your go script and add:

$ installpkg /boot/custom/tvheadend/glibc-2.7-i486-17.tgz

To run Tvheadend on every reboot add the following line as well to your go script:

$ /boot/custom/tvheadend/build.Linux/tvheadend -c /boot/custom/htsconfig -u root -g video -f

Switch to new bzimage and bzroot files

Now to boot up with your Multimedia enabled kernel you still need to switch to the new image files we created above.

First, make a backup from the original bzimage and bzroot:

$ mv /boot/bzimage /boot/bzimage_original
$ mv /boot/bzroot /boot/bzroot_original

Then rename the newly created image files:

$ mv /boot/bzimage_new /boot/bzimage
$ mv /boot/bzroot_new /boot/bzroot

After a reboot all the above created temporary files and packages will be removed from the flash drive, the only place you have to remove it manually is the drive you used for packaging unRAID:

$ rm -R /mnt/cache/.unraiddev

Now reboot your unRAID and after the next bootup you should be able to access tvheadend via a web browser:

$ tower:9981

If you don't see your tuner card in Tvheadend configuration panel, then something went wrong during kernel configuration.