Debian: Mounting Remote File Systems (NFS, CIFS, Etc.)


It seems that the usual way of mounting remote file systems that is based on fstab(5) does not work anymore on modern Debian GNU/Linux systems in their default configuration.

The culprit is systemd(1): by the time the service will try to mount a remote file system, the machine most probably will not be online yet and mount(8) will fail.

Debian does not seem to offer any other solution but to use systemd-networkd(8) together with systemd-networkd-wait-online(8).

The Recipe

First, configure systemd-networkd(8).

WARNING: You should like to modify the below to fit your purpose. At very least, you should replace enp0s25 with the correct name of an existing network interface. For a coherent guide, please see the ArchWiki:

sudo tail /etc/systemd/network/50-default.network <<EOF
[Match]
Name=enp0s25

[Network]
DHCP=yes
EOF

Next, enable systemd-networkd.service and systemd-networkd-wait-online.service:

sudo systemctl enable systemd-networkd
sudo systemctl enable systemd-networkd-wait-online

At this point, I recommend to reboot and check connectivity in order to eliminate any confusion regarding the cause of a possible mistake at a later stage.

Upon reboot, you can proceed to configuring the mount point in fstab(5).

For instance, I have the following in fstab(5) of a Debian machine in order to mount a read-only remote mount point that is served by nfsd(8) running on OpenBSD:

192.168.123.237:/home/export /mnt/nfs nfs resvport,ro,rsize=32768,wsize=32768

(Please note that the above does not require any options provided by systemd-mount(5).)

Vadim Penzin, August 8th, 2019


I hereby place this article along with the accompanying source code into the public domain.
I publish this information in the hope that it will be useful, but without ANY WARRANTY.
You are responsible for any and all consequences that may arise as the result of using this information.