Mounting network drives


My PC needs some time to establish its network connection on boot up. This has caused problems in the past, until I found a way to make it wait for the network connection at boot.

To do this, I set up the following service:

sudo bash -c "cat > /etc/systemd/system/wait-for-network.service" <<EOF
[Unit]
Description=service for making sure network is available before trying to mount
DefaultDependencies=no
After=nss-lookup.target
Before=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=sh -c 'until ping -c 1 192.168.178.250; do sleep 1; done'

[Install]
WantedBy=network-online.target
EOF

(You can e.g. enter the address of your router here)

The service can be activated with:

sudo systemctl daemon-reload
sudo systemctl enable wait-for-network.service

Source:

🔗https://systemd.io/NETWORK_ONLINE/