Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

FreeNAS Media Server with PlexMediaServer and Mythtv

Status
Not open for further replies.

mysticpete

Member
Joined
Nov 2, 2013
Messages
124
Create a Media Server hosting FreeNAS, Mythtv, PlexMediaServer, Transmission, Couchpotato and Sickbeard

Most recent details for this build can be found Here

I'm creating a media server and have been developing a solution for sometime, below you will find instructions for installing and configuring a very powerful media machine. These are the steps I have taken to accomplish the task, however they may not all work for you, take care to look for any errors at the end of each install, especially Mythtv looking for Lame.

I must first point out that much of the leg work has been done by others and where possible I have acknowledged them.

I thoroughly recommend starting with a fresh OS load, if you already have storage you can easily add it back in after by importing it, save your configuration before starting this.

Base Hardware:


I'm using an HP N54L server running 6GB of memory, 5 x internal 2TB WD RED hard disks for storage
TV will be supplied by a HD Homerun dual TV tuner, the benefit of this is it's flexibility in transmission out the box to many devices.
The FreeNAS OS and jails are installed on a 64GB mini SSD mounted on the PCI x1 slot
I do not intend to cover the process of installing the FreeNAS OS as this is readily available on the FreeNAS sites.



First Steps

A word about pkg-ng commands

This command set is a replacement for pkg_add as this is being phased out over the coming months (On my version of FreeBSD9-2-0 I was able to install it from the ports directory).

The command when used will download from its current ftp version i.e. entering # pkg install mythtv may look in the 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-stable/Latest/' listing

So if you have a different version of FreeNAS installed, I would suggest installing the packages from that version (if they are available) i.e. if you have, like me FreeNAS 9.2.1 then you want files from the ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.2-release.

You receive the error "pkg: No packages matching '<Package-name>' available in the repositories"

This is because the package listing that pkg install is looking in does not contain the Package being requested, so you will need to install it from another version, you can check this by looking in the packages listing from a web browser i.e. ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-stable/Latest/
If it's not listed in it's respective application directory then go up 2 levels and pick another version and look in the folder for that version...


Index of ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/

Up to higher level directory
Name Size Last Modified
packages 19/04/2007 12:00:00 AM
packages-8-stable 11/02/2014 10:02:00 PM
packages-8.3-release 28/03/2012 12:00:00 AM
packages-8.4-release 9/05/2013 12:00:00 AM
packages-9-current 9/12/2011 12:00:00 AM
packages-9-stable 11/02/2014 10:32:00 PM
packages-9.1-release 11/04/2013 12:00:00 AM
packages-9.2-release 3/09/2013 12:00:00 AM
packages-stable 7/11/2011 12:00:00 AM


So to pick up the version you need to install type the full path at the command prompt using pkg add command:

e.g. pkg add ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release/multimedia/mythtv-0.26.0.tbz


Now let's get started....


To install the following plugins I recommend you use Zufallsheld's very comprehensive installation guide http://zufallsheld.de/2013/11/22/freenas-transmission-couchpotato-sickbeard-dlna-server/ for these.....

Plexmediaserver
Couchpotato
Transmission
Sickbeard

There are a couple of things I found when I followed this and I still have to fix some of the folder ownership issues. On the whole this is very well documented installation, and it all works.


Setup the Mythtv Jail


My research into previous setups did not reveal any examples getting this working on a FreeNAS server, only others asking the same questions. I came across a couple of other guys trying to get this going and so I pitched in to collaborate (the more hands the better) and this can be found on John Payne's blog http://blog.heiren.us/2013/11/mythtv-server-on-freenas.html?showComment=1386694184546 from which the next sections have been tidied up and I have added the extra requirements to.

Firstly create a mythtv jail in FreeNAS (standard plugin jail)

login to the jail


Run the following commands in sequence....


root@mythtest:/ # portsnap fetch extract


Install the additional packages for Mythtv


root@mythtest:/ # cd /usr/ports/audio/lame && make install clean
root@mythtest:/ # pkg install libXv (libXv has a CAPITAL 'X')
root@mythtest:/ # pkg install qt4-webkit
root@mythtest:/ # pkg install xauth
root@mythtest:/ # pkg install xorg-fonts



Install Mythtv

Currently there have been a number of issues reported with Myth versions above 9.2.0 and I would suggest at this time to Only use this version until the next stable version is advised.

root@mythtest:/ # pkg install mythtv

Add the following to /etc/rc.conf


root@mythtest:/ # echo 'mythbackend_enable="YES"' >> /etc/rc.conf
root@mythtest:/ # echo 'sshd_enable="YES"' >> /etc/rc.conf
root@mythtest:/ # echo 'mysql_enable="YES"' >> /etc/rc.conf



Install SQL server


root@mythtest:/ # pkg install mysql55-server

mysql will automatically create the user 'mysql' and group 'mysql' with UID (88) (no_password)

Start mysql


root@mythtest:/ # service mysql-server start


Add the following for the database setup


root@mythtest:/ # mysql < /usr/local/share/mythtv/database/mc.sql
root@mythtest:/ # mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql


If the above fails try this......

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot -p mysql --force 2> /dev/null

After this, login to mysql and check the timezone:

root@mythtest:/ # mysql -p

Enter password:<no_password>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3Server version: 5.5.33 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates.
All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates
Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------------+---------------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------------+---------------------------+
| SYSTEM | SYSTEM |
+--------------------------+---------------------------+
1 row in set (0.00 sec)
This shows that mysql is using the system for it's timezone, there are other options but I am not going to go into these here.
Type exit to leave mysql


Now check the mythtv database entry
root@mythtest:/ # mysql -u root -p'<password>' -e 'show databases;'



Change the mysql password


root@mythtest:/ # mysqladmin -u root password <NEWPASSWORD>

Test the new password with # mysql -p


Setup X11 Forwarding


root@mythtest:/ # echo 'ListenAddress <youripaddress>' >> /etc/ssh/sshd_config
root@mythtest:/ # echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
root@mythtest:/ # echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config
root@mythtest:/ # echo 'X11Forwarding yes' >> /etc/ssh/sshd_config
root@mythtest:/ # echo 'X11UseLocalhost no' >> /etc/ssh/sshd_config



Restart sshd


root@mythtest:/ # service sshd restart
root@mythtest:/ # ssh -Y root@<mythtv jail ip> /usr/local/bin/mythtv-setup



Setup Remote X11 access from your PC/Laptop


Download Xming from here: http://sourceforge.net/projects/xming/
Download PuTTY from here: http://www.putty.org/

1) Install Xming server and start it on your local machine

2) Install PuTTY on your local machine

3) Configure the default profile in PuTTY with the IP and SSH port of your myth Server

4) Go to the Connection panel then select ssh and enable compression, then the x11 tab and check "Enable x11 Forwarding" box, then enter localhost:0 in the "X Display Location" and check "MIT-Magic-Cookie-"

5) Go to "Session" and hit the save button

With the Xming server started, open the PuTTY session you saved and login (with the user you created earlier) to the myth server, then type....

root@mythtest:/ # mythtv-setup

this will open an Xwindow on your local screen and load the myth setup screen.
If you get a message saying X11 server not found then you did something wrong.



Summary


By now we should have all our apps running and be able to forward ssh to our laptop or desktop to setup the mythtv.
Just a note here that I am not installing myth-web and so will not be covering that here for now.



Added users to Mysql to allow remote access to Mythtv

I am using XNMC Mythbox to access my Mythtv backend, you may use other apps, the most important thing to remember here is that nothing will be able to access the database until you allow remote access in mysql. At installation mysql server blocks connections from IP's other than the loopback 127.0.0.1. To add your access you will need to create a user and host, give it grants to the database and ensure the frontend can access the back.

To add a the user:

root@mythtest:/ # mysql -u root -p
Enter password <password>


mysql> CREATE USER 'mythtv'@'host' IDENTIFIED BY 'password';

set the privileges on the mythtv database

GRANT ALL PRIVILEGES ON mythconverg. * TO 'user'@'host';

exit from mysql.

To test access to the db, first we will try from a localhost

root@mythtest:/ # mysql -u <user> -p<password> -h localhost

root@mythtest:/ # mysql -u mythtv -pmythtv -h localhost

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 135
Server version: 5.5.36 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql>exit;

and now echoing the remote user

root@mythtest:/ # mysql -u <user> -p <password> -h <mythtvipaddress>

root@mythtest:/ # mysql -u mythtv -p -h 192.168.1.xx
Enter password: <password>


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 137
Server version: 5.5.36 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql>exit;

If you are able to access mysql in this way then it should work the same from the remote machine.
 
Last edited:

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Woot! Popped your guide-writing cherry!
 

doctor15

Junior Member
Joined
Apr 26, 2014
Messages
16
Is anyone able to get MythTV working with FreeNAS 9.2.1.5?

If I do "pkg add ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.2-release/multimedia/mythtv-0.26.0.tbz" (which seems to be the most recent binary package available) I receive an error "pkg: /tmp/mythtv-0.26.0.tbz.7vd96 is not a valid package: no manifest found"

I tried make install clean from the port, but also received a number of errors.

I already have FreeNAS installed and working so I would prefer not to have to downgrade and mess with my whole NAS configuration to get mythtv working.
 

mysticpete

Member
Joined
Nov 2, 2013
Messages
124

doctor15

Junior Member
Joined
Apr 26, 2014
Messages
16
I upgraded to 9.2.1.5 to cure the smbd issues and all add-ons are working OK with this version, the error you are getting is not version related, the package is no longer there, follow my tutorial to find and install mythtv.
http://mysticpete.blogspot.com.au/2014/03/create-media-server-hosting-freenas.html
Thanks! I really appreciate your guide and followed the instructions to browse the package repository and ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.2-release/multimedia/mythtv-0.26.0.tbz does exist. Which package did you use to build?



BTW, I was able to figure out what was wrong with doing a make using ports, so fingers crossed that might work out.
 

mysticpete

Member
Joined
Nov 2, 2013
Messages
124
yes I used 0.26.0 also I believe 0.27.0 does not work well with XBMC currently, that maybe resolved now though?
 

tophee

Member
Joined
Oct 27, 2011
Messages
71
Hi,

After something of a hiatus on this, I'm trying to get mythtv this working again on my FreeNAS box. I'm running FreeNAS-9.2.1.7-RELEASE-x64 (fdbe9a0). Every time I try and install the MythTv port I get the message
root@mythtv:/ # pkg add ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9
.2-release/multimedia/mythtv-0.26.0.tbz
[mythtv] Fetching mythtv-0.26.0.tbz: 100% 153 MB 7.6M/s 00:21
pkg: /tmp/mythtv-0.26.0.tbz.XXXXX is not a valid package: no manifest found

Failed to install the following 1 package(s): ftp://ftp.freebsd.org/pub/FreeBSD/
ports/amd64/packages-9.2-release/multimedia/mythtv-0.26.0.tbz
Any ideas? I've looked at all the available ports at ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/ and tried all the available options.

Many thanks
 

Whattteva

Neophyte Sage
Joined
Mar 5, 2013
Messages
729
Have you tried updating your package listing first with pkg update?
 

tophee

Member
Joined
Oct 27, 2011
Messages
71
Hi Whattteva. Thanks for the reply. No don't think so. Will try that and give it another go.
 

tophee

Member
Joined
Oct 27, 2011
Messages
71
Well, I started over with my mythtv jail and issues the pkg update right at the beginning, but still getting the ""not a valid package: no manifest found".
 

diedrichg

Neophyte Sage
Joined
Dec 4, 2012
Messages
1,306

Whattteva

Neophyte Sage
Joined
Mar 5, 2013
Messages
729
You could also do that.
A word of advice though. Just don't make it a habit if you're not comfortable with troubleshooting dependencies that often arise when you're compiling things from source though. That and mixing packages and sources usually don't end well.
That being said, if you have one or two installations from source and don't make it a habit, you should be ok.
 

diedrichg

Neophyte Sage
Joined
Dec 4, 2012
Messages
1,306
You could also do that.
A word of advice though. Just don't make it a habit if you're not comfortable with troubleshooting dependencies that often arise when you're compiling things from source though. That and mixing packages and sources usually don't end well.
-DBATCH
 

tophee

Member
Joined
Oct 27, 2011
Messages
71
Well, I won't have a chance to do anything til at least Monday night. But I think my ability to troubleshoot dependencies is fairly limited as my understanding of such things is fairly basic. Kinda monkey see monkey do....
 

mysticpete

Member
Joined
Nov 2, 2013
Messages
124
Hi,

After something of a hiatus on this, I'm trying to get mythtv this working again on my FreeNAS box. I'm running FreeNAS-9.2.1.7-RELEASE-x64 (fdbe9a0). Every time I try and install the MythTv port I get the message


Any ideas? I've looked at all the available ports at ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/ and tried all the available options.

Many thanks
What's with all this XXXX on the end of the file?
 

tophee

Member
Joined
Oct 27, 2011
Messages
71
I wonder that too. I've copied and pasted the location into the terminal from the ftp site. It is what appears in the terminal after it fails. Is there somewhere I can get further info?
 

JR Gonzalez

Member
Joined
Aug 29, 2014
Messages
64
Well, I started over with my mythtv jail and issues the pkg update right at the beginning, but still getting the ""not a valid package: no manifest found".
What version of FreeNAS are you running? I used a standard jail in 9.2.1.7. I had to install lame from the ports tree (there's no way around this, lame has been flagged as bad):

--- fresh standard jail ---

# pkg update
... fun stuff
# pkg upgrade
... more fun stuff
(assuming you have mounted a ports tree or installed it in the jail)
# cd /usr/ports/audio/lame
# make install
(just pick defaults if you actually get a bunch of dep options. I don't remember getting many if any at all)
# pkg install mythtv

It will install roughly 200 pkgs. After that you can move onto the mythtv.

By the way. Very important. Use vimage for the jail. You need to xforward. Can't do that without vimage (can't use vnc either).
 

tophee

Member
Joined
Oct 27, 2011
Messages
71
Hi JR Gonzallez. Thanks for your input. That got me much further. I had problems with lame but went back to the original guide and went from there. Don't know if that was right, but was able to get myth installed. I'm now struggling with forwarding X11. Still making progress.
 

JR Gonzalez

Member
Joined
Aug 29, 2014
Messages
64
You MUST make sure you made the jail with vimage enabled. Otherwise it won't work. For x11forwarding you have to enable it in /etc/ssh/sshd_config and there should be a line that says...

X11Forwarding yes

You also need to install xauth

# pkg install xauth


You also need to make sure your client is set up to forward X11. In linux all you need to do is add -X to ssh:

$ ssh -X user@hostname

In windows you need to install an xserver. The easiest (and cheapest I suppose) is to use Cygwin/X:

http://x.cygwin.com/docs/ug/setup-cygwin-x-installing.html

Then configure your client to use it. I believe putty/kitty have the option somewhere in there. You'd have to look that up. It's not hard at all tho once you have the xserver running.
 
Last edited:

tophee

Member
Joined
Oct 27, 2011
Messages
71
Ahhhhhhhhhh. Of course. I added xauth to my jail and can now run mythtv-setup with X11 being exported to my laptop. Brilliant. Thanks
.
 
Status
Not open for further replies.
Top