Mount network drives

;y new PC needs some time to create its network connection while booting up. This led to problems again and again, until I found this method to make it wait while booting.

To achieve this I created 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.9; do sleep 1; done'

[Install]
WantedBy=network-online.target
EOF

(you can put in your router's address for example)

You can then activate the service with:


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

Source:

https://systemd.io/NETWORK_ONLINE/