Instead of fighting systemd assumptions and legacy options which may or may not work, make your service and make your mount target depend on it.
My SMB shares are mounted from 192.168.1.2, change to what is correct in your case.
# /etc/systemd/system/wait-for-ping.service
[Unit]
Description=Blocks until it successfully pings 192.168.1.2
After=network-online.target
[Service]
ExecStartPre=/usr/bin/bash -c "while ! ping -c1 192.168.1.2; do sleep 1; done"
ExecStart=/usr/bin/bash -c "echo good to go"
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Enable that service with:
sudo systemctl daemon-reload
sudo systemctl enable --now wait-for-ping.service
Then edit your fstab as follows to include this as final mount option:
x-systemd.after=wait-for-ping.service
Do another systemctl daemon-reload
and you can verify that your mount target has the correct option set. My mount target is /mnt/media
, that creates mnt-media.mount
, so do:
systemctl cat mnt-media.mount
This should have an header like this:
# Automatically generated by systemd-fstab-generator
[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
After=wait-for-ping.service
# ... rest of file follows ...
Reboot your machine and you should find your mounts waiting until a ping succeeds.