How to Configure an NFSv4-only Client using nfsconf in CentOS/RHEL 8
The nfsconf tool
CentOS/RHEL 8 introduces the nfsconf tool to manage the NFS client and server configuration files under NFSv4 and NFSv3. Configure the nfsconf tool using /etc/nfs.conf (the /etc/sysconfig/nfs file from earlier versions of the operating system is deprecated now). Use the nfsconf tool to get, set, or unset NFS configuration parameters.
The /etc/nfs.conf configuration file is composed of multiple sections starting with a key word in square brackets ([keyword]) with value assignments within the section. For an NFS server, configure the [nfsd] section. A value assignment or key is composed of a name for the value, an equals sign, and a setting for the value, such as vers4.2=y. The lines starting with “#” or “;” are ignored, as are any blank lines.
[user@host ~]$ sudo cat /etc/nfs.conf ...output omitted... [nfsd] # debug=0 # threads=8 # host= # port=0 # grace-time=90 # lease-time=90 # tcp=y # vers2=n # vers3=y # vers4=y # vers4.0=y # vers4.1=y # vers4.2=y # rdma=n #
By default the [nfsd] section’s key-value pairs are commented out. However, the comments show the default options that will take effect if they are unchanged. This provides you with a good starting point for NFS configuration. Use the nfsconf –set section key value to set a value for the key in the specified section.
[user@host ~]$ sudo nfsconf --set nfsd vers4.2 y
This command updates the /etc/nfs.conf configuration file:
[user@host ~]$ sudo cat /etc/nfs.conf ...output omitted... [nfsd] vers4.2 = y # debug=0 # threads=8 # host= # port=0 # grace-time=90 # lease-time=90 # tcp=y # vers2=n # vers3=y # vers4=y # vers4.0=y # vers4.1=y # vers4.2=y # rdma=n #
Use the nfsconf –get section key to retrieve the value for the key in the specified section:
[user@host ~]$ sudo nfsconf --get nfsd vers4.2 y
Use the nfsconf –unset section key to unset the value for the key in the specified section:
[user@host ~]$ sudo nfsconf --unset nfsd vers4.2
Configure an NFSv4-only Client
You can configure an NFSv4-only client by setting the following values on the /etc/nfs.conf configuration file. Start by disabling UDP and other NFSv2 and NFSv3 related keys:
[user@host ~]$ sudo nfsconf --set nfsd udp n [user@host ~]$ sudo nfsconf --set nfsd vers2 n [user@host ~]$ sudo nfsconf --set nfsd vers3 n
Enable TCP, and NFSv4, related keys.
[user@host ~]$ sudo nfsconf --set nfsd tcp y [user@host ~]$ sudo nfsconf --set nfsd vers4 y [user@host ~]$ sudo nfsconf --set nfsd vers4.0 y [user@host ~]$ sudo nfsconf --set nfsd vers4.1 y [user@host ~]$ sudo nfsconf --set nfsd vers4.2 y
As before, the changes appear in the /etc/nfs.conf configuration file:
[user@host ~]$ cat /etc/nfs.conf [nfsd] udp = n vers2 = n vers3 = n tcp = y vers4 = y vers4.0 = y vers4.1 = y vers4.2 = y
目录 返回
首页