# NFS version 3

## jdgill0

I have setup NFS on my computers. It appears NFS v2 is all that is active/enabled. I have compiled NFS v3 support into both machines' kernel.

rpcinfo -p indicates only v2 is active.

The reason for wanting v3 is because of the file size limit in v2.

I have searched the web and the forums, and I am not finding any explicit details about making NFS use v3 versus v2.

I have looked in the nfs-utils ebuild, and it shows v3 enabled in the configure section.

I am baffled. Can anyone explain how I configure the systems to use v3 instead of v2?

Thanks.

----------

## lamaistres

I enable nfs client v3 and/or server v3 support in the kernel. I built them as modules and added them to modules.autoload.

emerged nfs-utils and portmap.

I edited /etc/exports. hosts.allow, and hosts.deny

Then I "rc-update add nfs default" (or nfsd for the server)

My rpcinfo output;

```
root@gentoo marquez # rpcinfo -p

   program vers proto   port

    100000    2   tcp    111  portmapper

    100000    2   udp    111  portmapper

    100024    1   udp  32769  status

    100024    1   tcp  32791  status

    100003    2   udp   2049  nfs

    100003    3   udp   2049  nfs

    100021    1   udp  32770  nlockmgr

    100021    3   udp  32770  nlockmgr

    100021    4   udp  32770  nlockmgr

    100005    1   udp    929  mountd

    100005    1   tcp    932  mountd

    100005    2   udp    929  mountd

    100005    2   tcp    932  mountd

    100005    3   udp    929  mountd

    100005    3   tcp    932  mountd
```

As you can see, v3 nfs is enabled. Is this how you setup nfs?

----------

## jdgill0

 *lamaistres wrote:*   

> I enable nfs client v3 and/or server v3 support in the kernel. I built them as modules and added them to modules.autoload.
> 
> emerged nfs-utils and portmap.
> 
> I edited /etc/exports. hosts.allow, and hosts.deny
> ...

 

I did all the above with the exception of not making nfs client/server modules. I had compiled them into the kernel.

I am now recompiling my kernel with them as modules.

```
<M> NFS file system support

[*]   Provide NFSv3 client support

[ ]   Allow direct I/O on NFS files (EXPERIMENTAL)

<M> NFS server support

[*]   Provide NFSv3 server support

[*]   Provide NFS server over TCP support (EXPERIMENTAL)

```

If this works, then I assume the nfs-utils need to overwrite the kernel modules for NFS in order to provide v3 support?

----------

## RAPUL

Hmm... 

I know this won't help you. But many people don't know shfs.

shfs uses ssh for transmission. 

Server only needs an ssh daemon. And maybe some sftp or a call to ssh-keygen depending on your needs.

Clients only need to emerge shfs package: a kernel module which allow to mount ssh partitions.

You don't need to share nothing. SSH servers always share all. No need to open tons of ports such as nfsd needs. And it is much more secure. It has the same security as ssh, scp or sftp does.

I am in love of SSH. Try it.

PD: I have been running during a long time a nfs infraestructure between 4 machines and every week i had issues about some nfsd daemon doing bad things or hanging one of the machines. Now i live happily with shfs.

----------

## jdgill0

Well, recompiling the kernel with NFS as modules (as I shown above) worked. I now have NFSv3 working between the two machines.

I did have a slight problem. I could not load the nfsd module, kept getting a symbol link error (on both machines, although I realize the modules are not needed on the client side). Backing up the .config file and rebuilding the kernel after a "make mrproper" fixed that problem.

 *RAPUL wrote:*   

> shfs uses ssh for transmission. 
> 
> Server only needs an ssh daemon. And maybe some sftp or a call to ssh-keygen depending on your needs. 
> 
> Clients only need to emerge shfs package: a kernel module which allow to mount ssh partitions.

 

This is interesting.  I will have to look this over, as it would provide a much simpler solution.

 *RAPUL wrote:*   

> You don't need to share nothing. SSH servers always share all. No need to open tons of ports such as nfsd needs. And it is much more secure. It has the same security as ssh, scp or sftp does.

 

Indeed it would be more secure. I trust SSH more than hosts.deny/allow. I am running a firewall with shorewall, which helps ease my worries.

Thanks everyone for the help and the sugesstion.

Maybe somebody could explain why NFSv3 works with kernel modules as opposed to being compiled into the kernel  :Smile: .

----------

## RAPUL

 *jdgill0 wrote:*   

> This is interesting.  I will have to look this over, as it would provide a much simpler solution.
> 
> Indeed it would be more secure. I trust SSH more than hosts.deny/allow. I am running a firewall with shorewall, which helps ease my worries.
> 
> 

 

Nice for giving a try to shfs.

If you have any problem setting up shfs i would help you. Anyway, it is very simple to get it working.

----------

## jdgill0

I have given shfs a go.  I really like how simple it is to use! Amazingly simple.

Question:

Can an entry be added to /etc/fstab, as I did not see any mention of this on the shfs homepage?

Limitation:

I ran into same problem with file sizes greater than 4 gigs as I did with NFSv2. The file size is truncated to [filesize - 4gigs].

The mount command I used was:

```
shfsmount root@192.168.1.1  /shfs  -o preserve,rmode=755
```

But even if shfs is limited in file size and command-line mounting, it is still awesome! I administer a couple computers where I work, and I just shfsmounted the remote computer's directory! This can make life so much easier.

My praises to the shfs developers.

Thanks for the tip about shfs, I definitely have uses for it.

----------

## RAPUL

Yes you can add it to /etc/fstab

Example:

```

ente/usr/portage/distfiles      /usr/portage/distfiles                  shfs            noauto          0 0

```

You can play with compression and changing encryption to improve throughput.

But preventing password prompting needs ssh-keygen for file authentication. You can read about ssh-keygen at gentoo-docs or:

```

SSH can be configured to authenticate quietly using a keyfile as shown here: 

 http://www.cs.umd.edu/~arun/misc/ssh.html

```

----------

## jdgill0

I made one change to your fstab entry, I added 'users' to allow non-root user (me in this case) to mount the remote filesystem:

```
server_name/home/username  /home/username/my_mount_pt  shfs  noauto,users 0 0
```

Now I can just do

```
mount my_mount_pt   ..... if i am in my home folder

or

mount ~/my_mount_pt  .... if i am not in my home folder
```

This is really cool. I wish I had this tool a long time ago!

----------

## madspida

 *RAPUL wrote:*   

> Yes you can add it to /etc/fstab
> 
> You can play with compression and changing encryption to improve throughput.
> 
> 

 

Is there any way to change the compression/encryption settings when mounting via fstab?

----------

