Thursday, November 16, 2017

Making sure a network share mounts after booting in Linux

I ran into a situation, where my CIFS / Samba share wasn't mounting automatically on boot. It appears to be a race condition: one that's resolvable by forcing another attempt later in the boot process. Create /etc/systemd/system/mountall.service, and use systemctl enable mountall to activate it.

[Unit]
Description=Ensure all drives are mapped
After=network.target

[Service]
Type=simple
ExecStartPre=/bin/sleep 5
ExecStart=/bin/mount -a

[Install]
WantedBy=multi-user.target

References