NFS and different exports to the same host

Tony Frank tfrank at
Sat Feb 21 02:59:25 PST 2004

Hi there,

On Fri, Feb 20, 2004 at 09:17:37PM -0600, dap wrote:
> Per the FreeBSD handbook, I have to follow the rule that for a specific host
> I have to export everything the same for a particular filesystem. So let's
> say I have one filesystem, /.
> So I can't have:
> /export1    -ro    server1 server2
> /export2             server1
> Instead, I need:
> /export1 \
> /export2 \
> server1
> Is there a way around this?

Each filesystem can only be exported with one set of attributes to a particular host.
If both /export1 and /export2 are directories of / then you would do:

/export1 /export2 -ro server1
/export1 -ro server2

But note that the same attributes apply - ie both ro or both rw.
If you need to give ro on one and rw to the other then you need to make them separate
filesystems.  See below for a way to do this.

>From the handbook:
In /etc/exports, each line represents the export information for one filesystem to one host. 
A remote host can only be specified once per filesystem, and may only have one default entry. 
For example, assume that /usr is a single filesystem. The following /etc/exports would be invalid:

/usr/src   client
/usr/ports client

One filesystem, /usr, has two lines specifying exports to the same host, client. 

The correct format for this situation is:

/usr/src /usr/ports  client

The properties of one filesystem exported to a given host must all occur on one line. 
Lines without a client specified are treated as a single host. 
This limits how you can export filesystems, but for most people this is not an issue.

eg I have in my /etc/exports file:

/data/ad2 -alldirs -maproot=root -network -mask
/data/ad3 -alldirs -maproot=root -network -mask
/usr -alldirs -ro -network -mask
/usr /usr/local -maproot=0:10 group1
/usr -ro -mapall=nobody
/tmp -maproot=root group1
/tmp group2
/cdrom -alldirs,quiet,ro -network -mask

So you can export the one filesystem (/usr or /tmp here) to different
places with different attributes.
You cannot have different attributes for same filesystem + same host.
So if I had a host in both group1 and group2 in this example it would 

> I have found that it works best for us to have a /exports, where we dump
> things like /exports/www, /exports/mail, and so on, rather than having
> filesystems for each of those. This is important since FreeBSD has a
> limitation on the number of possible slices, and we are running with one big
> RAID-1 storage system.

If you want to break up a single "disk" into many pieces you might want to
look at using vinum for this.
If you are using hardware raid already you can make the virtual disk a vinum
drive and then break it up into as many subdisks as you like.
Eg a config like:

drive hwraid1 device /dev/da0s1h

volume www
 plex org concat
  sd drive hwraid1 len 2G

volume mail
 plex org concat
  sd drive hwraid1 len 2G


While it adds an extra layer it should not be too much of an overhead.
You can also then add as many filesystems as you like, but they cannot
share the same total disk.
You could however add extra subdisks if more space is needed and run
growfs to increase room if it is needed.

> Also, I found that this generates errors (by mountd -r):
> /export1 -maproot=nobody \
> /export2 -maproot=root \
> server1
> While this works:
> /export1 \
> /export2 \
> -maproot=root \
> server1
> That's no good. Is there a solution to this problem?

Each "line" should be made of 3 parts:
1 - directory/filesystems to export
2 - attributes
3 - hosts

First one does not follow this layout.

You can make each directory it's own filesystem using the vinum idea.

> By the way, I have found that FreeBSD is a solid NFS server. Other than this
> limitation NFS has worked great.
> Handbook on NFS:

Hope that helps,


More information about the freebsd-questions mailing list