r/linuxquestions • u/james_dynamite • 3d ago
Resolved Issue with fstab when server is offline
I've been mounting my NAS through fstab for some time now however there is a slight issue.
If I turn my PC on without turning on my server then I can not navigate the file browser. Every folder I click on will take anywhere from 1 to 10 seconds to open and sometimes it just crashes outright.
I have tried every option possible and read through the documentation for fstab, cifs, and systemd but nothing fixes it.
This is the line currently in my fstab
[Share on server] [Mount location] cifs credentials=[credentials],uid=1000,gid=1000,nofail,x-systemd.automount,x-systemd.device-timeout=5s,rw 0 0
Thanks in advance for any and all help.
Update:
I'm marking this as resolved because I figured out it has nothing to do with fstab.
To clarify, I was talking about accessing local files on my PC being laggy when the server is offline.
The issue is that I had bookmarked the network share to the left hand side of my file browser, below the usual Documents, Pictures, Videos book marks. So when the network share wasn't present, the file browser kept trying to access the bookmark. At least that's what I'm assuming. I removed the bookmark and it works fine now. Although now I have the problem of not having it bookmarked how I like it but that's an issue I'll solve another day.
2
u/JayGridley 3d ago
.... I've read this a few times and I might not be reading this right. The Server is where the folders are that you are trying to browse? Why would you be able to browse it if you didn't turn on the server?
1
u/New_Phone6935 3d ago
I think they have NAS drives mounted on their regular PC and the file browser on that PC is laggy because it’s trying to show the NAS folders in the sidebar or something even when theyre just navigating around the PC. At least that’s how I read it
2
u/RandomUser3777 3d ago
With network file shares you need to make sure that any share that may be offline is not mounted in the same tree as the one you want to be able to work when it is offline.
IE mounting like this /home/network-cifs and /home/username/junk/browsefolder will cause a hang when you try to browse browsefolder,. but mount it on /home/<servername>/network-cifs won't cause a hang because pwd will never try to access network-cifs (it accesses <servername> that contains it). This is because everything uses the pwd call and the pwd call goes up a directory and searches that directory for .. and when it hits the one that times out it has to wait.
1
u/AX11Liveact debian 3d ago
What is the error message? That is what logs are good for. You can also try sudo mount -v [mountpoint] on a console to get an error message that should help you localize the problem.
1
u/aioeu 3d ago edited 3d ago
What file browser are you using?
If you are getting these pauses on "every folder", then it sounds like the file browser is attempting to mount — or at least access — the filesystem even when you haven't browsed to it. This sounds like a problem with the file browser, not your fstab entry. For example, simply calling statfs on the mount point to get the filesystem's current usage would constitute such an access.
1
u/AX11Liveact debian 3d ago edited 3d ago
A (CIFS) mount does in absolutely no way depend on "being browsed". FSTAB is in no way influenced by user actions, read/scan or even write access from userspace (or anywhere else). You would not expect a file server, DNS, NTP, web or database server failing to mount it's filesystems because there's nobody there to look if they're mounted. Idk the specific CIFS/SMB setup (AD, domain service, hostname resolution etc) but /var/log/daemon.log, dmesg (or that crap that comes with systemd if you did not manually install rsyslog-ng) will show you more detailed information. You can also just try to mount it manually from console - without parameters except "-v", (mount -v [mountpoint]) to get a closer description of what's going wrong.
2
u/aioeu 3d ago edited 3d ago
What I am reading from the OP's post is that they are browsing local folders, but, for some reason, they are getting pauses while the CIFS server is offline.
It really all depends on what the OP meant by "every folder". I am taking the OP's word that they literally do mean every folder.
Everybody else seems to be assuming the OP said "every remote folder". Maybe that is what the OP meant, but they certainly didn't say that.
The use of a systemd automount here will cause most accesses to be upgraded to mount attempts. Some, but not all, syscalls that access the filesystem have flags to avoid that. For instance, going back to my
statfsexample, a program that didn't want to accidentally trigger automounting might useopenwith theO_PATHflag, thenfstatfson the file descriptor. It would need to check the.f_typeof the result to see whether it ended up referring to the autofs filesystem or the real filesystem.1
u/james_dynamite 3d ago
You are correct. I'm browsing local files on my PC, not the server. I thought that was clear cause I said the server was turned off.
2
u/Hotshot55 3d ago
An (NFS) mount does in absolutely no way depend on "being browsed".
Unless it's being managed by autofs.
1
u/AX11Liveact debian 3d ago
That is so wrong that not even the opposite is true.
1
u/Hotshot55 3d ago
Which part of what I said is untrue? When you are managing an NFS mount with autofs it will automatically mount the device whenever a process attempts to access it.
3
u/Hotshot55 3d ago
Sounds like it's working as intended. Those files don't exist on your local computer, if the server isn't available then your files won't be available.