2

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.

2
  • Nope, can't be done. But I suspect you have an X-Y problem going on here.
    – womble
    Jan 15, 2020 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. Jan 15, 2020 at 19:40

1 Answer 1

6

This is not 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 trying it first, something like:

$ mount srv1:/srv/files /srv1
$ mount srv2:/srv/files /srv2
$ mount -t overlay overlay -olowerdir=/srv1:/srv2 /srv/nfs
4
  • This looks to be a workable solution. Thanks for the command example. I will need to test this further. Jan 15, 2020 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 Jan 17, 2020 at 5:13
  • Doing this with mount works, but trying to add this to /etc/fstab gives errors... any pointer on what the syntax is for that?
    – Depechie
    Jan 16, 2022 at 11:38
  • You can try to add a systemd based mount rule
    – kofemann
    Jan 16, 2022 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .