Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
cifs fstab entry mounting as root on boot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
doralsoral
Tux's lil' helper
Tux's lil' helper


Joined: 12 May 2004
Posts: 127

PostPosted: Wed Jan 01, 2020 2:45 pm    Post subject: cifs fstab entry mounting as root on boot Reply with quote

I have a cifs share listed in fstab like this

//172.16.0.6/Music /home/username/Music cifs users,rw,_netdev,credentials=/home/username/.creds 0 0

on boot it is mounted as root and i don't have permissions to do it. ls -l shows root:root. if i unmount it and just do "mount /home/username/Music" it gets mounted as current user and i can do whatever i want. I had to add the _netdev option to get it to wait until the network was up before mounting. Not sure if this is the cause or not.
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 539

PostPosted: Wed Jan 01, 2020 2:57 pm    Post subject: Reply with quote

I don't use cifs but may want to go through mount.cifs(8) man page options. uid and gid are of interest. You could also opt to simply not let it be automounted (noauto), and do it as user with a startup script as needed.
Edit: If you never need remount this as a user, I'd remove "users" and add uid=<user>,gid=<group> (I believe both numeric id and names should work). Then it should be mounted as <user>:<group> rather than root:root (if doesn't work, may need forceuid=/forcegid=, do read the man page for any further information anyway).
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1787
Location: United Kingdom

PostPosted: Wed Jan 01, 2020 6:18 pm    Post subject: Reply with quote

What Ionen wrote is the way to go, as I have to include 'uid=' and 'gid=' when I mount a SMB share from the command line. For example:

Code:
$ sudo mount.cifs //192.168.1.123/folder/ -o user=remoteuser,pass=remotepassword,uid=$(id -u),gid=$(id -g) /home/localuser/localfolder

In /etc/fstab you have to specify the desired user and group explicitly, of course. The mount command interprets non-numeric parameters of the uid and gid options as user and group names, respectively. That applies whether the options are used from the command line or in /etc/fstab.
_________________
Clevo W230SS: amd64 nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC eudev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum