Can't automount NFS via fstab

Hello,

I’d like to mount my NAS NFS share on startup. I’ve added it to fstab, and mount works flawlessly every time. But on startup, it doesn’t get mounted.

I don’t get any error messages, and can’t find anything relevant in dmesg or journalctl -b (though I may just not know what’s relevant). It just boots happily without ever appearing to try mounting the drive. And each time, if I “sudo mount -vvv -a”, it mounts it without complaint and works beautifully.

The current incarnation of the fstab entry (based on other threads here) is:

192.168.1.105:/volume1/Files /mnt/nas nfs vers=4.1,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min 0 0

I’ve tried defaults,_netdev, and pasting in the options listed in /etc/mtab, along with all kinds of other options Google has thrown at me. All of it mounts fine from the command line, then does nothing at startup.

Unfortunately, I have no idea what I’m doing. Any pointers?

At a not too distant past time, I did this (from my server), and had issues with the mount process beginning before the network had came up and was ready. I don’t remember the solution just now, but there was one in the options.

That certainly makes sense. But as I understand it, both the “nfs” type and the “_netdev” option are supposed to clue it in to wait for the network to be ready.

Hey ScottA., welcome! Good to have you with us!

Here’s how I mount my NFS shares from my Synology NAS. If you look at my post history, you should see a response I made to someone who had a similar issue, that references some changes that needed to be made NAS-side, but I don’t think you have that problem. I did have to drop down to NFS v3 to get full compatibility though, - which might be worth a shot.

fstab entry
<nas-ip>:/volume1/<folderpath> /mnt/<mountfolder> nfs defaults,user,x-systemd.automount 0 0

Hopefully that points you in the right direction

Thanks, it looks like I hadn’t tried option “user” before. I made my fstab entry look exactly like yours (with my specifics), and got the same same result: mounts fine manually, completely ignored on startup.

I disabled NSF v4 on the server, and (aside from needing to try a few times until it got the protocol version right) the client mounted fine manually. And still ignored it on startup. :cry:

Can I just sanity check something, are your mount points in /mnt set to be owned by you?

sudo chown username:username /mnt/<foldername>

here is my working fstab entry:

user@server.bam:         /mnt/mountpoint         fuse.sshfs      port=22,noauto,x-systemd.automount,_netdev,reconnect,identityfile=/home/user/.ssh/yourprivatekeytoserver,allow_other,default_permissions    0 0

Here, the most notable thing is, you’ve already established a ssh connection using private and public key. Meaning, you dont need password, and you have already tested connection so that the server has been added to ‘known hosts’ file. Therefore, you put your privatekey with path as ‘identityfile=/path/to/yourprivatekey’

They weren’t, so I went ahead and did that. No change - mountable manually, not on start.

Edit: Well, it did change it so I can “mount -a” as user rather than sudo.

So this isn’t an NFS mount at all, it’s an SSHFS mount? I’ll have to start reading up on what that even is.

Okay, that’s a bit clearer, thanks! This is way, way easier to fix. Going to refer back to a previous post :slight_smile: :

Essentially I have an account username on my NAS that has the same GUID as my client side username on my Linux client.

<NAS_username> GUID 1000 <==> <Linux_username> GUID 1000

I’m sorry, but somewhat disregard my comment, I dunno why but i thought it was SSHFS related! oops!

But if this were a problem with GID/credentials, wouldn’t it have the same problem when I “mount -a”?

From what I’ve seen, it’s more that your NAS recognises permissions server-side, rather than you having to authenticate client-side. I got mine to auto-mount by setting my NAS to map all users to admin for read/write. As long as your mount points are chowned to you, it should work. Sorry I can’t help more on this.

I already had root mapped to admin, so I tried mapping all users to admin. No change: mounts fine manually, doesn’t happen at startup.

However! Along the way I discovered something interesting. At some point, after mounting the share manually I added it to Dolphin’s Places, so it’s always there under “Remote.”

Now, clicking on the share in Dolphin is just as effective as “mount -a” at getting the share to show up. Maybe that’s expected?

At this point I should probably just give up trying to get this to work properly, and start thinking about workarounds. Is there any kind of shell script or something that runs on startup, before I fire up Dolphin or Konsole? Something I can put a mount -a command into?

Yep, my shares are listed in the Remote section of Dolphin, they appeared when I set up my fstab and mount points I think (it’s been a while):

image

If you want to prove that your shares are auto-mounting, I guess you could go into Konsole before you go into Dolphin, and just see if your /mnt folders are populated with content. If it’s not auto-mounting, they’ll be empty.

Beyond that, I guess you could either use the auto-mount settings option in System Settings, or add the command to your .bashrc file in the root of your home directory.

The System Settings doesn’t seem to do anything. Does .bashrc run at startup? I would have guessed it only runs when you open a terminal window. I’ll google it after lunch. :slight_smile:

If you routinely open up a bash command window on launching, .bashrc executes at that point. If that’s not enough, you can use the Autostart option in System Settings to execute your own script file (.sh).

That sounds perfect, I’ll look into it. Thanks!

1 Like

After some trial and error, it seems the easiest way is to just directly run “mount -a” directly from the autostart. The script was just the one line doing that anyway.

So, the symptom (no mounted drive) is solved. The cause (why does mount -a have to be run explicitly?) will have to remain a mystery. :slight_smile:

I wish I could remember what I had found…but it’s been too long (and I decided I didn’t need NFS after I got it) and clients been reloaded since then.