Problem Description:
I have my NAS mounted on my Linux box using NFS4. It all works great… but somehow, there is some kind of timeout going on; if I don’t access the NFS mount, they get dismounted (they are restored by accessing the drives, such as with “ls”. I want the mount to stay there, but I cannot seem to find out any information about this. Many years ago, the NFS mounts stayed mounted, but now it looks like some kind of auto-mount system is running. Is there a way to disable this unwanted feature?
Relevant System Information:
The NAS is mounted as (from /etc/fstab):
NAS:/ /media/NAS nfs4 _netdev,relatime 0 0
Screenshots or Error Messages:
No error message; I just have to do “ls” on the mount directory for the mount points to reappear.
What I’ve Tried:
Not much; I thought there may be an NFS4 mount option to disable this “feature”.
/media is generally used for mounting removable/temporary devices.
I suggest that you create a permanent new mountpoint e.g.
sudo mkdir /mntnas
Alter your /etc/fstab to reflect the new mountpoint
Also, remove the current NAS mountpoint otherwise your boot proceess may stall looking for a missing device.
Are you saying that Ubuntu will remove anything mounted under /media in some kind of timeout… but won’t if I just change the mount point. That seems very odd to me.
I guess I could try it – my Rythmbox database is rather substantial and points to the other path. I guess I could use “sed” to change all the paths, once I know a different mount point will work properly.
I was rather hoping to be able to disable the unwanted “feature”.
I guess I could do that… but my Rhythmbox database all points to /media/NAS… I guess that’s why there is a tool called “sed”, eh?
I appreciate the feedback, but I don’t think that this line is correct.
The NAS is mounted on Windows and on an iMac, and the mount doesn’t go away (of course, it is not using NFS on either of those machines).
However, I do have an external SSD drive mounted under /media, and it does not go away (again, it’s not using NFS).
It looks for all the world as if the NFS is configured with some kind of timeout.
When trying to research the problem, I read about “autofs”, but that isn’t installed. There is another similar feature whose name escapes me – I do have that installed (it must have come with the system, as I’ve not installed it).
I really don’t believe that the mount point is somehow making the mount go away.
The Ubuntu machine is currently in this state where the directories are missing. The output of “df -h” is
Well, that’s official, if you read the link that I sent you. /media for removable media, /mnt for temporary media.
You could well be right about that. As I say, I personally haven’t had the problem. Still, it’s a good idea to stick to standards — they’re there for a reason.
Might it be that the hard drives have a timeout on them? My external USB drives have a timeout. If they’re not used for a certain time (I think that I set it to 30 minutes), they power down. They do remain mounted, though, so when I access them again, they take several seconds to power up and then continue from where they left off.
It would be worth checking the drives for timeouts (check their manual, which should tell you how to set and clear timeouts), and if that proves negative, check the entire chain of connections. Also check that the power point for the drives isn’t subject to dips.
The /media dir is managed by udisks2 usually to dynamically mount removable media (cdroms, usb sticks etc) in there as a user, might be that there is some clash going on here where udisks2 actually triggers the mount when you enter the dir…
I’d use /mnt/nfs or something else you create under /mnt for non removable device mounts to prevent any interfering with udisks2 …
It could be that there is a timeout – not on the NAS itself, as far as I know. I guess I could poke around there, but I’m surprised it would affect just the Ubuntu mounts.
Where are the timeouts set for USB? I don’t see anyplace to adjust timeouts.
I poked around on the NAS configuration for NFS and I didn’t see anything like timeouts anywhere, but there could be.
I don’t think it’s power issues – it happens regularly; usually around 10-15 minutes (I haven’t exactly timed it), but I’m pretty certain that some kind of timeout is involved.
Ah, okay… udisks2 could be it. I guess I can try just creating a new mount point and seeing if that changes anything.
Or is there a way to tell udisks2 to NOT managed /media?
Do you think udisks2 would get upset if I created sym links in my mount points under /media? I don’t relish the thought of changing the thousands of references to /media/NAS.
Maybe I just didn’t get it but in your initial post you wrote of mounting the root directory of the NAS only. The mount1 to mount4 are ‘mounts’ on the NAS but in Ubuntu these are just (sub) directories. Is this correct?
What does df -h show after you used ls to ‘reconnect’ the directories? Does the output for the NAS change?
As far as I understand the directories are shown to you as you access them. What happens if you access a file in one of the ‘vanished’ mount directories directly using its path? Is it accessible?
What happens if you create one mount for each mount directory?
I did it that way in /etc/fstab because in my research regarding NFS4, if you mount a root point, NFS4 will automatically mount all of the existing mount points from the source area.
mount1-4 are 4 separate exports from the NAS and are mounted in four separate directories on Ubuntu.
I showed the output of df -h above (after doing an “ls”) above; to repeat, it shows
Good question; I hadn’t tried that, so I did. I tried accessing a file on “mount1”; it succeeded and mount1 (and only mount1) immediately appeared in “df -h”.
I’ll wait to get your feedback before proceeding.
It would be an interesting experiment to reconfigure /etc/fstab to explicitly list each mount point.
Meanwhile, if I get the time, I will do additional reading about NFS4.
Note: the main reason that this is a problem for me is that Rhythm Box’s library is hosted on the NAS, and RhythmBox shows the files is “missing” when the mounts go away. The only way to get them to return is to do the “ls” on the NAS mount directories.
I’m not familiar with Rhythm Box but maybe there is a possible workaround: if you do not change your media content often perhaps disabling Rhythm Box’s watch functionality just keeps the library as is and doesn’t update when directories/folders disappear.
See Rhythmbox - 5.1. Add tracks in the Library and Customizing Rhythmbox - 14.1.2. Music
To get back to the nfs4 (I think I need to mention that I do not use nfs!): I searched the manpage nfs for infos and found following info in section ‘transport methods’:
(…) After the client exhausts its retransmits (the value of the retrans mount option), it assumes a network partition has occurred, and attempts to reconnect to the server on a fresh socket. (…)
Perhaps there is some timeout in the network connection that causes the disappearing of the mounts/directories. I doubt they get lost totally. So maybe tweaking the connection parameters and/or mount options may help.
The media content doesn’t change that often, but turning off the feature in RhythmBox (my favorite media player) is just working around the real problem; it’s like adding a cron() job to do an “ls” every five minutes. Currently, if RhythmBox is up and I see that it has missing media, I just recall the “ls” command that makes the mounts re-appear, so I can live with it – but it’s annoying.
I’m not having any errors at all; from experience, it seems like the directories go away after not being accessed for 10 minutes: if I am playing something from “mount1”, then all the media files stored on “mount2-4” vanish and come back when I do “ls”. There is never any indication of network errors. I really think this is some kind of oddball automount thing at work.
It probably IS a mount option or parameter, but I haven’t found it yet.
Or, as you originally suggested, perhaps mounting each mount point specifically in /etc/fstab will solve the issue.