M BUZZ CRAZE NEWS
// news

How to automount NAS drive on WiFi

By David Jones

I have Kubuntu 20.04 which I have connected to my (wpa2 encrypted) wifi. I have the password remembered in the system, so whenever I login to KDE the computer connects to my wifi. I also have NAS on the same wifi and I would like to automout it. But this is only possible when I'm connected to wifi, which I guess happens after I log in to the KDE (because otherwise how it would know the password).
Is there a way how to mount something automatically when I'm connected to wifi? I tried to put the mounts to /etc/fstab and it aoutomounts if I have ethernet connection. On wifi thery are not mounted unless i do sudo mount -a 'manually'.
I'm also not sure how to unmount correctly during shutdown. Just shutting down computer (via the KDE menu of course) sometimes stucks on the umount. I guess the wifi is already disconnected at that point so it can not correctly unmount and it just timeouts after like a minute, which blocks the shut down process.
Thanks

4

1 Answer

Usually systemd takes the job of mounting and unmounting. I've done the following on two of my devices to connect to my NAS on demand: Open fstab and enter the mount:

The scheme is [target] [mountpoint] [options]

//server/path /path/to/local/mount cifs username=XXX,password=YYY,noauto,_netdev,users 0 0

The mount will take place when you try to connect to your mountpoint, either by script or via files/nautilus. "noauto" is the flag that prevents your system to try to connect immediately.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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