使用 ID 映射装载 Synology NFSv4 导出

eri*_*rik 5 linux debian mount nfs synology

我有一个通过 NFSv4 导出共享目录的 Synology DiskStation (DSM 6.0.2)。我指定了一个 NFSv4 域ITET-PHO

在另一台 Linux 机器(Debian Wheezy)上,我想使用 idmapping 挂载此导出。在那里我有以下配置/etc/idmapd.conf

[General]
Verbosity = 2
Pipefs-Directory = /run/rpc_pipefs
# set your own domain here, if id differs from FQDN minus hostname
Domain = ITET-PHO

[Mapping]
Nobody-User = nobody
Nobody-Group = nogroup

[Translation]
Method = static

[Static]
erikhe@ITET-PHO = erik
Run Code Online (Sandbox Code Playgroud)

因此,我尝试erikhe将域中的 Synology上的用户静态映射ITET-PHO到本地用户erik。所有其他用户都应映射到nobody. 但是,当我挂载共享目录时,我只能看到 Synology 中的 UID 编号:

drwxr-xr-x 4 1566874442 1566573057 4096 Okt  5 10:21 erikhe-301898
Run Code Online (Sandbox Code Playgroud)

还显示所有其他 UID 而不是nobody. 在日志文件中,我看到 idmap 正在做某事。这是做的时候service nfs-common restart

Oct  5 15:11:07 sisyphous systemd[1]: Stopping LSB: NFS support files common to client and server...
Oct  5 15:11:07 sisyphous nfs-common[6520]: Stopping NFS common utilities: idmapd statd.
Oct  5 15:11:07 sisyphous systemd[1]: Stopped LSB: NFS support files common to client and server.
Oct  5 15:11:07 sisyphous systemd[1]: Starting LSB: NFS support files common to client and server...
Oct  5 15:11:07 sisyphous rpc.statd[6539]: Version 1.2.8 starting
Oct  5 15:11:07 sisyphous sm-notify[6540]: Version 1.2.8 starting
Oct  5 15:11:07 sisyphous sm-notify[6540]: Already notifying clients; Exiting!
Oct  5 15:11:07 sisyphous rpc.idmapd[6551]: libnfsidmap: using domain: ITET-PHO
Oct  5 15:11:07 sisyphous nfs-common[6530]: Starting NFS common utilities: statd idmapdrpc.idmapd: libnfsidmap: using domain: ITET-PHO
Oct  5 15:11:07 sisyphous nfs-common[6530]: rpc.idmapd: libnfsidmap: Realms list: 'ITET-PHO'
Oct  5 15:11:07 sisyphous nfs-common[6530]: rpc.idmapd: libnfsidmap: processing 'Method' list
Oct  5 15:11:07 sisyphous nfs-common[6530]: rpc.idmapd: libnfsidmap: loaded plugin /lib/x86_64-linux-gnu/libnfsidmap/static.so for method static
Oct  5 15:11:07 sisyphous rpc.idmapd[6551]: libnfsidmap: Realms list: 'ITET-PHO'
Oct  5 15:11:07 sisyphous rpc.idmapd[6551]: libnfsidmap: processing 'Method' list
Oct  5 15:11:07 sisyphous rpc.idmapd[6551]: libnfsidmap: loaded plugin /lib/x86_64-linux-gnu/libnfsidmap/static.so for method static
Oct  5 15:11:07 sisyphous rpc.idmapd[6552]: Expiration time is 600 seconds.
Oct  5 15:11:07 sisyphous rpc.idmapd[6552]: Opened /proc/net/rpc/nfs4.nametoid/channel
Oct  5 15:11:07 sisyphous nfs-common[6530]: .
Oct  5 15:11:07 sisyphous rpc.idmapd[6552]: Opened /proc/net/rpc/nfs4.idtoname/channel
Oct  5 15:11:07 sisyphous systemd[1]: Started LSB: NFS support files common to client and server.
Oct  5 15:11:07 sisyphous rpc.idmapd[6552]: New client: fa
Oct  5 15:11:07 sisyphous rpc.idmapd[6552]: New client: fb
Oct  5 15:11:07 sisyphous rpc.idmapd[6552]: Opened /run/rpc_pipefs/nfs/clntfb/idmap
Run Code Online (Sandbox Code Playgroud)

当我安装导出时,mount.nfs4 cerberous:/volume1/homes /mnt/test我得到:

Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: New client: fc
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: New client: fd
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: New client: fe
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: Stale client: fe
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: #011-> closed /run/rpc_pipefs/nfs/clntfe/idmap
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: Stale client: fd
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: #011-> closed /run/rpc_pipefs/nfs/clntfd/idmap
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: Stale client: fc
Oct  5 15:11:19 sisyphous rpc.idmapd[6552]: #011-> closed /run/rpc_pipefs/nfs/clntfc/idmap
Run Code Online (Sandbox Code Playgroud)

如何使 id 映射(至少是静态的)在 Debian 上工作?ID 映射一般应与 Synology 配合使用。最终我想在 Linux 机器上自动将 Synology 用户映射到 LDAP 用户。

mbi*_*rth 1

免责声明:没有 Kerberos 服务器的 ID 映射似乎只能在 NFSv4 上工作一半。在列出文件时,我设法让正确的用户名显示在我的客户端上,但创建新文件总是将它们创建为用户无人,因为在这种情况下 Synology 不会映射任何内容。此错误报告链接的线程表明这是idmapd由于某种原因不使用 Kerberos 时的正常行为。(编辑:更详细的解释。

然而,我做了什么:

首先,您必须在加载 NFS 服务后启用 idmapping。为此,您必须/usr/syno/etc/rc.sysv/S83nfsd.sh在 Synology 上编辑该文件。找到线

SYNOLoadModules $KERNELMODULE
Run Code Online (Sandbox Code Playgroud)

然后添加以下行:

echo "N" > /sys/module/nfsd/parameters/nfs4_disable_idmapping
Run Code Online (Sandbox Code Playgroud)

然后,仍然在 Synology 上,编辑/etc/idmap.conf并将其设置Domain为您的ITET-PHO(如果尚未设置)。禁用 NFS,然后在 Synology 控制中心应用并重新启用(+应用)它以重新加载nfds

/etc/modprobe.d/nfs-idmap.conf在您的客户端计算机上,创建一个包含以下内容的文件:

options nfs nfs4_disable_idmapping=0
options nfsd nfs4_disable_idmapping=0
Run Code Online (Sandbox Code Playgroud)

之后重新加载nfs内核模块以应用选项。

还要确保,idmapd正在您的客户端上运行。(我想,在 Ubuntu artful 上,我必须sudo systemctl start nfs-idmapd手动运行。)当然,也可以用作nfsvers=4挂载选项。

(在 Synology 上,您可以killall idmapd在前台运行它idmapd -f -vvv,看看它是否正在执行任何操作。)