how to setup ubuntu that fstab runs after network is connected?

Solution 1:

You can declare this filesystems as a network device by adding _netdev to the options sections of your fstab line like so:

//192.168.5.167/H /mnt/ssd cifs credentials=/root/.smbreds,_netdev,noauto,x-systemd.automount 0 0

This will prevent the system from attempting to mount this filesystem until the network has been enabled on the system.

This is stated in man-pages for mount:

_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).


Important:

  • You appear to be trying to use x-systemd.automount but not successfuly. As it appears in the example you posted in your question, you have added an extra space between x- and systemd.automount which will result in an error. If you want to use systemd.automount in your fstab options, then use it like this x-systemd.automount and then run sudo systemctl daemon-reload and follow it by sudo systemctl restart remote-fs.target
  • I assume you understand that having the noauto option as in the example you added to your question, will prevent this filesystem from beeing mounted at boot time and will not be mounted with mount -a command. This filesystem can only be explicitly mounted with this option in the fstab line. If that is not what you want, then you should remove the noauto option.