# Mounting samba-shares (3 questions)

## airflow

Hello,

I have a Debian-server serving samba-shares. My Gentoo-box (Desktop-installation) should make them easily mountable, but there are a few problems. My fstab contains the entry

```
\\linuxserver\public    /mnt/public       smbfs   noauto,user    0 0
```

First of all, why does the mountpoint on the Gentoo-box have to belong to the user who mounts the drive? Shouldn't it be sufficiant that the mountpoint belongs to the group "users" (chmod 770)? Fact is, I can only mount if the mountpoint, in my case /mnt/public belongs to the user, otherwise there is a "permission denied"-problem. This is of course not optimal, as there are also other users, who then can't use the mountpoint.

Secondly, the password has to be issued again by hand, although it is the same as the UNIX-password...

And thirdly, and this is really weird (couldn't find anything about this in the forums), even if the mountpoint is set to the right user and the user mounts the drive himself, he can't umount it again... The error-message is 

```
umount: /mnt/public mount disagrees with the fstab
```

I would be very grateful if someone could shed a little light on this...

regards,

airflow

----------

## adaptr

First - it doesn't have to, the permissions of a mount point are immaterial when it's mounted.

What you do have to do is issue the correct smbfs options to the mount command - user to mount it AS, etc.

man mount and look for smbfs options.

Second - again, you have to supply the right options (including SMB credentials) to the mount command, or, as in this case, to the fstab entry.

Mounting an SMB share has nothing to do with Linux users.

And last - of course it disagrees - your fstab entry has backslashes in it!

Although mount will (apparently) accept these when mounting, you better believe that Linux will internally store these as slashes, so when it comes time to umount it again - hey! they're not the same!

man mount, man smbclient, read the options for smbfs TWICE  :Wink: 

----------

## MBCook

The line needs to look something like...

```

//linuxserver/public    /mnt/public       smbfs -o username=User,password=Pass   noauto,user    0 0

```

I think. Check the man page, it's been a while on how you pass the options (and their exact names). But even though in the windows world you use \s, you use /s when refering to the computer and such.

Keep trying, you'll figure it out (I'm assuming I'm not quite perfect above). I've done it. And once you've got that line, the world becomes as easy as 

mount /mnt/public

----------

## airflow

I had now the time to dive deeper into the samba-thing. I just want to give short feedback...

 *adaptr wrote:*   

> First - it doesn't have to, the permissions of a mount point are immaterial when it's mounted.
> 
> What you do have to do is issue the correct smbfs options to the mount command - user to mount it AS, etc.
> 
> man mount and look for smbfs options.

 

I dare to say that this is wrong. The mountpoint has to belong the user who mounts it. It is not sufficiant if the mountpoint belongs to the right group. See also: http://lists.samba.org/archive/samba-technical/2002-April/020967.html (the cited text). Also, the shares can only be unmounted by root, still (Permission denied). Which I don't understand, as everything involved belongs to the user. Anywhere, I don't care, as I want those shares to be mounted all the time.

 *Quote:*   

> Second - again, you have to supply the right options (including SMB credentials) to the mount command, or, as in this case, to the fstab entry.
> 
> Mounting an SMB share has nothing to do with Linux users.

 

Stupid question from my side, sorry. Just for the records, a right fstab-entry now looks like this (this is one line):

```
//linuxserver/public    /mnt/Public       smbfs   noauto,user,username=airflow,password=xcv,uid=airflow,gid=users,,fmask=0660,dmask=0770      0 0
```

 *Quote:*   

> And last - of course it disagrees - your fstab entry has backslashes in it!
> 
> Although mount will (apparently) accept these when mounting, you better believe that Linux will internally store these as slashes, so when it comes time to umount it again - hey! they're not the same!
> 
> man mount, man smbclient, read the options for smbfs TWICE ;-)

 

Sorry again, I had this from a not very helpful forum-posting from this forum... Should have searched further...

Now there is one more questions which I couldn't solve my reading the fstab or smbmount manpages. There are people who say that it is possible that those sambashares are mounted automatically at boot. This doesn't happen, although the entries in fstab are there. I couldn't find it in the forums or in the manpages, does somebody know how to achieve this?

regards,

airflow

----------

## MBCook

I'm not suprised that they aren't mounted at boot. Samba isn't started untill after the filesystems are loaded. So to do that, you could make a little script in /etc/init.d and add it to the default runlevel. Just make it require Samba (so it will wait for Samba to load) and have it mount the (un)share for you.

It's a hack though. The only way I can think of to do it "correctly" would be to have Samba on the initrd and started before the filesystems are mounted.

----------

## fleed

MBCook, I think what you're saying only applies if the server was connecting to itself. If it's a client that's automounting then I suppose the server would already be started.

----------

## adaptr

 *airflow wrote:*   

> I dare to say that this is wrong. The mountpoint has to belong the user who mounts it. It is not sufficiant if the mountpoint belongs to the right group.

 

Not so - how, then, can you grant any user the right to mount filesystems by passing the "user" mount option?

As I said - as long as the user wanting to mount something onto a mountpoint has sufficient rights to mount a FS on it (this is determined in /etc/fstab, not by the mount point's permissions), then he can. 

It's as easy as that.

IOW, if I have

```
/dev/blah    /mnt/blah     rw,user,noauto 0 0
```

in fstab, then anyone whatsoever can both mount and unmount that FS on that mountpoint.

Note that the user cannot mount the device anywhere else, nor can he mount anything else ON that mountpoint - the permission implied through fstab is exactly what it says, no more.

----------

## adaptr

 *MBCook wrote:*   

> I'm not suprised that they aren't mounted at boot. Samba isn't started untill after the filesystems are loaded.

 

So what?

Mounting samba shares has nothing to do with Samba the server - the smbfs is a kernel-supported filesystem that can be compiled into the kernel, so it will always be available.

----------

## adaptr

 *airflow wrote:*   

> 
> 
> ```
> //linuxserver/public    /mnt/Public       smbfs   noauto,user,username=airflow,password=xcv,uid=airflow,gid=users,,fmask=0660,dmask=0770      0 0
> ```
> ...

 

Hahum - yes, the entry is there, but you might like to remove the "noauto" option from fstab - THAT is what causes it not to be auto loaded on startup.

Man mount I guess...

----------

## airflow

 *adaptr wrote:*   

>  *airflow wrote:*   I dare to say that this is wrong. The mountpoint has to belong the user who mounts it. It is not sufficiant if the mountpoint belongs to the right group. 
> 
> Not so - how, then, can you grant any user the right to mount filesystems by passing the "user" mount option?
> 
> As I said - as long as the user wanting to mount something onto a mountpoint has sufficient rights to mount a FS on it (this is determined in /etc/fstab, not by the mount point's permissions), then he can. 
> ...

 

Hello adaptr, thx for your continuing support. I'll just document my (different) experiences regarding this by pasting a little shell-output...

```
airflow@aquarius Netzlaufwerke $ ls -lsh

total 5.5K

 512 drwx------    2 airflow  users          48 Jan 15 22:23 Home

 512 drwxr-x---    2 airflow  users          48 Jan 15 22:23 MP3-Archiv

 512 drwxrwx---    2 root     users          48 Jan 15 22:23 Public

4.0K drwx------    1 airflow  users        4.0K Jan 20 14:15 Storage

airflow@aquarius Netzlaufwerke $ mount Public

cannot mount on /mnt/Netzlaufwerke/Public: Operation not permitted

smbmnt failed: 1

airflow@aquarius Netzlaufwerke $ su

Password:

root@aquarius Netzlaufwerke # chown airflow Public/

root@aquarius Netzlaufwerke # exit

exit

airflow@aquarius Netzlaufwerke $ ls -lsh

total 5.5K

 512 drwx------    2 airflow  users          48 Jan 15 22:23 Home

 512 drwxr-x---    2 airflow  users          48 Jan 15 22:23 MP3-Archiv

 512 drwxrwx---    2 airflow  users          48 Jan 15 22:23 Public

4.0K drwx------    1 airflow  users        4.0K Jan 20 14:15 Storage

airflow@aquarius Netzlaufwerke $ mount Public/

airflow@aquarius Netzlaufwerke $ umount Public/

umount: only root can unmount //linuxserver/public from /mnt/Netzlaufwerke/Public

```

Note that Public is first owned by root,user and then airflow,user. No other changes, but one time it is not possible to mount as user and the other time not. The "user" option in fstab is passed in both cases. Also note that it is possible to mount, but not to unmount.

Regarding the noauto-option - I'm embarrassed again. I thought that noauto can't be the relevant option, as it's also issued in my other entries, who are mounted at boot indeed. But those were my CD-ROMs.  :Rolling Eyes: 

regards,

airflow

----------

## adaptr

 *Quote:*   

> I thought that noauto can't be the relevant option, as it's also issued in my other entries, who are mounted at boot indeed. But those were my CD-ROMs.

 

..and thus were definitely not mounted at boot.

You strange boy  :Wink: 

Tha's some seriously odd mount behaviour, though...

I don't have an immediate answer to that - are the user passwd entries okay/normal?

What is the "users" group? Is everyone in it ?

Oh, I see - Debian, so yes, every user is in users...

Hmm..

----------

## HermanR

It may be me (probably it is), but I find all of this quite confusing.

The only way I got this Samba share stuff working as a regular user, is by 'chown'ing the mount point to my username.group, while unmounting is only possible when I include 'users' as a mount option instead of 'user'.

So, the relevant line in /etc/fstab is:

```
//pc2/shared        /mnt/smbshare    smbfs           noauto,users,password="" 0 0
```

Has anyone found a way to do this, without changing the mountpoint? Or, to put it differently, is it possible to have more than one user use the same Samba share?

----------

## wolfgangVH

 *HermanR wrote:*   

> It may be me (probably it is), but I find all of this quite confusing.
> 
> The only way I got this Samba share stuff working as a regular user, is by 'chown'ing the mount point to my username.group, while unmounting is only possible when I include 'users' as a mount option instead of 'user'.
> 
> So, the relevant line in /etc/fstab is:
> ...

 

I added "umask=0000" to the fstab line and now mine mounts and unmounts as a user, and I can modify the contents of the volume too.

I also mounted it as a user for the first time, so I don't know if that alone gave me the write permissions or the umask line.

I assume it needs umask=0000 because it treats the samba share as a windows drive, as in the permissions are set for the whole drive on mount, because windows doesn't support unix permissions.  I don't know....

Ed:  Hmm I can't actually create files on the drive, only directories. That's wierd.  I'll have to mess with it some more...

----------

## Gauss_Cleric

the following comes from man smbmnt

```
smbmnt is a helper application used by the smbmount program to  do  the

       actual  mounting  of  SMB shares.smbmnt can be installed setuid root if

       you want normal users to be able to mount their SMB shares.

       A setuid smbmnt will only allow mounts on directories owned by the  us-

       er, and that the user has write permission on.

```

But I find that an strange behaviour too. I would like to let any user to mount it. (yes they can mkdir one, but since, in my case, they don't know anything about unix that would be a lot of trouble for them)

If anyone discovers a way to bypass this (not with shell scripts since I want to use the gnome disk mounter) please let me know. Cheers!

----------

