2

I'm trying to automatically mount a samba share residing on nas running openmediavault 5.6.12-1 and samba version 4.9.5-Debian on my desktop running Ubuntu 20.04.3.

After following the instructions in the openmediavault forum and the ubuntu community I added the following command to my fstab file:

//192.168.100.12/HomSpace /media/nasMounted cifs credentials=/root/.memoriaCredentials,uid=1000,gid=1000,noperm,rw,vers=3.0 0 0

When I execute sudo mount -a the share folder is mounted correctly without errors. Unfortunately, after rebooting the PC the folder is not mounted automatically. I haven't found any instructions on the internet suggesting a different and equally practicable way to mount a cifs share folder and without any error in the log I have no idea what I'm doing wrong.

What's wrong with the command that I added to the fstab? How can I automount the cifs share at boot? Thank you in advance.

3
  • 3
    the only difference between your fstab entry and mine //192.168.1.117/[NAS share_name] /media/NAS/GnV_Common cifs username=[name],password=[password],rw,uid=1000,gid=500 where it works perfectly well. I haven't included vers=3.0 or noperm params. For exploration purposes, perhaps try editing those out to see what changes. I would do that by copy/paste the line, make your changes and and comment out the line(s) you need to suppress.
    – 24601
    Nov 8, 2021 at 21:36
  • 1
    I mount shares through fstab as well; it works reliably. I have the vers=3.0 parameter but instead of noperm I have nofail. Based on this and the comment by @24601, I suspect the problem is the noperm parameter. Edit: I also don't have the rw parameter. Nov 8, 2021 at 21:52
  • I removed all flags from the entry in the fstab: //192.168.100.12/HomSpace /media/nasMounted cifs credentials=/root/.memoriaCredentials 0 0 but without any improvement. When I click on the share though nautilus before executing sudo mount -a I get this error: Unable to access "nasMounted" mount: /media/nasMounted: operation permitted for root only. I suppose it has to do with the ownership of the hosting folder. Probably normal since I'm not root. Nov 9, 2021 at 10:05

1 Answer 1

1

Since the share will mount when you issue a sudo mount -a I suspect there is nothing wrong with your fstab declaration. It does suggest a timing issue. Linux is reading fstab before the network stack is up and operational so when it goes to mount the network share it fails.

2 possibilities are to turn this into a "mount on demand":

[1] Keep your current mount point but add two more options: noauto,user

//192.168.100.12/HomSpace /media/nasMounted cifs credentials=/root/.memoriaCredentials,uid=1000,gid=1000,noperm,rw,vers=3.0,noauto,user 0 0

When you boot your system the share will not mount but it will show up on the side panel of your file manager as a launcher. Click on it and it will go to fstab to see how to mount it then do so.

EDIT: As pointed out below I should have made sure the credentials file was readable by the ordinary user for this method to work. Placing it under one's home directory would be a better choice.

[2] Change your mount point and use a systemd automounter.

Mount point cannot be under your home directory or /media so I would suggest something like /mnt/nasMounted. Then add two options noauto,x-systemd.automount

//192.168.100.12/HomSpace /mnt/nasMounted cifs credentials=/root/.memoriaCredentials,uid=1000,gid=1000,noperm,rw,vers=3.0,noauto,x-systemd.automount 0 0

This works by accessing the /mnt/nasMounted mount point. Either by you directly through the file manager, or by any application, or by any other process. Pretty much anything accessing that mount point will trigger a mount all without your intervention.

Either way after you edit fstab run these two commands to make systemd happy:

sudo systemctl daemon-reload

sudo systemctl restart remote-fs.target
2
  • I was also suspecting that the problem had to do with a timing issue, like reported in the Troubleshooting section at Ubuntu wiki. But your explanation and proposed solutions are far better. I already tried the solution [1], which works beautifully with one exception: when I clicked on the share from the file manager,I get this error error 13(Permission denied) opening credential file /root/.memoriaCredentials. Since both the folder and the file are restricted to root, I created a new credential file in my home folder. Better solution? Nov 9, 2021 at 21:42
  • I should have asked about the /root/.memoriaCredentials file to make sure it was readable to you. I got sloppy.
    – Morbius1
    Nov 9, 2021 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.