I recently bought a second raspberry pi, for the purpose of making it a “dumb” media center running XBMC (Raspbmc to be exact). I already have a media center PC running XBMC on Windows 7, and I wanted to connect my raspberry pi to the downloaded media, stored remotely on the Win7.
First, of course, I tried SMB (windows share). It worked… ok. But after installing a new HP Wireless printer, it seemed to disconnect a lot. I don’t fully understand why, but it appears that the printer publishes itself as SMB master thus disconnecting my other SMB connections (or maybe only Linux ones)
Anyways, I have spent almost two days, understanding how to connect the Raspberry pi to Windows 7 using NFS. It was not easy, because it seems Microsoft has dropped support for it on home OS (even Win7 ultimate) since Windows XP.
I ended up doing it with Cygwin (which gives powerful Linux capabilities to windows machines).
I want to outline what I have done in order for this to work. This process could be very easy and it could be frustrating. I really hope it will help you do it yourself.
So it might do the trick as step-by-step, and you might come some obstacles on the way
The original guide I used can be found in this link, however it did not work at once and I had to tweak a bit. Also, it is referring to Windows XP.
As this is not step-by-step in full, with screenshots, it might help you on your journey. This can also help you with any windows share to be exported to linux
Here it is:
On the windows machine:
- Download Cygwin 32bit (not 64, even if you are running 64 bit machine)
During install, make sure you install the following packages:
- nfs server
- Make sure your windows username has a password (this is important). If you don’t want to type it when you log in, you can follow this guide
- Start Cygwin as administrator
- Due to a strange behavior of Cygwin, you must remount your desired drive as a different mount
mkdir -p /mnt/d
mount d:/ /mnt/d/
- install nfs server installation
- Answer that you want to run nfsd as separate account, and type in your current username and password
Now, it’s time to edit the exports file (the file in charge of sharing mount points)
- Either edit /etc/fstab in Cygwin, or c:\cygwin\etc\exports in windows
Add the following line (only one example)
** This does not limit network connections to the share
** This limits connections only from 192.168.0.x network
cygrunsrv –start mountd
cygrunsrv –start nfsd
cygrunsrv –start portmap
- You will need to fix cygwin’s fstab in order to preserve the mountpoint (cat /etc/mtab) and copy the new line to /etc/fstab
If you will not do that you risk losing the mountpoint at windows reboot
- Add windows firewall exception for c:\cygwin\usr\sbin\rpc.nfsd.exe
- Add windows firewall exception for TCP,UDP 2094 and 111
- There will be another port to add. I’m not sure which one will it be but you will notice it later (if you get “connection timeout” – this is firewall issues)
On the raspberry pi
(This can be any other Linux box. You must have root permissions!)
- Create a folder to mount to
mkdir -p ~/share
- mount the new share to this folder
sudo mount -v -t nfs 192.168.9.4:/mnt/d share
Note: other switches might help on some machines. Example
sudo mount -v -t nfs -o vers=2 -o nolock 192.168.9.2:/mnt/d share
Here was a big tricky part. After successful mount, I could not cd in any folder. I fixed this in two steps:
- On raspberry pi and on windows I performed “chmod -R 755 *” on the share (on Cygwin on /mnt/d and on linux on ~/share)
On Cygwin I did chown on /mnt/d with the windows username and “none” group. For instance, if you windows username is “Sara”, you should do “chown -R Sara:None /mnt/d”
This might needs to be done as root (sudo)
If you got to this part, you are very lucky and can almost rest!
- Perform /cat/mtab and copy last line in full (this is the line containing your new mount)
- Edit fstab (sudo nano /etc/fstab) and paste this line at the end
- That’s it! If you want to test it – reboot your raspberry pi/linux
This is it! Exhausting, I know. But worth it. For some reason NFS works way better than SMB. To add the share to XBMC simple add a source on the “home directory” and choose “share”
I really really hope this can come in handy to some of you. I will do my best to answer questions and I assume there is a better simpler way, but this is how I did it
EDIT: It appears cygwin sets new files with 000 permission, which will cause your remote client not to be able to do anything with the new files. To overcome this, edit the /etc/fstab on your cygwin (windows) machine, and add this line in the bottom (replacing the old one).
none /cygdrive cygdrive binary,noacl,posix=0,user 0 0
Following this, restart your cygwin and three services installed earlier. That’s it (Thanks for this post)