Anyone able to help me automount SMB shares?

I’ve been using EndeavourOS for almost a year and I love it, even with little to no Linux experience it has been quite simple to solve most issues I’ve run into. Having said that, I’d like to mount a few network drives on boot, which I seem to recall being possible. I’m aware the Archiwiki exists, but I was hoping someone here could help me solve this instead.

As of now I’m accessing them by manually mounting them in Nemo (smb://192.168.1.59/). How can I automount them on boot?

Why? What’s wrong with what’s written already in the Arch wiki? Which parts need clarification etc.?

For reference, this what the Arch wiki has about automatically mounting an SMB share using /etc/fstab:

https://wiki.archlinux.org/index.php/Samba#Automatic_mounting

1 Like

My preferred way is to add a systemd automount to /etc/fstab

Something like this:

//servername/sharename /path/to/mount cifs x-systemd.automount,x-systemd.idle-timeout=1min,rw,uid=yourusername,gid=yourgroupname,credentials=/etc/samba/private/sharename.cred,iocharset=utf8,vers=2.0 0 0

For example(I am using mlt as your username, if it is something else, use that instead):

First create somewhere to mount it:

sudo mkdir /mnt/server

Create a file called /etc/samba/private/server.cred with this as the contents

username=myuser
password=mypass

Replace myuser and mypass with your username and password for the smb share.

Then add this to the bottom of your /etc/fstab

//192.168.1.59 /mnt/server cifs x-systemd.automount,x-systemd.idle-timeout=1min,rw,uid=mlt,gid=mlt,credentials=/etc/samba/private/server.cred,iocharset=utf8,vers=2.0 0 0

Before rebooting, test it out by typing:

sudo mount /mnt/server

If it worked, you should see the contents of your share at /mnt/server.

The nice thing about a systemd automount is that if the server isn’t available it should’t cause anything to break or hang.

Also, you can mount it anyplace you want. /mnt/server is just an example.

5 Likes

Wonderful, well-written wordplay with W.

6 Likes

Astonishingly, always alliterating allows alternative approaches.

7 Likes

Is the server you are accessing a windows server or a linux server?

If this is a Linux client mounting a partition from a Linux Server, then one would be best served by using NFS or other methods.

Just my opinion.

Pudge

Thank you so much for taking the time to help me, this was quite simple with your directions. I now have one of the drives mounted. Do I simply add another line in fstab for the other(s)? Do I need to change anything other than the server directory?

1 Like

Yes.

If the username and password are different you also need a second .cred file.

It is a Linux server (Mint).

I use nfs myself but I have found that over a wireless network nfs needs some tweaking to get optimal performance while smb just works.

1 Like

I said best served, but @dalto you are absolutely correct there are exceptions to every rule.
Thanks for keeping me honest.

Pudge

I now have all of them mounted, thank you!

1 Like

This is the method I used:

fstab:

//myserver/drive /run/media/marcelo/drive cifs nofail,user,auto,uid=1000,gid=1000,vers=2.0,credentials=/home/marcelo/.smbcredentials

I wasn’t aware that there was another method in the wiki…
I’ll look the wiki more often… :slight_smile:

What do I need to add to the fstab entry to allow users of the same group read, write and execute permissions? I did some research and from what I found adding umask=002 should accomplish this, however, while it seemed to add write access, it also seemed to have remove read access.

My fstab entry currently looks like this:

//192.168.1.59/disk1/ /mnt/MB/D1 cifs x-systemd.automount,x-systemd.idle-timeout=1min,rw,uid=okita,gid=okita,umask=002,credentials=/etc/samba/private/server.cred,iocharset=utf8,vers=2.0 0 0

https://wiki.archlinux.org/index.php/Umask will be worth reading here.

If umask removes permissions, how do I add permissions?

It looks fine. Can we see what ls -l /mnt/MB/D1 looks like?

ls -l /mnt/MB/D1 resutls in ‘drwxr-xr-x 2 okita okita’.

To clarify, I’m setting up an emby server which should be running under the user ‘emby’. I have added this user to the group ‘okita’. As of now it can read files, but not write. I would like emby to be able to write as well, so I can delete files via the web interface.

edit: it can read without the umask, if I add umask=002 it seems to have no permissions.

Have unmounted and remounted it since you made that change?

Does the directory itself and all the files it have the same permission or is it just the directory?

Yes, rebooting after adding umask=002 seems to have removed the read permission. Subfolders have the same drwxr-xr-x 2 okita okita permissions.

edit: umask=002 seems to remove read, but add write permission.