5

I am planing to buy RaspberryPi 3 and have it connected to my TV. I also have a lot of movies on Windows partition in my dual boot Ubuntu 14.04 & Win 8 machine (Win 8 isn't used, but is there). I would like to share the movies folder to RaspberryPi over my WiFi, so that I can watch movies on TV without loading the movie file to RaspberryPi.

Can this be done and how?

2
  • 1
    If you use the Kodi image for raspberry pi, you get inbuilt support for NFS and Samba. Then all you need to do is setup the service on your server as the other answers describe.
    – Potaito
    May 26 '16 at 12:51
  • 2
    I use webdav to stream over http protocol. In this case the media player is aware that it is using a network resource and it can properly configure settings like buffering. I had some bad experience with network filesystems as an application trying to cache a multi-GB file can freeze a system (and the whole local network) for several minutes.
    – DarioP
    May 26 '16 at 13:55
12

my favourite method is via SSHFS.

  1. Install openssh server on your Ubuntu machine: sudo apt-get install openssh-server

  2. Install sshfs on the Raspberry Pi (don't know the package name for the distro you're running), in Ubuntu:sudo apt-get install sshfs

  3. Connect to your ssh server by mounting a folder:sshfs username_on_server@server_ip:/location_of/movies_on_Server /mountpoint/on_rasberry_pi

  4. You might have to add your Rasberry Pi user to the fuser group: sudo useradd -G {group-name} username

  5. to unmount the remote folder: fusermount -u /mountpoint/on_rasberry_pi

Enjoy.

1
  • Until step 3 all was good, but on 4 what fuser group is that? And on 5 I had the error fusermount: entry for /mnt/backup not found in /etc/mtab (being /mnt/backup my mount point on raspberry pi)
    – brasofilo
    May 9 '20 at 4:43
5

In addition to the above, you could use samba shares. Instructions are here.

This is definitely supported by KODI (openELEC, Osmc or other), which is what I would install on the raspberry pi, if you want to use it as a media player for the TV, and resembles my setup.

(Though I think kodi also sees NFS)

Here is a summary of the instructions (credit goes to the original author):

Procedures

Install Samba

    sudo apt-get update
    sudo apt-get install samba

Set a password for your user in Samba

    sudo smbpasswd -a <user_name>

Note: Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you'll need to create a Samba password for yourself. This tutorial implies that you will use your own user and it does not cover situations involving other users passwords, groups, etc...

Tip 1: Use the password for your own user to facilitate.

Tip 2: Remember that your user must have permission to write and edit the folder you want to share.

        Eg.:
        sudo chown <user_name> /var/opt/blah/blahblah
        sudo chown :<user_name> /var/opt/blah/blahblah

Tip3: If you're using another user than your own, it needs to exist in your system beforehand, you can create it without a shell access using the following command : sudo useradd USERNAME --shell /bin/false

You can also hide the user on the login screen by adjusting lightdm's configuration, in /etc/lightdm/users.conf add the newly created user to the line :

        hidden-users=

Create a directory to be shared

mkdir /home/<user_name>/<folder_name>

Make a safe backup copy of the original smb.conf file to your home folder, in case you make an error

sudo cp /etc/samba/smb.conf ~

Edit the file "/etc/samba/smb.conf"

sudo nano /etc/samba/smb.conf

Once "smb.conf" has loaded, add this to the very end of the file:

    [<folder_name>]
    path = /home/<user_name>/<folder_name>
    valid users = <user_name>
    read only = no

Tip: There Should be in the spaces between the lines, and also there should be a single space both before and after each of the equal signs.

Restart samba:

sudo service smbd restart

Once Samba has restarted, use this command to check your smb.conf for any syntax errors

testparm

To access your network share

  sudo apt-get install smbclient
  # List all shares:
  smbclient -L //<HOST_IP_OR_NAME>/<folder_name> -U <user>
  # connect:
  smbclient //<HOST_IP_OR_NAME>/<folder_name> -U <user>

To access your network share use your username () and password through the path "smb:////" (Linux users) or "\\\" (Windows users). Note that "" value is passed in "[]", in other words, the share name you entered in "/etc/samba/smb.conf".

    Note: The default user group of samba is "WORKGROUP".
2
  • 1
    Instructional pages are great. Broken links are not. It would be more helpful if you were to edit your answer to include a detailed summary of the steps included on that link. That way, your answer will still be helpful even if something happens to that link.
    – user323419
    May 26 '16 at 20:43
  • @TheBrownOne Modified my answer accordingly (though I think that the universality of that rule should be discussed)
    – Bruni
    May 27 '16 at 6:30
3

It can be done with NFS.

This is useful to read about: How do I mount directories from other Linux/Unix/BSD servers? How do I mount an NFS share?

How to setup NFS in Ubuntu: SettingUpNFSHowTo

Ubuntu NFS Server Configuration

Below example shares Public directory (located in pba user home directory) to 10.0.0.1 IP address

Install NFS Server

sudo apt-get install rpcbind nfs-kernel-server

Make sharing directory and set permissions

mkdir -p ~/Public
chmod 777 ~/Public

Add new share to /etc/exports

echo "/home/pba/Public 10.0.0.1(rw,sync,no_subtree_check)" | sudo tee -a /etc/exports

rw makes the share read/write, and sync requires the server to only reply to requests once any changes have been flushed to disk. This is the safest option (async is faster, but dangerous. It is strongly recommended that you read man exports.

Export new share

sudo exportfs -ra

Restart NFS kernel server

sudo service nfs-kernel-server restart

Server is now ready.

Raspberry Pi Client Side Configuration

In below example 10.0.0.12 is a NFS server IP address with /home/pba/Public share

Install NFS, portmap and start services

sudo apt-get install nfs-common portmap
sudo service rpcbind start
sudo update-rc.d rpcbind enable

Make mount directory and mount NFS

mkdir ~/Public
sudo mount -v -t nfs 10.0.0.12:/home/pba/Public /home/pi/Public

Seeing results:

$ cd ~/Public && ls
Ubuntu file  Ubuntu file~

Add line to /etc/fstab to make changes permanent

echo "10.0.0.12:/home/pba/Public /home/pi/Public nfs rsize=8192,wsize=8192,timeo=14,intr 0 0" | sudo tee -a /etc/fstab

For Windows

I've download FreeNFS for Windows. FreeNFS path set to C:\Public.

To mount FreeNFS share mount need to be done like this

sudo mount -v -t nfs 10.0.0.12:/ /home/pi/Public
4
  • 1
    Why is this upvoted? This is about sharing from Windows to an RPi.
    – user323419
    May 26 '16 at 17:08
  • Windows part is how I did it with windows machine to test NFS with RPi, including info how to set it up with any machine on RPi. I will add to my answer link to Ubuntu NFS help page... Downvote not appreciated.
    – Paul B
    May 26 '16 at 18:29
  • Instead of linking to a help-page, it would be helpful if you were to explain how to use NFS on Ubuntu. Then I will reverse my downvote. As it stands, this answer does not provide a solution for setting up a share from Ubuntu. Simply providing a link would make it no more than a "link only answer", which is discouraged.
    – user323419
    May 26 '16 at 20:40
  • 1
    Right, I did improve my answer.
    – Paul B
    May 27 '16 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.