NFS cannot allocate memory and No such file or directory errors

NFS cannot allocate memory seems to be common issue a lot of people face while mounting NFSv4 shares, as revealed from search results on Google. Even I faced it when trying to mount a NFS share exported from my desktop on my Raspberry Pi. It didn’t give the error on the Pi, though. I discovered this issue when debugging this problem and tried to mount on localhost.

Initially it appears to be a kernel issue, but it turned out not to be one. After researching a lot about the problem I understood that it is a error in exports configuration!

Basically, in NFSv4, there is a / (root) under which all shares are exported and this must have the fsid=0 parameter specified in the configuration.
At the client, while mounting you are not supposed to specify the full path to the resource, instead it must be relative to the NFS Root.

The following example would clear it up –

I’ll try to export /home and mount it on localhost with following configuration:

And when I run the mount command:

Now I’ll change the exportfs configuration to:

Running the mount command again,

Now, in the above output, you can see that while it failed to mount with NFSv4, but it succeeded in mounting NFSv3. This comes from the newer way of exports which is partially explained in the manual exports(5).

The solution to the No such file or directory is simple, you have to use / as the path to mount the root and if you are exporting some subdirectories, they need to be relative to / in the mount command instead of the full path.

Now modifying the mount command accordingly:

Now if I export a subdirectory inside /home, say my home folder /home/nilesh then it would be available via NFSv4 to clients as /nilesh and not /home/nilesh.

There seems to be a big problem controlling access in this model, you can’t have different permissions for /home and /home/nilesh. If you export /home as read-only, /home/nilesh will also get mounted read-only no matter what.

If you export /home as read-write and /home/nilesh as read-only, then clients would be able to write into all directories on the share, when the share root is mounted, i.e. /, but if the client mounts /home/nilesh it will be read-only.

I’m not sure about how to control access in NFSv4 for subdirectories, since you cannot have more than one entry for fsid=0. If you know the answer, do comment.


4 thoughts on “NFS cannot allocate memory and No such file or directory errors

Add yours

    1. strange. My client is RHL5, and Server is RHL6,. Neither distros have NFS enabled out of the box. I was getting Input/Output Error and Cannot Allocate Memory, until I started portmap on the RHL5 client. This may narrow down a more amicable solution to configuring NFS4 across legacy distributions.

Have something to add? Do it here.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: