导出包含“-”(破折号)的 NFS 路径

qdo*_*dot 10 networking linux unix nfs

我对 NFS 导出文件有点紧张。

具体来说,我找不到导出路径名中包含“-”的目录的方法。

手册 (exports(5)) 指出:

Also, each line may have one or more specifications for default options 
after the path name, in the form of a dash ("-") followed by an option 
list. The option list is used for all subsequent exports on that line 
only.
Run Code Online (Sandbox Code Playgroud)

然后声明:

If an export name contains spaces it should be quoted using double quotes. 
You can also specify spaces or other unusual character in the export name 
using a backslash followed by the character code as three octal digits.
Run Code Online (Sandbox Code Playgroud)

不幸的是,事实并非如此。具体来说,如果路径名包含“-”,无论是逐字的,还是带有 \055 或用双引号括起来的,它仍然指的是没有“-”的名称

有任何想法吗?我有大量的目录,所有的形式

  • /vol/buildsystem-s3c2440
  • /vol/buildsystem-tao3530

我更愿意将它们全部用作 nfs 导出。没有在脚本中到处用“_”替换“-”,可以用“-”来完成吗?

Mik*_*kel 3

根据本文,我假设您使用的是 Linux?

如果导出名称包含空格,则应使用双引号将其引起来。您还可以使用反斜杠后跟三个八进制数字的字符代码来指定导出名称中的空格或其他异常字符。

Linux 系统上有两种不同的 NFS 服务器实现:

  • 用户NFS
  • 内核NFS

请尝试运行ps -ef | grep nfsd看看您拥有哪一个。

我认为用户 NFS 将显示为nfsdunfsd,内核 NFS 将显示为[nfsd]
(请注意一个有方括号,而另一个没有。)

对于内核 NFS,您应该使用双引号或八进制转义符,例如

"/path/to/mount-point" <options>
Run Code Online (Sandbox Code Playgroud)

或者

/path/to/mount\055point <options>
Run Code Online (Sandbox Code Playgroud)

(参考:nfs-utils-1.1.2,xgettoksupport/nfs/xio.c

对于用户 NFS,导出名称中不允许有空格,但减号 ( -) 不应要求转义,例如

/path/to/mount-point <options>
Run Code Online (Sandbox Code Playgroud)

(参考:nfs-user-server-2.2beta47,filt_getcauth_init.c

如果您无法深入了解,我建议从用户 NFS 切换到内核 NFS,以便您可以使用引用或八进制转义。

在 Debian 和 Ubuntu 上:

  • apt-get install kernel-nfs-server

在红帽和 Fedora 上:

  • yum install nfs-utils