From MythTV Official Wiki
Revision as of 00:32, 28 January 2010 by Wpcprez (talk | contribs) (NFS install)

Jump to: navigation, search

The Problem

You have setup a location for music or video files perhaps on your backend and you want to access these files from a frontend. This is slightly complicated by the fact that all systems need to share media from the same location or the mythdatabase will store the locations twice.

The Solution

Several ways of sharing a directory from one machine to others exists on Linux. Samba and NFS are the two most commonly used for this purpose.

Samba is intended for sharing folders to Windows machines, but can also be used between Unix/Linux machines. NFS is an old-school Unix protocol, but Windows can be set up to read NFS exports (though not without 3rd party applications as far as I know).

For the purposes within this article NFS is the easiest by far, so we will concentrate on this. Please note that NFS by default will not be particularly secure. It is assumed that this is to be used on a semi-secure network, and that the traffic transmitted is not particularly confidential (TV recordings shouldn't be as far as I am concerned).

One gotcha here is that NFS requires userids to be the same on server and client. Assuming your user is "mythtv" you can check this with this command on boths server and client:

 id mythtv

This will produce something like this:

 uid=105(mythtv) gid=105(mythtv) groups=105(mythtv),20(dialout),24(cdrom),29(audio),44(video)

The only part we are interested in here is the uid field. This is 105 in this case.

If the uid is the same on server and client you can proceed with the below instructions. If not, you will have to fix this now as NFS uses UID, and not usernames for access control by default.

NFS install

This part assumes you are using a Debian/Ubuntu-like installation. Fedora/RedHat/Other installations may use yum install instead, and the package names may differ from the below. Consult your OS' documentation or online resources if you don't know how to do this on your distribution.

First install the following on the backend AND the frontend, though you may have these installed already.

$ sudo apt-get install nfs-kernel-server portmap nfs-common

For this example the media i wish to share is at


It's a folder on a harddrive mounted at /media on my backend. It may not be the same on your setup, so adjust accordingly. It is possible to get fancy with symlinks/hardlinks, but this is outside the scope of this article. Also it makes no difference technically - only cosmetic.

$ sudo nano /etc/exports

add the following line


Which breaks down to this:

This is the directory you want to export 
This allows any machines in the 192.168.1.x network access to the share. /24 is the netmask (meaning You can also specify individual ip addresses or hostnames here.
These are NFS options. rw means that the client will have read/write access. no_root_squash means root on the clientside will have write access (disabled by default for security reasons). async means file operations are A-synchronous - this increases performance. These are basic ones, and many more can be added. (see exports(5), exportfs(8), nfsd(8), for more).

At this point you should re-export the export list.

$ sudo exportfs -a

Any errors will be printed to the screen. Different distributions and NFS server versions will be configured differently, and you may need to specify different options than what is supplied above. Please note that the NFS server may warn you about some options, and select a safe default instead and continue with the export. There can also be fatal errors where the server refuses to continue. These will have to be fixed before you can continue.

On the client:

$sudo mount mybackend:/media/mediashare /media/mediashare

replace mybackend with the name or ip of the pc having your media directory.

for this mount to work you need the exact same file path

 mkdir -p /media/mediashare

hint: -p creates parent dirs if required

now you should be able to successfully mount the folder in the client pc, and both pc's frontend and backend report media at /media/mediashare/

Isn't that cool

to make it stick you need an entry in fstab

$ sudo nano /etc/fstab
mybackend:/media/mediashare /media/mediashare nfs auto 0 0 

now in your mythfrontend music you would set the filepath as (if it was video it'd be pretty much the same)


and scan for new music, (actually rather than scan from a remote frontend do it from the pc holding the actual files otherwise it will be very slow to scan).

Thats pretty much it job done make another export for music or video and now all video and music are stored on your server and accessible.

 Warning: NFS deals with partitions.

If you have partitions below the path we have specified it will also have to be exported. For example: /media/mediashare/video and /media/mediashare/music being separate partitions/mountpoints. Simply add another entry to /etc/exports on the server, and another line to /etc/fstab on the client.

Multiple paths

If you have video in 2 or more locations separate the paths with a colon :


/var/lib/mythtv/videos/ : /media/morevideo/videos 

This will be in general in your mythfrontend setup