How to setup nfs for ubuntu and xbmc
#1
I had some time off work and was not happy with windows at all.
So I decided to start from the ground up and go with linux manily Ubuntu.
I set my mane pc up with Kubuntu Just the plane old live cd. Then my wifes with the plane Ubuntu cd she likes gnome I liked KDE. For my HTPC I used the karmic minimal setup and used the xci script becuase I could not for the life of me get it to run on my own. To many years with microsoft I guse.
Once every thing was working I set out to network my computers and found a post in here on how to setup a disckless server and thought cool, but a bit out of my ability. I did like what I read about nfs and dicided that was for me!
So this is what I did on my server I set up my file structer like so.
/dev/sda1/boot @ .95 GB ext4
/dev/sda2/Extended @ 73.58 GB
/dev/sda5 swap @ 9.54 GB swap
/dev/sda6/ @ 64.04 GB ext4
/dev/sdb1/home @ 465.76 GB ext4
/dev/sdc1/mnt/disk1 @ 0.91 TB ext4
/dev/sdd1/mnt/disk2 @ 1.36 TB ext4
/dev/sde1/mnt/disk3 @ 1.82 TB ext4

The next thing I did was to install nfs-server on my system to do this open a terminal and switch to root (so you don't have to type sudo ever time) do this by typing sudo -s then enter your password. As a note this is for nfsv4!

apt-get install -y nfs-kernel-server

now make a directory in your root called export
mkdir /export
and then add the folders you wish to share so as an exampel
mkdir /export/TV-Shows (I do not know how to share this way with spaces in the folder name so TV shows is TV-Shows). Now we have to bind that folder with the location of are tv shows in my case I set it up this way.
/export/NFS-Shares/Kids witch are on /mnt/disk1/Kids
note the subfolders on the drive can be named any way you like! Just the ones you setup in the export folder and the folder that you wish to bind to it can not have spaces (if this is wrong let me, and how to do it).
Now we bind the folders for export by typing in the terminal

mount --bind/the/path/to/your/share /export/folder/you/put/here

In my case mount --bind/mnt/disk1/Kids /export/Kids. Now to make this happen on bootup we have to add a line to the fstab to do this we type in the terminal.
kate /etc/fstab (to open the file in kate text editor)

#<file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
UUID=0485a786-de77-45a1-b00a-a71b34df69c9 / ext4 errors=remount-ro 1 1
UUID=da206d1c-34ea-425f-a543-903a17cd9119 /boot ext4 defaults 1 2
UUID=7c14e609-7922-42d2-84ea-6cd95f7301cf /home ext4 defaults 1 2
UUID=44f5246f-32b3-4085-89c6-342ba088decc none swap sw 0 0
UUID=03b4c725-2fbc-44d4-b6b0-da3d31133c01 /mnt/disk1 ext4 rw,nosuid,async 1 2
UUID=4196461b-dd2e-43f6-b8ba-cd8458cc5604 /mnt/disk2 ext4 rw,nosuid,async 1 2
UUID=60c4792f-7a50-4a45-bc62-e06a3b71382c /mnt/disk3 ext4 rw,nosuid,async 1 2
/home/jim/Music /export/videos/Music none bind 0 0
/home/jim/Pictures /export/videos/Pictures none bind 0 0
/mnt/disk1/Kids /export/videos/Kids none bind 0 0
/mnt/disk2/Jim /export/videos/Jim none bind 0 0
/mnt/disk3/Jenn-Jim /export/videos/Jenn-Jim none bind 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
this is an example of my fstab.
you can add the line any were and it should work! Kepping up with my example we will add this to the fstab
/mnt/disk1/Kids /export/Kids none bind 0 0
now save and close the fstab or add any other share you wish and on next boot it should mount for you.
now we have edit some more files. To do this in the terminal we type.
kate /etc/default/nfs-kernel-server
and add
NEED_SVCGSSD=no
save and close kate
kate /default/nfs-common
and add
NEED_IDMAPD=yes
NEED_GSSD=no
save and close kate
kate /etc/idmapd.conf
and add
Nobody-User = nobody
Nobody-Group = nogroup
save and close kate
kate /etc/exports
/export xxx.xxx.x.xx/xx(rw,fsid=0,insecure,no_subtree_check,async)
/export/Kids xxx.xxx.x.xx/xx(rw,nohide,insecure,no_subtree_check,async)
x is = to your ip addres so if your systems IP is 192.168.1.10 and you wish to share with system on your network ranging from .10 to .25 you would add 192.168.1.10/25 now rebbot your system.
on your xbmc system putty in our boot to the terminal and add
apt-get install -y nfs-common
then edit like so
nano /etc/default/nfs-common
and add
NEED_IDMAPD=yes
NEED_GSSD=no
ctrl x to quit y to svae and enter
now we do
nano /etc/idmapd.conf
and add
Nobody-User = nobody
Nobody-Group = nogroup
ctrl x to quit y to save and enter
now kepping in line with my example edit the fstab like so
nano /etc/fstab
and add
xxx.xxx.x.xx:/Kids /home/Kids nfs4 _netdev,auto 0 0
agian xis = to your IP addres. You need to add the folder in witch you wish to mount the shares to I made a folder called NFS-Shares in my home folder so that my kids did not have acsess to any unwanted files.
now just to be sure you should reboot the system and you can add the new nfs shared files just like you would any natively stored media thats it hpoe you like this its much faster the smb.
I should add this not the best with wifi at lest 802.11b/g I do not have an 802.11n system so I do not know how it would be.
Reply
#2
Looks good. I've been running NFSv4 for a long time as well and it blows SAMBA out of the water no doubt - can max out the gigabit link plus no strange errors like I was seeing with SMB.


PS: You should add a disclaimer that this is for NFSv4. There's lots of info out there for 'NFS' but most people get confused when the NFSv3 and NFSv4 instructions aren't specified.

The exports portion and bind are the main differences as far as I recall.

------------------------------------------------------------------------------------------

ALSO, if you have a firewall on the server - these rules added to iptables are all that's needed to open it up for NFS. That is in addition to any other iptables rules you already have in place.

iptables -- add these three lines to iptables.rules
-A INPUT -p udp -i eth0 -m udp --dport 111 -j ACCEPT
-A INPUT -p tcp -i eth0 -m tcp --dport 111 -j ACCEPT
-A INPUT -p tcp -i eth0 -m tcp --dport 2049 -j ACCEPT
Reply
#3
I'll have to look in to that! I do not have a firewall setup as of yet as I just started with linux two weeks ago other that running the xbmclive install. Now I'm trying to get a minimal ubuntu install going for xbmc.
Reply
#4
Interesting. Ill keep this post in mind for next time.

Thanks for sharing.
Reply

Logout Mark Read Team Forum Stats Members Help
How to setup nfs for ubuntu and xbmc0