I think it might involve systemd, but when I connect to my specified network, I want to mount my network drive (which is a usb drive plugged into my router)
I already have the mounting part working, I have it set up as a bash alias, but obviously having it mount automatically would be better.
Does anyone know how to do this? I saw some related articles but nobody was able to figure it out in the threads I saw.
The easiest is probably a NM dispatcher script that starts after NM established a connection to your network. You can specify the network connection, but it needs to be unique for your home network.
Adding this line to your /etc/fstab file the share will be mounted on demand (when you access to it) that is the recommended option: //192.168.1.1/USB_Storage ~/readyshare cifs _netdev,nofail,username=admin,x-systemd.automount 0 0
If you need that this share to be always mounted, simply remove the x-systemd.automount part: //192.168.1.1/USB_Storage ~/readyshare cifs _netdev,nofail,username=admin 0 0
I know this doesnât exactly answer @WinterMadnessâ question, but I think it might work.
I think using the mount on demand method will prevent the system from trying to mount it if the ~/readyshare directory is not browsed. Still, the â_netdevâ and ânofailâ options would prevent problems whether you are not connected to any network, or to foreign networks.
It is not automatically, if you personally wish to check to SSID and then decide to run a script.
In NM, every connection has its own UUID. Use nmcli connection show . In a dispatcher script you can do a if statement to check the UUID and then run commands or not. Read the Arch Wiki article, it describes how a script can look like.
Iâve marked this answer as the solution to your question as it is by far the best answer youâll get.
However, if you disagree with my choice, please feel free to take any other answer as the solution to your question or even remove the solution altogether: You are in control! (If you disagree with my choice, just send me a personal message and explain why I shouldnât have done this or or if you agree)
P.S. In the future, please donât forget to come back to your question after your issue has been solved and click the 3 dots below the answer to mark a solution like this below the answer that helped you most:
so that the next person that has the exact same problem you just had will benefit from your post as well as your question will now be in the âsolvedâ status.