How to setup nfs-kernel-server?

Having done a new install of CE 9.0 I attempted to set up NFS share from CE.
In truth I have forgotten how I successfully set it up in the first instance, so this is probably an incomplete method which explains why I failed this morning.

In any case maybe someone will point out the reason for my failure

Create NFS server and share directories

    installentware

Disable rpcbind

    systemctl mask rpcbind.socket
    systemctl mask rpcbind.service

Edit /opt/etc/init.d/*nfs-kernel-server by changing these two

    rpc.nfsd --no-nfs-version 4 --no-tcp 1
    rpc.mountd --no-nfs-version 4 --no-tcp

to

    rpc.nfsd --no-nfs-version 4 1
    rpc.mountd --no-nfs-version 4

Put entries in /opt/etc/exports for the directories to be shared.

  cat /opt/etc/exports
  /mnt        *(ro,all_squash,insecure,no_subtree_check,sync)
  /storage/music 192.168.1.0/8(rw,no_all_squash,async,secure,no_subtree_check)

  modprobe nfsd

Where should that ā€œmodprobe nfsdā€ command be entered to ensure it is launched at each boot?
What is the preferred file?
This is probably the reason my set up is not yet working?

Try with echo nfsd >/storage/.config/modules-load.d/nfsd.conf

1 Like

Thanks.

Unfortunately I still have a problem when trying to mount the share in PCLinuxOS via Dolphin filemanager

An error occurred while accessing ā€˜storage/music on 192.168.1.6ā€™, the system responded: mount.nfs: requested NFS version or transport protocol is not supported

and from command line

.# mount -a
mount.nfs: requested NFS version or transport protocol is not supported

Is this likely to be due to a difference in the NFS versions between PC and CE?

Greetings. Has anyone managed to raise the nfs server on ng 9.2 ā€¦ 0227? I wanted to raise the server on AM6 (922x) for the pioneer-140 bd player. I tried all the perversions found on the network, but it does not work. For old guides, it requires portmap, which is not in the entware repo. Itā€™s a shame ā€¦

Working 29.2.2020.

install kernel nfs server

opkg install nfs-kernel-server

modify exports file /opt/etc/exports (not sure how secure this is)

/media *(rw,no_root_squash,insecure,no_subtree_check,fsid=0,crossmnt)

modify start script /opt/etc/init.d/S57nfs-kernel-server (just some small modifications)

remove this 4 lines checking for portmap

if [ -z "`pidof portmap`" ] ; then
        echo 'Error: portmap not started'
        exit 1
fi

remove --no-tcp, add --udp and increase number of threads from 1 to 8

    rpc.nfsd --no-nfs-version 4 --udp 8
    rpc.mountd --no-nfs-version 4

start nfs server

/opt/etc/init.d/S57nfs-kernel-server start

mount share (only for test)

mkdir /storage/test_nfs_mount
mount -t nfs THIS_DEVICE_IP:/media /storage/test_nfs_mount
3 Likes

I am completely lost with understanding the 2 lines for mounting a share. I have a drive attached to my N2 that i want to share, It shows in file manager as /var/media/TOSHIBA_EXT.

Could you help a thicky out and tell me what I need to set in order to see it and use it. I did say that there was far too much SSHing for my skills. To set my skills in context, I did manage to edit the files in your quide once Iā€™d looked up that the command was nano!

You need to set the path in /opt/etc/exports file

/var/media/TOSHIBA_EXT *(rw,no_root_squash,insecure,no_subtree_check,fsid=0)

The last 2 lines (mkdir and mount) are only for a test. You mount NFS on some other device.

Should be so simple then. The only thing is that the drive is labelled TOSHIBA EXT with a space. I think thats messing it up. Iā€™ve tried with space / and _ in /opt/etc/exports but the best I get is that add sourcesearching NFS in file manager on my other CoreELEC box sees the IP of my N2 and offers up the drive but I cannot get to the contents.

I suffered with this when setting a mount for smb. I donā€™t suppose you know how to fix it other than by changing the label to TOSHIBA?

I found that there is an ā€œescape sequenceā€ \040 to ignore paces. TOSHIBA\040EXT did the trick. I am jubilant. Thanks so much for your help.

2 Likes

friends, yesterday I didnā€™t have time to write here about the results of my research ā€¦ I adjusted the nfs server on AM6 (ugoos) from CE to cd-card. Actually, you need the correct script and the correct exports file for normal operation. Above, the comrade vpeter has a very useful instruction. Now my second box from ugoos x3pro with its nfs-client on android communicates perfectly with AM6. However, I have not been able to make friends of my bd player with this server yet. When you start the network search on the player, the player finds the AM6 resource, but it is empty! At the same time, if you raise Hanewin-server on Win, then its resource is perfectly shared and plays the content. Perhaps you need to change the export settings, tried to change it to default - there is no difference. Could it be the case with certain tcp / utp ports? I apologize for my English (google translit)

Probably nfs-kernel-server forgot to enable udp for nfs ā€¦


probably because of the difficulties of translation, we do not understand each other correctly. I did not find confirmation that nfs works with utp protocol. Nowhere in the files did I meet utp for port 2049. Hanewin server uses tcp and udp on port 2049

Got it. You need to add parameter --udp to rpc.nfsd to look like this

rpc.nfsd --no-nfs-version 4 --udp 1

and you get

vim3:~ # rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100003    3   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl
    100003    3   udp   2049  nfs
    100227    3   udp   2049  nfs_acl
    100021    1   udp  60195  nlockmgr
    100021    3   udp  60195  nlockmgr
    100021    4   udp  60195  nlockmgr
    100021    1   tcp  35277  nlockmgr
    100021    3   tcp  35277  nlockmgr
    100021    4   tcp  35277  nlockmgr
    100005    1   udp  49285  mountd
    100005    1   tcp  35143  mountd
    100005    2   udp  47827  mountd
    100005    2   tcp  34353  mountd
    100005    3   udp  43156  mountd
    100005    3   tcp  48301  mountd

Bingo! Thanks!

Thanks for bringing this back and for instructions (I also have a toshiba external drive lol).
I got the share working but itā€™s effectively read-only from my Macbook. Iā€™m able to watch video files on the share for now which is great.

If I try to write to the folder in Finder, it prompts me to enter my password, which I do, and then I get an error saying permission denied after about 5 seconds. I did some searching and maybe this has to do with being root or fsid=0?

You will have to look for flags in exports file. What I use above works in my case to make it rw.

Continuing the theme of using a bd player as an nfs server client on Ugoo AM6 (CE). In the beginning, I could not get this player to see the server. This was solved earlier by adding the udp protocol to port 2049. I use a different startup script, where there are no nfsd startup parameters. After adding udp, the player saw the server, had navigation on the tree, but could not play files - it just hung and had to do a reboot with power. Added one more parameter, from the ā€œdefaultā€ script - the packet size. At the same time, the package had to be reduced to 2048.

echo 2048 > /proc/fs/nfsd/max_block_size

Otherwise, with large packets, the player also hung up or was very slow. He now doesnā€™t play heavy video (bd3d.iso) very well, but better than using the smb protocol. There is one more parameter, which unfortunately is not possible to adjust in nfsd - the number of threads. In the hanewin server this is possible, but ā€œourā€ nfsd implementation does not have such a parameter and it turns out that the number of threads is maximum. Perhaps with this option it would be possible to fine-tune nfsd. Reducing the packet size below 2048 is already unreasonable, it would be more logical to limit the flows to 4-16 and play with the packet size, but alas ā€¦
IMG_20200302_125546
Now I have another problem - after opening the bdmv folder and watching the video, when I re-enter the folder with the movie, the player no longer sees the bdmv folder! The impression is that somewhere the label is ā€œviewedā€ and more, this folder does not appear in the shared resource. In this case, just the video files (mkv, bd3d.iso) are visible and nothing happens to them. Only bdmv folders ā€œdisappearā€. The player itself (client) does not have such settings. Perhaps this is due to the attributes in exports, but I donā€™t know what else can be changed there, because in general, everything works fine.

Maybe it is time to make kernel NFS server addon instead of this entware implementation? :slight_smile:

Maybe I look into one dayā€¦

3 Likes

Everyone keeps saying using NFS is simple, but on CE its far from simple and mired in poor contradictory write ups. Far to steep a learning curve for the average user.

Best to stop advising people to use it over SMB or streamline the process to a huge extent.

Shoog

1 Like

It would be cool! Can you do it? One thing is sad - in this nfsd implementation there is no way to set the number of threads. You probably need to recompile the nfsd daemon ā€¦