nfs4 patch for proxmox

jinjer

Renowned Member
Oct 4, 2010
204
7
83
Hi,

I recently needed to mount all my shares using nfsv4 instead of the classic nfs protocol.

Fortunately this is a simple patch, so I would like to contribute it in the hope it will get incorporated some time.

This patch works ONLY if ALL your shares are nfs4: as there's no provision in the gui for nfs/nfs4 distinction, the patch will simply mount all shares as nfs4. Manually mounted nfs3 shares will still be recognized.

Code:
pvet:/usr/share/perl5/PVE# diff -u Storage.pm.org Storage.pm
--- Storage.pm.nfs	2011-06-10 11:32:28.000000000 +0200
+++ Storage.pm.nfs4	2011-06-10 11:32:11.000000000 +0200
@@ -2068,8 +2068,8 @@
     my $source = "$server:$export";
 
     $mountdata = read_proc_mounts() if !$mountdata;
-
-    if ($mountdata =~ m/^$source\s$mountpoint\snfs/m) {
+		
+    if ($mountdata =~ m/^$source\/?\s$mountpoint\snfs4?/m) {
 	return $mountpoint;
     } 
 
@@ -2081,7 +2081,7 @@
 
     my $source = "$server:$export";
 
-    my $cmd = ['/bin/mount', '-t', 'nfs', $source, $mountpoint];
+    my $cmd = ['/bin/mount', '-t', 'nfs4', $source, $mountpoint];
     if ($options) {
 	push @$cmd, '-o', $options;
     }

The patch is on proxmox 1.6 but should be straightly portable to recent versions.

Hope this is usefull.

jinjer
 
Fortunately this is a simple patch, so I would like to contribute it in the hope it will get incorporated some time.

I thought nfs automatically select the right protocol version? Do we really need an extra nfs4 type?
 
I am wondering if anybody is interested in nfs4 vs nfs(3) support in proxmox. Using nfs has its advantages over iscsi for shared storage and nfs4 has it's own ones over nfs3 (security).
Oops... did I share a secret?

jinjer
 
dietmar, seems me and you replied at the same time.
Actually, if your nas exports both nfs3 and nfs4 trees, the nfs client in linux defaults to nfs3. You can confirm this with cat /proc/mounts on the client. Also, when you have nfs4 server with nested export directories (i.e. 1 export per VM) if you mount the shares with nfs3 you will not be able to see the nested exports on the client. nfs4 instead will auto-mount them.

Why nested exports? because each one could be a san-slice exported from the server with it's own service level reservations and a separated backup policy.

jinjer
 
Actually, if your nas exports both nfs3 and nfs4 trees, the nfs client in linux defaults to nfs3.

Why do you export them as nfs3 if you want nfs4?

And why does linux mount use nfs3 if nfs4 is available (I would like to understand that)?
 
From the Ubuntu NFS Guide:
  • Remember that mount/fstab defaults to NFSv3, so "mount -t nfs4" is necessary to make this work.
On the client we can mount the complete export tree with one command:

  • # mount -t nfs4 -o proto=tcp,port=2049 nfs-server:/ /mntNote that nfs-server:/export is not necessary in NFSv4, as it is in NFSv3. The root export :/ defaults to export withfsid=0.

Unfortunately, simply replacing nfs with nfs4 doesn't offer a complete solution (I tried your patch). In nfs4, the export paths are relative to /export, whereas in nfs3, the full path includes /export. For example, /export/backups in nfs3 would simply be /backups in nfs4. Although it doesn't complain when you add the nfs4 export through the web interface, I ran into some problems when trying to actually make a backup since it used the full /export/backups path.

There is also a potential issue with uuid mapping that requires a few configuration changes for nfs4. Ultimately, I decided to follow https://help.ubuntu.com/community/SettingUpNFSHowTo to setup a client on the host machine, and just add it through the web interface as a directory.
 
OK, I added nfs4 support to the todo list for V2.0 - in the meantime people can use the directory workaround described above.
 
OK, I added nfs4 support to the todo list for V2.0 - in the meantime people can use the directory workaround described above.
this is great news. My nas exports both nfs3 and nfs4 (and isn't running linux) so this is the reason for having to tell linux clients to use nfs4.

@AkeemMcLennon: What you're describing is normal with nfs4. It's the way nfs4 exports shares. My patch is obviously a "hack" and is not supposed to just "switch" nfs from 3 to 4 in a running installation. I don't see the need to have an interchangeable "switch" from nfs3 to nfs4 in the gui as the paths are not compatible between the two. A hack to make them the same will certainly confuse ops trying to set nfs4 in the first place and expecting a path of "/backup" from the "/exports" root while proxmox would require them to use the full "/exports/backup" path which is plain wrong for nfs4.

ouch my wording above is so bad...

I've been using the patch above for the last weeks and have seen no problems, so I guess what is left is the gui rework and associated Storage.pm changes
 
Last edited:

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!