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.
Linux
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
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
Thanks will have a look at autofs
updated OP
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)
Bookmarking this location in file manager also causes problem.
I second this. autofs is was I'd recommend.
Systemd will do this. Iirc you just need to put the mount info in fstab.
I currently have systemd solution but it only manages to mount when needed.
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).
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.
Thanks will have a look at autofs
updated OP
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.
updated OP for now
Not really tied to gnome, it's just something I'm using. Would KDE work better ?
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?
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.
just tried Dolphin (KDE file manager) - same experience. Going to experiment with autofs next
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.
I think the problem is NFS more than Gnome - even umount chokes on an unresponsive share
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.
This should sidestep that and timeout pretty quickly: https://jshtab.github.io/guide/gvfs-autmount/
I'll have a look at this, updated OP for now
You never mentioned you were trying to mount live files or your home directory...that's an entirely different thing.
Yes, it does matter.
I'm not mounting home directory itself but my samba mount point directory was inside home directory. For e.g. /home/user/share1
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?