# Tip: Exporting Btrfs over NFS 4

## Hupf

If you try to export a btrfs volume over NFSv4 you may get errors like

 *Quote:*   

> Aug 25 11:50:32 pc-diego rpc.mountd[10423]: qword_eol: fflush failed: errno 9
> 
> (Bad file descriptor)
> 
> Aug 25 11:50:32 pc-diego rpc.mountd[10423]: Cannot export /dati/ISO, possibly
> ...

 

(shamelessly copied from this bug)

On the client's side, you may see "stale file handle" or ESTALE error messages when trying to mount such a volume.

The solution was not easy to find based on the above error messages which is the reason for me writing this post. After reading this guide, chapter 18.7.1.1, I did the following:

# mkdir -p /exports/btrfs

# mount --bind /regular/btrfs/mountpoint /exports/btrfs

Then I changed my /etc/exports file to look like this:

 *Quote:*   

> /exports *(ro,no_subtree_check,fsid=0)
> 
> /exports/btrfs *(rw,no_subtree_check,fsid=12345)

 

(notice the fsid=0 part; you may replace the 12345 with the UUID given with btrfs-show, but it just has to be unique among the exports)

You should now successfully be able to

# mount -v -t nfs4 server:/btrfs /mnt/nfs

(notice the use of /btrfs instead of /exports/btrfs since /exports is the "virtual root" for all nfs exports now)

----------

## krinn

you are just showing howto export something using nfsv4

the only "new" thing i see is the need to specify the fsid for your filesystem when it's brtfs, i don't know if it's a "real" need.

And it's not clear it's a need, as the guys weren't exporting right the fs in the bug report you've shown

redo your test with 

```
/exports *(ro,no_subtree_check,fsid=0)

/exports/btrfs *(rw,no_subtree_check)

```

if it doesn't work it will confirm the need to specify fsid for brtfs, else it's just the nfsv4 standard, nothing new there

because the fsid is state to be pass to help kernel when the fs is not on a device (like if someone would export a fs that is in memory), but i doubt you use such configuration but an harddisk device that hold your fs no ?

----------

## Hupf

Originally I had the exact same configuration but tried to export the btrfs mount point directly (which resulted in the errors from the bug report). Solely adding the mount --bind in-between and exporting that solved the issue for me.

----------

