I've 2 network drives on one subnet (nfs and samba). I would like to access them only if computer is connected to particular ssid (subnet).

I'm using gnome primarily. And files stops responding if mount points can't be accessed. There is no real way to recover from this apart from connecting to network, unmount and then change network.

I would like those drives to be accessed by system only if they are reachable.

[EDIT][UPDATE]: Following suggestions from comments. I've tried systemd and autofs methods both of them don't work the way I've setup access to mounts. If mount point is in home OR bookmarks in files app, it would hang up as soon as network is disconnected. It works well when mount points are not visible by default (for e.g. /smb/share1). Currently using autofs <- easy and short to setup with mount points under /smb and /nfs

all 21 comments

sorted by: hot top controversial new old
[–] 20 points 11 months ago* (5 children)

Maybe look into autofs which will mount only when you choose to access the drives and then unmount on idle. Could be simpler then trying to react to network status.

https://wiki.archlinux.org/title/Autofs

  • source
  • hideshow 5 child comments
  • [–] [S] 2 points 11 months ago (2 children)
  • [–] 5 points 11 months ago (3 children)

    I know autofs will work with nfs. Never used it with SMB. I’ve used it on a share of /home to specifically mount /home/user as needed (e.g., at login).

  • source
  • hideshow 3 child comments
  • [–] 6 points 11 months ago* (5 children)
  • [+] -13 points 11 months ago (3 children)

    Let's avoid systemd solutions. They'll just lock you deeper into lennart's cancer.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 2 points 11 months ago (3 children)
  • [–] [S] 1 point 11 months ago (2 children)

    I'll have a look at this, updated OP for now

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 11 months ago

    A shot in the dark, but try setting them up to connect to a hostname instead of an IP - maybe if the name doesn't resolve then it won't get stuck?

  • source