25

I'm trying to mount a CIFS device after the system boots (using systemd), but the system tries to mount the system before the network is established, so it fails.

After logging into the system I can mount it without any problem, using sudo mount -a.

How can I tell my Arch (arm) to wait until the network is available?

1

3 Answers 3

37

Adding _netdev to the mount options in /etc/fstab might be sufficient.

Mount units referring to local and network file systems are distinguished by their file system type specification. In some cases this is not sufficient (for example network block device based mounts, such as iSCSI), in which case _netdev may be added to the mount option string of the unit, which forces systemd to consider the mount unit a network mount.

Additionally systemd supports explicit order dependencies between mount entries and other units: Adding x-systemd.after=network-online.target to the mount options might work if _netdev is not enough.

See the systemd mount unit documentation for more details.

2
  • 1
    the _netdev section did not work for me BUT it was left and the x-systemd.after=network-online.target did on nfsv4 mounts, this was verifed on U16.04.6 vm
    – ssvegeta96
    Dec 23, 2019 at 19:16
  • @ssvegeta96 yeah, i have never in my life seen that _netdev works on systemd. they just don't care enough. (not to mention that needing any of that is a regression compared to classic unix which simply sorted the fstab from local to non-local) Aug 29, 2022 at 1:11
8

Add _netdev to the /etc/fstab entries in question. From the manpages for `mount(8)':

_netdev The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).

1

A bit hacky, but all _netdev and x-systemd options didn't help, since WINS/DNS was stil not running.
I got going with a root crontab entry:

@reboot /usr/bin/mount -a

This is run late in the boot process.
So even if systemd fails in the first place to mount the CIFS mount defined in fstab, later a mount -a is run again and this time the mount succeeds.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 4 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .