0

I have several folders on my NAS set to automount on my Xubuntu laptop at boot, using a saved credentials file. Each one has an fstab entry that looks like this:

# NAS home
//192.168.1.111/Home/ /home/username/mountpoint cifs credentials=/home/username/nas.creds,uid=1000,gid=1000 0 0

This works perfectly when the laptop is connected to Ethernet on boot. However if not (as will almost always be the case) then the shares fail to mount. They are still visible on the desktop/file manager but if I attempt to open them a message pops up that they can only be mounted by root.

If I then use sudo mount -a then the shares mount as usual.

My understanding is that this happens because fstab is executed some time before a Wi-Fi connection to the network is established, meaning the mounts fail.

Adding sudo mount -a to the startup apps won't work as it requires a password.

So, what is an appropriate method to ensure that the shares mount after a Wi-Fi connection is established?

Thanks!

0

You can put your mount script in /etc/network/if-up.d and it will run with sudo when the connection is made. I did something similar to fix an 18.04 "enhancement" and it worked, see my answer to Wake-on-LAN quit working with latest kernel (Bionic)

  • Thanks! I've never written a script before, but following your linked example I created a file under /etc/network/if-up.d and added the following: #!/bin/sh /bin/mount -a Didn't work on the first reboot, so I changed the permissions to make the file executable. After the next reboot, the shares were mounted! Thanks again. – 4n3wv Jul 18 '18 at 14:02
  • I am glad it worked for you! I am learning as well. – Organic Marble Jul 18 '18 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.