fstab entries unable to mount/umonunt on demand as user [SOLVED, kind of]

Connection sharing, Firewall, Samba..etc
Forum rules
Before you post please read how to get help
Post Reply
Eliminateur
Level 1
Level 1
Posts: 10
Joined: Tue Sep 03, 2019 10:01 am

fstab entries unable to mount/umonunt on demand as user [SOLVED, kind of]

Post by Eliminateur » Wed Sep 11, 2019 10:30 am

Hello,
i'm running mint 19.2 cinn and created several entries on fstab to mount on demand:
//server/soft /media/soft cifs username=user,domain=domain.local,noauto,uid=1000,gid=1000,vers=1.0 0 0
//server/almacen /media/almacen cifs username=user,domain=domain.local,noauto,uid=1000,gid=1000,vers=1.0 0 0
//server/documentos /media/documentos cifs username=user,domain=domain.local,noauto,uid=1000,gid=1000,vers=1.0 0 0
the idea is that those are mounted on demand when i access them from nemo, the folder appear in the list under the network section BUT when i try to open them it says "unable to mount, operation permitted for root only".

as reference i've been using this guide: viewtopic.php?t=222087 but it was not completely made for systemd.
Also, if i mount it manually i can't unmount it from the user on the tasktray, i need to run sudo umount

¿any ideas?
Last edited by Eliminateur on Mon Sep 16, 2019 7:55 am, edited 1 time in total.

all41
Level 15
Level 15
Posts: 5583
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: fstab entries unable to mount/umonunt on demand as user

Post by all41 » Wed Sep 11, 2019 11:17 am

Take ownership of the mountpoints in /media.
such as:
sudo chown -R $USER:$USER /media/documentos
(include the full mountpoint name by right-clicking the file in /media
and choosing properties)

Do not change $USER:$USER to your username--leave just as is. This means change ownership to the currently logged in user and group.

altair4
Level 19
Level 19
Posts: 9690
Joined: Tue Feb 03, 2009 10:27 am

Re: fstab entries unable to mount/umonunt on demand as user

Post by altair4 » Wed Sep 11, 2019 12:04 pm

//server/soft /media/soft cifs username=user,domain=domain.local,noauto,uid=1000,gid=1000,vers=1.0 0 0
If you follow the HowTo in your link you will notice that you are missing an option: user

The way you have it set now only root can mount the share. user allows a mount ( and an unmount ) by an ordinary user as long as it hasn't been mounted before which is why the noauto option is there.

So change your line to:
//server/soft /media/soft cifs username=user,domain=domain.local,noauto,user,uid=1000,gid=1000,vers=1.0 0 0
EDIT: Just noticed that you are missing something else. If you specify a username to gain access to the share you also need to provide the password:
//server/soft /media/soft cifs username=user,password=userpw,domain=domain.local,noauto,user,uid=1000,gid=1000,vers=1.0 0 0
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

Eliminateur
Level 1
Level 1
Posts: 10
Joined: Tue Sep 03, 2019 10:01 am

Re: fstab entries unable to mount/umonunt on demand as user

Post by Eliminateur » Wed Sep 11, 2019 1:08 pm

i did both things but now i have a password entry error, it never asks for the password and fails:
Screenshot from 2019-09-11 14-06-46.png
ofc i didn't hardcode the pas in fstab nor i desire so, the idea is that it would ask for password on opening

altair4
Level 19
Level 19
Posts: 9690
Joined: Tue Feb 03, 2009 10:27 am

Re: fstab entries unable to mount/umonunt on demand as user

Post by altair4 » Wed Sep 11, 2019 1:19 pm

Please see my edit above. THe only way I can reproduce that exact type of error is to not add the password=userpw option to fstab:
altair4 wrote:
Wed Sep 11, 2019 12:04 pm
EDIT: Just noticed that you are missing something else. If you specify a username to gain access to the share you also need to provide the password:
//server/soft /media/soft cifs username=user,password=userpw,domain=domain.local,noauto,user,uid=1000,gid=1000,vers=1.0 0 0
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

Eliminateur
Level 1
Level 1
Posts: 10
Joined: Tue Sep 03, 2019 10:01 am

Re: fstab entries unable to mount/umonunt on demand as user

Post by Eliminateur » Wed Sep 11, 2019 1:32 pm

altair4 wrote:
Wed Sep 11, 2019 1:19 pm
Please see my edit above. THe only way I can reproduce that exact type of error is to not add the password=userpw option to fstab:
altair4 wrote:
Wed Sep 11, 2019 12:04 pm
EDIT: Just noticed that you are missing something else. If you specify a username to gain access to the share you also need to provide the password:
//server/soft /media/soft cifs username=user,password=userpw,domain=domain.local,noauto,user,uid=1000,gid=1000,vers=1.0 0 0
i'm not really missing that because i don't want to hardcode the password in fstab, it's one of the points, i want the system to ask for the credential when the folder is accessed.
If i were to hardcode then i wouldn't bother with ondemand mount and would just leave it as automount, the whole point of the ondemand mount is for it to ask credentials on access.

And if i don't put a user then it assumes the username is the same as the logged on user.

altair4
Level 19
Level 19
Posts: 9690
Joined: Tue Feb 03, 2009 10:27 am

Re: fstab entries unable to mount/umonunt on demand as user

Post by altair4 » Wed Sep 11, 2019 1:39 pm

No can do.

What you could do is set up a credentials file that contains the username and password, include that into the fstab file, and make it so no one can access that credentials file but root.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
AndyMH
Level 8
Level 8
Posts: 2401
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: fstab entries unable to mount/umonunt on demand as user

Post by AndyMH » Wed Sep 11, 2019 3:05 pm

What you could do is set up a credentials file that contains the username and password, include that into the fstab file, and make it so no one can access that credentials file but root.
It's what I do, sample fstab syntax:

Code: Select all

# mount point for synology NAS 
//diskstation.local/home/ /media/synology cifs credentials=/etc/samba/credentials,uid=1000,gid=1000 0 0

credentials file is a simple text file of the form:

Code: Select all

username=xxx
password=xxx
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate

Post Reply

Return to “Other networking topics”