HOWTO : NFS
June 04, 2016 05:53AM
This HOWTO: will be split into distinct areas,

"Section One" Install and Configure the server
"Section Two" Configure client access.
"Section Three" Boot from NFS share.


We will veer off the beatern track here and be configuring in a hybrid mode.
There may be monsters on this journey, so you have been warned!



"Section One" Install and Configure the server

Install NFS Server and Client
apt-get update ; apt-get upgrade ; apt-get install autofs nfs-kernel-server nfs-common --install-recomends -f -y ; sync ; reboot ;

I will be making the following assumptions (just amend to suit your environment)
1. You already have a working system!
2. Your media to be shared is mounted via fstab by its label, in this case Disk1
3. The mounted disk resides in the following folder /media/Disk1
4. this mount has a folder inside called /Data

Configure NFS Server (as root)
cp -a /etc/exports /etc/exports.backup
Then open the /etc/exports file using the following command:
nano /etc/exports
Edit and comment out all existing lines by adding a “#” in front the line. Setup NFS share for each mounted drive/folder you want to make available to the client devices
# the following will allow both v3 and v4 clients to access the same files

# Export media to allow access for v4 clients ONLY
/media/Disk1   *(rw,async,insecure,no_root_squash,no_subtree_check,fsid=0,nohide)

# Export media to allow access for v3 clients 
/media/Disk1/Data  *(rw,sync,insecure,no_root_squash,no_subtree_check,nohide)
rw – allows read/write if you want to be able to delete or rename file
async – Increases read/write performance. Only to be used for non-critical files.
insecure – Does not mean the files are insecure but rather this setting allow clients (eg. Mac OS X) to use non-reserved ports connect to a NFS server.
no_subtree_check – Improves speed and reliability by eliminating permission checks on parent directories.
fsid=0 - declares this to be a v4 only share
nohide - makes it visible
no_root_squash - *enables* write access for the connecting device root use on a NFS share

Starting / Stopping / Restarting NFS
Once you have setup NFS server, you can start NFS share using the following command as root
exportfs -ra
Any time you make changes to /etc/exports restart your NFS server as root
service nfs-kernel-server restart

Ok now we have the shares setup and accessible, we can start to use this for our full fat linux/mac clients and or configure our other *plugs to boot from the NFS share(s).


"Section Two" Configure client access.

NFS Client Configuration v4 - NFSv4 clients must connect with relative address
Use the mount command to mount a shared NFS directory from another machine, by typing a command line similar to the following at a terminal prompt as the root user (where 192.168.xxx.xxx is the server I.P. address)
mount -t nfs -o vers=4 192.168.xxx.xxx:/ /home/”your user name”/nfs4
The mount point directory /home/”your user name”/nfs4 must already exist and there should be no files or subdirectories in the /home/”your user name”/nfs4 directory.
Another way to mount an NFS share from your 'plug is to add a line to the /etc/fstab file. The basic and what I find best for my uses is as below
192.168.xxx.xxx:/	/home/”your user name”/nfs4	nfs	auto	0	0

NFS Client Configuration v3 - NFSv3 clients must use full address
Use the mount command to mount a shared NFS directory from another machine, by typing a command line similar to the following at a terminal prompt as the root user (where 192.168.xxx.xxx is the server I.P. address)
mount -t nfs -o vers=3 192.168.xxx.xxx:/media/Disk1/Data /home/”your user name”/nfs3
The mount point directory /home/”your user name”/nfs3 must already exist and there should be no files or subdirectories in the /home/”your user name”/nfs3 directory.


"Section Three" Boot from NFS share

The following link gives the steps necessary to configure your u-boot to boot from the NFS share. Please note though that although it discusses using TFTP in the process, this is not necessary and those steps can be avoided.
Boot your Dockstar/Plug by TFTP/NFS

an example uboot statement kindly provided by the master of u-boot @bodhi is included below for you to amend / modify to match your share description and nfs path
bootcmd_nfs=setenv nfs_server "192.168.0.224"; setenv nfs_path "/srv/nfs/hosts/tldDebian2"; setenv nfs_bootcmd "run nfs_set_bootargs; run nfs_boot"; setenv nfs_ipconfig "192.168.0.229:192.168.0.224:192.168.0.1:255.255.0.0:tldDebian2::off"; setenv nfs_set_bootargs "setenv bootargs console=ttyS0,115200 root=/dev/nfs nfsroot=$nfs_server:$nfs_path,v3 rootfstype=nfs rootwait  ip=$nfs_ipconfig $mtdparts"; setenv nfs_load_uimage "nfs 0x800000 $nfs_server:$nfs_path/boot/uImage"; setenv nfs_load_uinitrd "nfs 0x1100000 $nfs_server:$nfs_path/boot/uInitrd"; setenv nfs_load_dtb "nfs 0x1c00000 $nfs_server:$nfs_path/boot/dts/kirkwood-pogo_e02.dtb"; setenv nfs_bootm "bootm 0x800000 0x1100000 0x1c00000"; setenv nfs_boot "run nfs_load_uimage; run nfs_load_uinitrd; run nfs_load_dtb; run nfs_bootm"; echo "Booting NFS root…"; run nfs_bootcmd



Edited 18 time(s). Last edit at 06/09/2016 06:13AM by Gravelrash.
Re: HOWTO : NFS
June 04, 2016 05:53AM
RESERVED
Re: HOWTO : NFS
June 04, 2016 06:12AM
Comments and feedback appreciated



Edited 5 time(s). Last edit at 06/09/2016 04:43PM by Gravelrash.
Re: HOWTO : NFS
June 04, 2016 04:29PM
@Gravelrash,

I think we need to add info about version 3 and version 4. How to export V3 NFS and V4 NFS shares (base on the syntax). And how a client can choose to mount the version. Since everything is default to V4, but a lot of V3 clients are still out there (stock, u-boot,....)

For example, current U-Boot only works with V3. This is in the NFS rootfs topic, which I intented to make a cleanup post in tsunulukai's thread: Boot your Dockstar (and other plugs) using NFS rootfs (referred by the mini Wiki).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : NFS
June 04, 2016 05:08PM
@bodhi

NP i can amend to suit, the above as you rightly point out is for V4 (which for me is my default). I have tried to keep to the KISS principle in the above.

I will hunt down some info on V3 and split the above into V3 and V4 sections. been a while since i mashed around with V3 that i find V4 so much easier to work and configure. truth be told ive forgotten completely how to do a V3 setup...

back to the drawing board :)
Re: HOWTO : NFS
June 04, 2016 05:14PM
Gravelrash Wrote:
-------------------------------------------------------
> @bodhi
>
> NP i can amend to suit, the above as you rightly
> point out is for V4 (which for me is my default).
> I have tried to keep to the KISS principle in the
> above.
>
> I will hunt down some info on V3 and split the
> above into V3 and V4 sections. been a while since
> i mashed around with V3 that i find V4 so much
> easier to work and configure. truth be told ive
> forgotten completely how to do a V3 setup...
>
> back to the drawing board :)

:) I think this works for both V3 and V4:
/media/Disk1   xxx.xxx.0.0/24(rw,async,insecure,no_subtree_check)

But this only V4:
/media/Disk1   xxx.xxx.0.0/24(rw,async,insecure, fsid=0,no_subtree_check)

My NFS rootfs bootmd from u-boot:

bootcmd_nfs=setenv nfs_server "192.168.0.224"; setenv nfs_path "/srv/nfs/hosts/tldDebian2"; setenv nfs_bootcmd "run nfs_set_bootargs; run nfs_boot"; setenv nfs_ipconfig "192.168.0.229:192.168.0.224:192.168.0.1:255.255.0.0:tldDebian2::off"; setenv nfs_set_bootargs "setenv bootargs console=ttyS0,115200 root=/dev/nfs nfsroot=$nfs_server:$nfs_path,v3 rootfstype=nfs rootwait  ip=$nfs_ipconfig $mtdparts"; setenv nfs_load_uimage "nfs 0x800000 $nfs_server:$nfs_path/boot/uImage"; setenv nfs_load_uinitrd "nfs 0x1100000 $nfs_server:$nfs_path/boot/uInitrd"; setenv nfs_load_dtb "nfs 0x1c00000 $nfs_server:$nfs_path/boot/dts/kirkwood-pogo_e02.dtb"; setenv nfs_bootm "bootm 0x800000 0x1100000 0x1c00000"; setenv nfs_boot "run nfs_load_uimage; run nfs_load_uinitrd; run nfs_load_dtb; run nfs_bootm"; echo "Booting NFS root…"; run nfs_bootcmd

Note the mount (bold part) above that indicated V3.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 06/04/2016 05:16PM by bodhi.
Re: HOWTO : NFS
June 04, 2016 05:51PM
@bodhi

Think i got this right now...



Edited 1 time(s). Last edit at 06/04/2016 06:29PM by Gravelrash.
Re: HOWTO : NFS
June 04, 2016 09:06PM
Raises hand to ask stupid question..............

Um Mr. Professor, could you, er, um, elaborate on why you would want to use NFS for rootfs? I have a mix of V4 and V3 but don't feel all that confident I know too much. I hope it's not too much trouble.

Staring at my notes on my desk, head hung in shame :(



Edited 2 time(s). Last edit at 06/04/2016 09:09PM by LeggoMyEggo.
Re: HOWTO : NFS
June 05, 2016 12:31AM
> Um Mr. Professor, could you, er, um, elaborate on
> why you would want to use NFS for rootfs?

:) Everybody has different needs. So YMMV.

If you have a lot of plugs, there are many different reasons why you would want to boot from NFS root. Even more so if local storage is not needed for each plug.

Practicallity:

- Save in cost of having a USB drive for each.
- Save in maintenance time when it's time to apt-get upgrade. You could just quickly clone one rootfs to many and change hostname and IP address (because all reside in a single file system). Or chroot into each rootfs on the main server to upgrade kernel. The main server hosts an NFS root for each machine.
- Save in backup time (only one folder needs backup).

Bonus: boot time is faster on a Gbit network than from local rootfs.

Others purposes:

- Parallel processing. Many applications can take advantage of this. My compilation farm is constructed this way. It compiles on 6 to 10 plugs (depending what's going on), but there are 1 main server and 5 other dedicated rootfs just compiling. They are part of 12 plugs used for researchs (job-related which I don't want to discuss). I have 5 more that were hacked, but just for testing u-boot/kernel (waiting in the wing and conscription when needed).

Potential use cases:

Imagine if you're running a network of thin client computers in the neighborhood. NFS rootfs makes maintenance a lot easier.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 06/05/2016 12:36AM by bodhi.
Re: HOWTO : NFS
June 05, 2016 04:50PM
Perfect explanation Professor Bodhi ! Now I am enlightened :)

So on average would running a Plug off of a NFS rootfs share hosted on a x86 system be faster than running that Plug off of a local USB drive? How does NFS compare to a Plug running off of a SATA drive (in the case of a Pro or Kirkwood device with SATA port)? Curious now.
Re: HOWTO : NFS
June 05, 2016 05:33PM
LeggoMyEggo Wrote:
-------------------------------------------------------
> Perfect explanation Professor Bodhi ! Now I am
> enlightened :)
>
> So on average would running a Plug off of a NFS
> rootfs share hosted on a x86 system be faster than
> running that Plug off of a local USB drive? How
> does NFS compare to a Plug running off of a SATA
> drive (in the case of a Pro or Kirkwood device
> with SATA port)? Curious now.


Note that I did not say NFS rootfs is running faster, I only said that it boots faster. And also SATA local drive is best performance always. NFS rootfs just provides the ability to replicate a system and maintain it a lot easier.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : NFS
June 06, 2016 02:55AM
Gravelrash Wrote:
-------------------------------------------------------
> This HOWTO: will be split into two
> distinct areas,
>
> "Section One" will cover V4 for all "The
> Mortals" and
> "Section Two" will cover V3 for "Retro
> Hipsters".
>
> If you are operating a split or
> mix of V3 and V4 environments, you dont need this
> HOWTO and should be assisting in its
> writeup!

>
>
> Install NFS Server and Client
>
> apt-get update ; apt-get upgrade ; apt-get install
> autofs nfs-kernel-server nfs-common
> --install-recomends -f -y ; sync ; reboot ;
>
>
> . Q. HOW DO I KNOW WHICH SECTION OF THE GUIDE
> TO FOLLOW?
> . A. "nfsstat" is your friend
>
>
> ---snip--->
> gravelrash@4320 ~ $ nfsstat -c
> Client rpc stats:
> calls      retrans    authrefrsh
> 167        0          167     
> 
> Client nfs v4:
> --snip---> 
> additional output ommitted as not relavent
>

Thanks a lot for this. I just want to note that the command, nfsstat does not give the version.

It gives:
root@debian:/etc# nfsstat
Server rpc stats:
calls      badcalls   badclnt    badauth    xdrcall
0          0          0          0          0       

Client rpc stats:
calls      retrans    authrefrsh
0          0          0       

root@debian:/etc#

But with:
nfsstat --version
root@debian:/etc# nfsstat --version
nfsstat: 1.2.8
root@debian:/etc#

That information led me to think it's v3 here that I just installed, following your guide. Can someone please help confirm?
Re: HOWTO : NFS
June 06, 2016 03:54AM
you need to issue

nfsstat -c

you appear to have missed off the operator of "-c"

With no arguments, nfsstat displays statistical information since the last time of the reboot.
Re: HOWTO : NFS
June 06, 2016 04:50AM
@Gravelrash,

Also, nfs-kernel-server provides both V3 and V4, with the default mount is V4.

I believe if the client does not specify the type, then it will always mounted with V4. So the export
/media/Disk1   xxx.xxx.0.0/24(rw,async,insecure,no_subtree_check)
is mounted as V4 by default, if the client does not specify a V3 mount.

@notoneofmyseeds,

The bottom line is someone new to NFS, such as notoneofmyseeds, should not care about the type. It's going to be V4 both ends by default.

Using the V3 syntax would be only to make it backward compatible when and if needed.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : NFS
June 06, 2016 06:14AM
@bodhi - back to teh drawing board for me with my howto.... can you recomend any links.?
Re: HOWTO : NFS
June 06, 2016 01:15PM
@Gravelrash,

I don't recall following any specific tutorial. I think it was just what I gathered from reading various sites after googling.

I think the information so far in this thread is a good enough summary. Perhaps it is OK just to have a main section. And then a smaller section that mentions that what you decribe is for the latest, ie. V4, and specific things one needs to be aware about V3. Nowadays nobody really uses V3 much, unless on an older system (u-boot NFS support is old, and so is stock OS).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : NFS
June 06, 2016 04:23PM
ok i will get on the case with this in a little while - just writing up a report today and tomorrow

EDIT : think i found a dead simple way of doing this - ehehehehehe

https://lukas.zapletalovi.com/2011/05/export-for-both-nfs-v4-and-v3-clients.html



Edited 1 time(s). Last edit at 06/06/2016 04:30PM by Gravelrash.
Re: HOWTO : NFS
June 07, 2016 06:02AM
@bodhi
i think that we are finished, all bar your feedback and instructions on how to configure and boot your plugs from NFS

@all
Please try the above and feedback your findings
Re: HOWTO : NFS
June 07, 2016 01:29PM
This looks *very* useful - should have had this a few months ago...

You should possibly mention the no_root_squash option - it bit me today (for a few hours - repeatedly!).

The default is that root on the client can *not* write to an NFS share. But in certain cases (e.g. backup of rootfs to NFS share) this is necessary, so the option no_root_squash *enables* write access for rott on a NFS share.

Cheers,

Rainer

===========================
Blog: https://rmkrug.wordpress.com/

1 x Pogoplug E02 (pink): Logitech media server

1 x Pogoplug E02 (pink): FTP server only (throw away configuration - quick to rebuild)

1 x GoFlex Net: running OpenMediaVault
Re: HOWTO : NFS
June 07, 2016 04:02PM
Yes, if it is suppose to be wide open. Then
no_root_squash,no_subtree_check

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : NFS
June 07, 2016 04:06PM
@Gravelrash,

> i think that we are finished, all bar your
> feedback and instructions on how to configure and
> boot your plugs from NFS

It's going to be a little long so I think I will do that in a separate post, when I have a good block of free time. In the mean time, you could refer to tsunulukai's thread:

Boot your Dockstar by TFTP/NFS

Please also mention that TFTP is not needed, the solution should be all NFS (as example, my bootcmd for NFS).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 06/07/2016 04:16PM by bodhi.
Re: HOWTO : NFS
June 07, 2016 04:44PM
@rkrug : thanks for that, i will add that and also your pointer about root

@bodhi -i will reference the link as well - having had a quick look through ti i can see its a looong post to write up.
Re: HOWTO : NFS
June 08, 2016 12:48PM
Good job Gravelrash! Wiki post was updated.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: HOWTO : NFS
June 08, 2016 06:30PM
Some feedback. I had to remove "hohide" as was causing an error I don't now recall.

Thanks to all for the guide.
Re: HOWTO : NFS
June 09, 2016 04:29AM
@notoneofnyseeds

can you recall if it was for a v3 or v4 setup? I will run the above again on my kit and see if i can replicate the issue.

Well done for finding an error and reporting back!
Re: HOWTO : NFS
June 09, 2016 04:40AM
not *hohide* but *nohide* ---- typo in the howto!

===========================
Blog: https://rmkrug.wordpress.com/

1 x Pogoplug E02 (pink): Logitech media server

1 x Pogoplug E02 (pink): FTP server only (throw away configuration - quick to rebuild)

1 x GoFlex Net: running OpenMediaVault
Re: HOWTO : NFS
June 09, 2016 06:15AM
Typo amended. Well spotted there!

rkrug Wrote:
-------------------------------------------------------
> not *hohide* but *nohide* ---- typo in the howto!
Re: HOWTO : NFS
June 09, 2016 01:17PM
I think mine is V3. I can verify this, because I made a purposeful error on the " Export media to allow access for v3 clients ONLY" line and with the V4 line as suggested, I got an error. After after correcting the error, which was writing a share that does not exist, it worked well. And is still working.

If only I can get SAMBA working, I'd be moving ahead.
Re: HOWTO : NFS
June 09, 2016 04:02PM
@notoneofmyseeds

thanks for testing and confirming - if you want to start a new topic about samba, i will do my best to assist
Re: HOWTO : NFS
June 22, 2016 01:58PM
Gravelrash Wrote:
-------------------------------------------------------
> @notoneofmyseeds
>
> thanks for testing and confirming - if you want to
> start a new topic about samba, i will do my best
> to assist

I did not mean to ignore this generous offer. I never did come back to this thread. Perhaps you know of a way that I could adjust my account so notifications are sent me on threads that I comment on. Do you know. I've since had SAMBA sorted. Thanks a lot. My apologies again.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: