Saturday, May 20, 2017

Raspbian Jessie NFS mounts fail because of rpcbind service not running

You happen to have NFS mounts on your Raspbian and you want them to come up after a reboot or you configure them but get the error that rpc.statd or rpcbind is not running?

pi@raspi1:~ $ sudo mount /mnt/nfsserver/backups
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified
pi@raspi1:~ $ sudo /etc/init.d/rpcbind start
[ ok ] Starting rpcbind (via systemctl): rpcbind.service.
pi@raspi1:~ $ sudo mount /mnt/nfsserver/backups

Now you have manually fixed this once, but on the next reboot, your fix will be gone again. You need to fix that with the below steps, taken from this great help.

0. Assumptions
You have a working NFS mount on your Raspbian which is or can be mounted and configured e.g. into /etc/fstab

1. Make yourself root
su -

2. Create /etc/systemd/system/nfs-common.service
cat >/etc/systemd/system/nfs-common.service <<\EOF
[Unit]
Description=NFS Common daemons
Wants=remote-fs-pre.target
DefaultDependencies=no

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/init.d/nfs-common start
ExecStop=/etc/init.d/nfs-common stop

[Install]
WantedBy=sysinit.target
EOF

Copy paste the above and hit ENTER

3. Create /etc/systemd/system/rpcbind.service
cat >/etc/systemd/system/rpcbind.service <<\EOF
[Unit]
Description=RPC bind portmap service
After=systemd-tmpfiles-setup.service
Wants=remote-fs-pre.target
Before=remote-fs-pre.target
DefaultDependencies=no

[Service]
ExecStart=/sbin/rpcbind -f -w
KillMode=process
Restart=on-failure

[Install]
WantedBy=sysinit.target
Alias=portmap
EOF

Copy paste the above and hit ENTER

4. Create /etc/tmpfiles.d/rpcbind.conf
cat >/etc/tmpfiles.d/rpcbind.conf <<\EOF
#Type Path        Mode UID  GID  Age Argument
d     /run/rpcbind 0755 root root - -
f     /run/rpcbind/rpcbind.xdr 0600 root root - -
f     /run/rpcbind/portmap.xdr 0600 root root - -
EOF

Copy paste the above and hit ENTER

5. Configure the services to run at startup
systemctl enable rpcbind.service
systemctl enable nfs-common

Copy paste the above and hit ENTER

6. Reboot and check if your NFS mount is there now
pi@raspi1:~ $ mount
nfsserver:/volume1/backups/raspi on /mnt/nfsserver/backups type nfs

No comments:

Post a Comment