Nfs with Zfs usage.

ozgurerdogan

Renowned Member
May 2, 2010
610
5
83
Bursa, Turkey, Turkey
I create nfs share with on pve node 1:

zfs set sharenfs="rw=@1.2.3.4" \
rpool/data/

On pve node2:
I was able to add this nfs share but its content is emtpy. I can verify nfs size. Why can not I see raw images you think?
 
I use ZFS for many year. But never saw through the nfs share function for ZFS, so i used the normal exportfile.
 
I ran command on nfs server pve.

Code:
root@backup:~# zfs set sharenfs="rw=@1.2.3.4" \
> rpool/data
root@backup:~# df -t nfs
df: no file systems processed
exportfs -ra && service nfs-kernel-server restart && service portmap restart
But on other pve client, I can see nfs share volume "rpool/data" but after I added it, its content is empty. I probably miss some point.
 

Attachments

  • 2018-03-04_22-32-26.png
    2018-03-04_22-32-26.png
    12.2 KB · Views: 58
I dont use NFS but I found old line in /etc/exports

/media/zfs_pool/cloud/mk 10.10.10.16(rw,sync,no_subtree_check)
 
Nfs mount is ok. But I can not see any zfs data set in nfs client box.

On nfs server: (z2 is pool name)
apt-get install -y nfs-kernel-server
zfs set sharenfs="rw=@1.2.3.4/32" z2

On nfs client:
mount -t nfs backup.domain.com:/z2 /bz2
root@s1:~# ls -l /bz2
total 2
drwxr-xr-x 2 root root 2 Mar 12 07:33 dump
drwxr-xr-x 2 root root 2 Mar 12 07:32 images
drwxr-xr-x 2 root root 2 Mar 12 07:33 private
drwxr-xr-x 4 root root 4 Mar 12 07:45 template

But on pve gui, content tab is empty.
 
You don't need to fill /etc/exports file, but you can share zfs datasets after installing and starting nfs-kernel-server only:
Code:
# apt-get install nfs-kernel-server && systemctl start nfs-kernel-server

And then:
Code:
# for DS in home pve srv; do
     zfs create rpool/$DS;
     zfs set mountpoint=/$DS rpool/$DS;
     zfs set sharenfs=on rpool/$DS;
 done
After that everything works.
 
Last edited:
You don't need to fill /etc/exports file, but you can share zfs datasets after installing and starting nfs-kernel-server only:

Is this so? Previously, you needed at least one entry in the /etc/exports to get the nfs service/daemon running in the first place.
 
Is this so? Previously, you needed at least one entry in the /etc/exports to get the nfs service/daemon running in the first place.
Code:
root@pve-1:~# cat /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
Code:
root@pve-1:~# showmount -e localhost
Export list for localhost:
/pve  *
/srv  *
/home *
Code:
root@pve-1:~# cat /etc/dfs/sharetab 
/home   -       nfs     rw,crossmnt 
/srv    -       nfs     rw,crossmnt 
/pve    -       nfs     rw,crossmnt
 
Code:
root@pve-1:~# cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
Code:
root@pve-1:~# showmount -e localhost
Export list for localhost:
/pve  *
/srv  *
/home *
Code:
root@pve-1:~# cat /etc/dfs/sharetab
/home   -       nfs     rw,crossmnt
/srv    -       nfs     rw,crossmnt
/pve    -       nfs     rw,crossmnt

Thank you for reporting back ... the "old" problem seems to be fixed then.
 
If I try old exports file way, proxmox throws this error when adding nfs share:

create storage failed: error with cfs lock 'file-storage_cfg': mkdir /mnt/pve/dasd/images: Permission denied at /usr/share/perl5/PVE/Storage/Plugin.pm line 903. (500)
 
If I try old exports file way, proxmox throws this error when adding nfs share:

create storage failed: error with cfs lock 'file-storage_cfg': mkdir /mnt/pve/dasd/images: Permission denied at /usr/share/perl5/PVE/Storage/Plugin.pm line 903. (500)

Why you don't use zfs sharing options? It works exellent.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!