5

How can I share FolderA on ServerA so that my client can simply access it as ServerA:/FolderA if FolderA is not in / ?

Lets say FolderA is actually

/usr/local/test/RandomName

I can use bind in fstab to shorten it and put it in /export

/usr/local/test/RandomName /export/FolderA none bind 0 0

So now, I can mount it as

mount -t nfs ServerA:/export/FolderA /media/folderA

What I really want is

mount -t nfs ServerA:/FolderA /media/folderA

The server is Ubuntu 10.04 and the clients will include Macs and Linux machines

wag2639
  • 2,115
  • 6
  • 24
  • 32

4 Answers4

2

You have to set the base directory in your NFS exports. To do that and make /export the base directory you should open the file

/etc/exports

and enter the following in the first line:

/export  the.IP.of.THEclientsyouwant(ro,fsid=0)

With the option fsid=0 (or fsid=root) set you won't call the full path on the client side and then the command

mount -t nfs ServerA:/FolderA /media/folderA

just will work as you will.

exports(5) Man page /etc/exports configuration - Red Hat

0

The sole fsid=0 didn't work for me.

nfs-utils>=2.4.1 got Add the "[exports] rootdir" option to nfs.conf feature (May 28, 2019):

The following patchset adds support for the "rootdir" configuration option for nfsd in the "[exports]" section in /etc/nfs.conf.

If a user sets this option to a valid directory path, then nfsd will act as if it is confined to a chroot jail based on that directory. All paths in /etc/exports and the exportfs utility are then resolved relative to that directory.

Something like this should work:

Note: I couldn't make exporting / root path work but exporting through a subdirectory did it.

Target dir bound to /export/nfs/FolderA.

/etc/nfs.conf:

[exports]
rootdir=/export

/etc/exports:

/nfs (fsid=0) # workaround for `/` path
/nfs/FolderA

Access it nfs://server_name/nfs/FolderA

Dawer
  • 21
  • 1
0

I'm not sure if you can do that using bind in your server's fstab. but I do know you can do this:

ln -s /usr/local/test/RandomName /FolderA

Configure your /etc/exports file to export /FolderA and you should be good.

Richard June
  • 728
  • 4
  • 7
-3

Open following file on NFS server:

/etc/exports

and enter following details to it:

/usr/local/test/RandomName XX.XX.XX.XX(rw)

Then login NFS client and do mount as follows:

mount -t nfs YY.YY.YY.YY:/usr/local/test/RandomName /media/folderA

Fstab entry:

YY.YY.YY.YY:/usr/local/test/RandomName /media/folderA nfs defaults 0 0

Note:

XX.XX.XX.XX - IP of NFS client
YY.YY.YY.YY - IP of NFS server
Suku
  • 2,006
  • 13
  • 15