Home‎ > ‎

raspbmc sharing files via nfs

How to share your media files with another pi running raspbmc. The examples below will share files from a USB drive attached to 1 pi (host) to another pi (client). It is assumed that the host has an IP address of and that a USB drive has been auto mounted on the host as /media/DriveName.

Setting up the host

set nfs kernel server to start on boot:
sudo update-rc.d rpcbind defaults
sudo update-rc.d nfs-common defaults
sudo update-rc.d nfs-kernel-server defaults
reboot your pi:
sudo service xbmc stop
sudo reboot
define your exports:
sudo nano /etc/exports
add a new line to the bottom of the file:
/media/DriveName *(ro,sync,no_subtree_check,insecure,all_squash,anonuid=0,anongid=0)
in theory the following is more secure but needs to be tested:
Here 192.168.1.x is the range of IPs which can connect on subnet 255.255.255.x (/24)
ro is readonly, we only want to read from the media, so don't need write access
insecure allows xbmc to access the files without root privileges
without the all_squash and anonuid and anongid, we are only allowing access to the same uid/gid as that connecting. As both machines have the same pi user, they have the same uid/gid and access is the same.
sync is not needed as it only helps when writing data, but we are using it read-only.
no_subtree_check will speed up access. We are exporting the whole drive, so don't need to worry about checks within it.
refresh exports:
sudo exportfs -ra

Setting up the client

Create a folder to act as the mount point. We are giving this the same mount point as on the host so that the raspbmc database will reference the files in the same folders on the host and the client:
sudo mkdir /media/DriveName
sudo chmod 777 /media/DriveName
Mount the drive on boot up:
sudo nano /etc/fstab
add a new line to the bottom of the file: /media/DriveName nfs defaults 0 0