Auto mount to smb share SOLVED

Questions about Wi-Fi and other network devices, file sharing, firewalls, connection sharing etc
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
mayfield
Level 1
Level 1
Posts: 5
Joined: Tue Jun 08, 2021 6:30 am

Auto mount to smb share SOLVED

Post by mayfield »

Hello Mint friends

I have an Ubuntu server with a shared folder data and have added an entry into fstab to auto mount, I can copy and paste files from my mint laptop but cannot delete. What am I doing wrong?

fstab entry - //SERVER/data /mnt/samba/data cifs username=mick,password=mick,file_mode=0777,dir_mode=0777 0 0
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
AndyMH
Level 21
Level 21
Posts: 13753
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Auto mount to smb share

Post by AndyMH »

My entry for my nas:

Code: Select all

#diskstation mounting under cifs
//diskstation.local/home/	/media/synology	cifs	credentials=/etc/samba/credentials,uid=1000,gid=1000,nofail	0	0
try adding uid=1000,gid=1000 to your mount options. If your usename on your local PC is mick you can replace uid=1000,gid=1000 with uid=mick,gid=mick. Mounting using cifs you have to fake the linux permissions, this is what uid=1000,gid=1000 is doing.

credentials is just a way of slightly obscuring your uname/pwd for the nas. A two line text file of the form (save it where you want):

Code: Select all

username=xxx
password=yyy
nofail means mint won't spend 90seconds trying to connect on boot before giving up if the nas is not present.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto mount to smb share

Post by altair4 »

I don't mean to interrupt since AndyMH knows what he's doing with samba but I have a question:

You can't delete a file you just added to the mounted share from the client? Or you can't delete any files that are already present on the mounted share from the client?

The permissions you see on the client do not reflect the permissions you see on the server itself. To the server you are user mick so you can only do what mick can do on the server.

You might want to post how the server is set up by posting the output of this command on the server:

Code: Select all

testparm -s
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
AndyMH
Level 21
Level 21
Posts: 13753
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Auto mount to smb share

Post by AndyMH »

altair4 wrote: Fri Jan 28, 2022 7:58 am I don't mean to interrupt since AndyMH knows what he's doing with samba but I have a question:
Just a little, and not as much as you :D
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
mayfield
Level 1
Level 1
Posts: 5
Joined: Tue Jun 08, 2021 6:30 am

Re: Auto mount to smb share

Post by mayfield »

altair4 wrote: Fri Jan 28, 2022 7:58 am I don't mean to interrupt since AndyMH knows what he's doing with samba but I have a question:

You can't delete a file you just added to the mounted share from the client? Or you can't delete any files that are already present on the mounted share from the client?

The permissions you see on the client do not reflect the permissions you see on the server itself. To the server you are user mick so you can only do what mick can do on the server.

You might want to post how the server is set up by posting the output of this command on the server:

Code: Select all

testparm -s
I just tested this. I can delete a folder I create from the client but cannot delete a folder already present
mick@server:~$ testparm -s
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Weak crypto is allowed
Server role: ROLE_STANDALONE

# Global parameters
[global]
log file = /var/log/samba/log.%m
logging = file
map to guest = Bad User
max log size = 1000
obey pam restrictions = Yes
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
server role = standalone server
server string = %h server (Samba, Ubuntu)
unix password sync = Yes
usershare allow guests = Yes
idmap config * : backend = tdb


[printers]
browseable = No
comment = All Printers
create mask = 0700
path = /var/spool/samba
printable = Yes


[print$]
comment = Printer Drivers
path = /var/lib/samba/printers


[downloads]
comment = my directory on ubuntu server
guest ok = Yes
path = /home/mick/downloads
read only = No


[data]
comment = data directory on ubuntu server
guest ok = Yes
path = /home/mick/data
read only = No
mick@server:~$
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto mount to smb share

Post by altair4 »

That's an interesting problem.

Your shares allow guest access so you don't need to pass a user name and password but you are anyway - which is fine.

That user would come across as the Ubuntu user "mick" as long as you added "mick" to the samba password database on the Ubuntu system: sudo smbpasswd -a mick

If you didn't do that the user would be converted to the Ubuntu user "nobody".

"nobody" would only be able to add a file to that share if permissions on the target folder was 777 but that would mean he would also be able to delete anything on that target folder. He may not be able however to delete any file in an existing subfolder. I'm not sure which scenario applies to this situation.

I remember a bug report related to this issue sometime ago ... I just need to find it.

For now I would suggest you either add mick to samba on the server if you have not already done so:

Code: Select all

sudo smbpasswd -a mick
And / Or change your share defintions to force the client user to become "mick". For example:
[downloads]
comment = my directory on ubuntu server
guest ok = Yes
path = /home/mick/downloads
read only = No
force user = mick
Then restart smbd on the server: sudo service smbd restart
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
mayfield
Level 1
Level 1
Posts: 5
Joined: Tue Jun 08, 2021 6:30 am

Re: Auto mount to smb share

Post by mayfield »

Thank you all for the great help
Locked

Return to “Networking”