Systemd natively supports automount units, which only actually mounts e.g. a network drive when something on the system attempts to access the mount point in question.
For this to work reliably at boot-time for network drives, the trick seems to be to configure systemd to have an unlimited timeout for the units in question.
The following assumes that a share named
//server/media_share will be mounted on
Start by setting up a
.mount unit for the network drive (in this case, it's a samba/cifs share):
# contents of /etc/systemd/system/mnt-server-media_share.mount
# NB: The name of the .mount unit needs to match the mount location!
Description=Server media_stash share
Then, set up an
.automount unit for the
# contents of /etc/systemd/system/mnt-server-media_share.automount
# NB: The name of the .automount unit needs to match the mount location!
Description=Automount unit for //server/media_share
Finally, enable the
.automount unit with
sudo systemctl enable --now mnt-server-media_share.automount.
The end result should be that the share will be automounted the first time something tries to access it.
sudo mount after enabling the
.automount unit should show a corresponding mount point line starting with
systemd-1 on /mnt/server/media_share type autofs (... options ...)