# NFSv4 only but rpc.mountd needed?

## musv

Hi there, 

I was playing around with my nfs configuration and came to the strange conclusion, that it only works with rpc.mountd. 

Ok, let's start at the beginning: 

I switched quite long time ago to systemd. At that time there were no nfs unit files available on Gentoo. So I took them from a Wiki. It worked quite ok, but sometimes the nfs service shut down before the nfs shares were unmounted. Therefore I checked the current Gentoo systemd units and compared them with the Arch units.

My current config:

```
[Unit]

Description=NFS server and services

Requires= network.target proc-fs-nfsd.mount rpcbind.target 

Wants=nfs-idmapd.service

After= network.target proc-fs-nfsd.mount rpcbind.target 

After= nfs-idmapd.service

[Service]

Type=oneshot

RemainAfterExit=yes

ExecStartPre=/usr/sbin/exportfs -r

ExecStart=/usr/sbin/rpc.nfsd -N2 -N3 -V4

ExecStop=/usr/sbin/rpc.nfsd 0

ExecStopPost=/usr/sbin/exportfs -au

ExecStopPost=/usr/sbin/exportfs -f

ExecReload=/usr/sbin/exportfs -r

[Install]

WantedBy=multi-user.targe
```

```
[Unit]

Description=NFSv4 ID-name mapping service

Requires=var-lib-nfs-rpc_pipefs.mount

After=var-lib-nfs-rpc_pipefs.mount

BindsTo=nfs-server.service

[Service]

Type=forking

ExecStart=/usr/sbin/rpc.idmapd
```

```
[Unit]

Description=RPC Bind service

Requires=rpcbind.socket

After=network.target

Wants=rpcbind.target

Before=rpcbind.target

[Service]

Type=forking

ExecStart=/sbin/rpcbind

[Install]

Also=rpcbind.socket
```

```
[Unit]

Description=RPCbind Server Activation Socket

[Socket]

ListenStream=/var/run/rpcbind.sock

[Install]

WantedBy=sockets.target
```

The other units are the same in Arch and Gentoo. My goal was to drop completely NFSv2 and NFSv3. In the kernel I activated only NFSv4 and v4.1 for client and server. In the fstab the shares are mounted only with type nfsv4. 

When I start now the server, it doesn't complain and starts up fine. But on the client trying to mount a share I get the error message:

```
mount.nfs4: access denied by server while mounting hexe:/home_sm
```

Just for fun I started nfs-mountd (rpc.mountd) on the server. And surprise - I can mount the share. Have a look into the manpage:

 *man rpc.mountd wrote:*   

> The rpc.mountd daemon implements the server side of the NFS MOUNT protocol, an NFS side protocol used by NFS version 2 [RFC1094] and NFS version 3 [RFC1813].

 

So what's wrong? Why do I need rpc.mountd in a NFSv4 only environment?

----------

## salahx

nfs.mountd serves 2 purposes: One is the NFSv2/v3 MOUNT protocol, which requires the portmapper and causes SUN RPC traffic to flow over the interfaces. However, it also has second purpose: To export the filesystems in /etc/exports. This is still required even for NFSv4, however the clients neither talk to the portmapper nor nfs.mountd in this case - only the NFS server does. 

If you wish, if all your clients are NFS4 only, you can firewall off the portmapper and nfs.mountd and everything will still work normally.

----------

## musv

Thanks for your explanation.

----------

