this post was submitted on 14 Nov 2025
31 points (100.0% liked)

Linux

61653 readers
717 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

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

top 30 comments
sorted by: hot top controversial new old
[–] IanTwenty@piefed.social 20 points 2 months ago* (last edited 2 months ago) (3 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

[–] rando@lemmy.ml 4 points 2 months ago

Thanks will have a look at autofs

[–] rando@lemmy.ml 2 points 2 months ago (1 children)
[–] IanTwenty@piefed.social 1 points 2 months ago (1 children)

How frustrating about the hangs, looks like this has been a problem for years in various desktops and file managers and you've already found the best mitigation (keeping the mounts out of home)

[–] rando@lemmy.ml 1 points 2 months ago

Bookmarking this location in file manager also causes problem.

[–] thatradomguy@lemmy.world 2 points 2 months ago

I second this. autofs is was I'd recommend.

[–] thenextguy@lemmy.world 6 points 2 months ago* (last edited 2 months ago) (2 children)
[–] rando@lemmy.ml 1 points 2 months ago

I currently have systemd solution but it only manages to mount when needed.

[–] d00phy@lemmy.world 5 points 2 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).

[–] corsicanguppy@lemmy.ca 3 points 2 months ago

I've used smb with autofs. Works a treat.

Be sure you have nothing running from or accessing the mount constantly, of course -- I forgot with a homedir -- or it'll never I mount.

[–] rando@lemmy.ml 3 points 2 months ago

Thanks will have a look at autofs

[–] rando@lemmy.ml 1 points 2 months ago
[–] stupid_asshole69@hexbear.net 2 points 2 months ago (2 children)

When using gnome you’re supposed to not have specific filesystems mounted if they’re not gonna be available.

The proscribed solution is to use systemd to figure out if those mount points are available and mount them, but that would have to be coming off networkd instead of fstab which it sounds like is what you’re using.

A script to figure out if the server you want is available before mounting the filesystem would be easy, but a bad idea because that should be handled by your init system (probably systemd as above).

You could also just abandon gnome and use something else.

[–] rando@lemmy.ml 1 points 2 months ago

updated OP for now

[–] rando@lemmy.ml 1 points 2 months ago (1 children)

Not really tied to gnome, it's just something I'm using. Would KDE work better ?

[–] stupid_asshole69@hexbear.net 1 points 2 months ago (2 children)

You’re asking the wrong person, I use lxqt.

Tonight I can see if konqueror (the kde file browser still think…) does the same thing.

How are your network filesystems mounted, fstab?

[–] rando@lemmy.ml 1 points 2 months ago

It was through fstab until recently. About 2 weeks back I moved to mount them on demand (systemd, will confirm exact method when I'm in front of computer) however this still doesn't address unmount part when I switch network.

[–] rando@lemmy.ml 1 points 2 months ago (1 children)

just tried Dolphin (KDE file manager) - same experience. Going to experiment with autofs next

[–] stupid_asshole69@hexbear.net 2 points 2 months ago (1 children)

Man that makes me feel old, apparently konqueror was the kde web browser!

So if I access a smb network share in pcmanfm-qt then switch networks my cursor turns into the watch when I try to click stuff in the share but nothing is hung or stuck and I can just click off it and even unmount using the eject icon beside the share name.

This is using Debian 13 with lxqt.

[–] floquant@lemmy.dbzer0.com 1 points 2 months ago (1 children)

I think the problem is NFS more than Gnome - even umount chokes on an unresponsive share

[–] stupid_asshole69@hexbear.net 1 points 2 months ago

Oh shit, you’re right! I assumed the op was trying the same thing on smb and nfs.

Do you think it needs the “soft” option which makes data loss a possibility.

[–] just_another_person@lemmy.world 2 points 2 months ago (1 children)
[–] rando@lemmy.ml 1 points 2 months ago (1 children)

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

[–] just_another_person@lemmy.world 1 points 2 months ago (1 children)

You never mentioned you were trying to mount live files or your home directory...that's an entirely different thing.

Yes, it does matter.

[–] rando@lemmy.ml 1 points 2 months ago

I'm not mounting home directory itself but my samba mount point directory was inside home directory. For e.g. /home/user/share1

[–] flx@lemmy.blahaj.zone 1 points 2 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?