1

I am running into an issue with NFS that I am not sure how to solve. I have spent a bit of time trying to find an answer but was not successful. I am ultimately trying to achieve the below setup without having to mount each sub-directory individually as these may change overtime dynamically and that route will not scale.

NFS Server1 exports /srv/files/ and within that directory are these subdirectories which have the actual files needed on the client

/srv/files/0001/
/srv/files/0002/
/srv/files/0003/
/srv/files/0004/

NFS Server2 exports its own /srv/files and within that directory is a similar structure though the subfolders will have a name unique in respect to NFS Server1 folders

/srv/files/0005/
/srv/files/0006/
/srv/files/0007/
/srv/files/0008/

NFS Client can mount both NFS server shares as read only but within the same directory:

/srv/nfs/0001
/srv/nfs/0002
/srv/nfs/0003
/srv/nfs/0004
/srv/nfs/0005
/srv/nfs/0006
/srv/nfs/0007
/srv/nfs/0008

Is this possible to do? Is NFS the right route? Again I will not need to write data to the NFS Servers, simply read.

  • Nope, can't be done. But I suspect you have an X-Y problem going on here. – womble Jan 15 at 3:27
  • Valid point. Ultimately these files will be generated on remote machines and available to a web server that will allow downloading of the files. I don't want the files traversing the network prior to the download however since not all files will be download and each one is over 20MB, hence the use of NFS instead of some type of file transfer and this also needs to scale well. There may be a better tool for this. – timmytimmers Jan 15 at 19:40
1

This is possible to do directly with NFS, but you can use unionfs or overlayfs to achieve that. As overlayfs is part of the standard kernel I would suggest to try it first, something like:

$ mount srv1:/srv/files /srv1
$ mount srv2:/srv/files /srv2
$ mount -t overlay overlay -olowerdir=/srv1:/srv2 /srv/nfs
|improve this answer|||||
  • This looks to be a workable solution. Thanks for the command example. I will need to test this further. – timmytimmers Jan 15 at 19:42
  • After testing overlayfs works perfect for what I am looking for. Important to note that this example mounts the overlay as read only which fits my use case. This could also be mounted for writing. Thanks for the help – timmytimmers Jan 17 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.