# smbmount

## d4h0od

do i have to emerge entire samba package to be able to use smbmount?

isnt there anyway to install only smbmount and other utils need to mount a samba share... i dont want to run samba server myself

when i used debian before then i only had to do apt-get install smbfs

but cant find any smbfs package in gentoo

----------

## roXet

I believe the 'entire samba package' is what allows you to mount windows file shares. If you don't have it running you won't be able to see the shares, so smbmount will pretty much be useless.

----------

## delta407

Just enable "SMB file system support (to mount Windows shares etc.)" under "Network filesystems" (under "File system support") in your kernel configuration and "mount -t smbfs //machine/share /mnt/point".

----------

## roXet

so you don't have to install samba to do that? Only if you want to share file to a windows client. Ok, I was confused. =)

----------

## reverius42

 *roXet wrote:*   

> so you don't have to install samba to do that? Only if you want to share file to a windows client. Ok, I was confused. =)

 

In Debian, when you apt-get install smbfs, it's not really getting any part of samba... it's getting the necessary filesystem stuff to mount an SMB filesystem (and possibly the smbmount binary, i'm not sure). Anyways, you don't need that on Gentoo because of a few things:

1) You're compiling your own kernel, so you just have to make sure that smbfs is enabled in some form

2) The smbmount binary is already there, apparently.

All you should have to do is "mount -t smbfs //host/share /mountpoint"  :Smile: 

----------

## Black666

Somehow it's not working here.

I do a 

```
mount -t smbfs //anecon007/mp3 /mounttest/
```

but all I get is

```
mount: wrong fs type, bad option, bad superblock on //anecon007/mp3, or too many mounted file systems
```

I checked the W2K box and sharing and NTFS permissions are all to "Read for Everyone" so this should not be a permissions issue. I also typed this command as root...still no effect.

Any hints?

----------

## reverius42

 *Black666 wrote:*   

> Somehow it's not working here.
> 
> I do a 
> 
> ```
> ...

 

It's possible that I have the syntax wrong. Try "mount -t smbfs \\\\anecon007\\mp3 /mounttest". The backslashes are the Windows-style of doing network paths... you need twice as many because you have to escape them, or else they're interpreted by the shell.

If it says the same thing, then I don't know what to do...

----------

## BradN

I've seen windows machines (2000 if I remember) get picky about what name you access them with (but that meant that accessing by IP usually didn't work, where by host name it did).

----------

## mrchuckles

 *Quote:*   

> I checked the W2K box and sharing and NTFS permissions are all to "Read for Everyone" so this should not be a permissions issue. I also typed this command as root...still no effect. 

 

Well, it sounds like permissions issue.  The 'everyone' group includes the 'Guest' account, but it's disabled by default.  To connect anonymously, you'll need to enable the Guest account, but I wouldn't if I were you.  Try connecting with a username and password to see if that helps.

```
mount -t smbfs -o username=<username>,password=<password> //anecon007/mp3 /mounttest
```

Also, make sure you have SMB support compiled in your kernel, and you have the module loaded (if that's how you set it up).

Let us know what happens.

----------

## Terrible_Josh

try

mount -t smbfs -o username=whatever //host/share /mountpoint

It will prompt you for the password.

----------

## d4h0od

i have tried everything above but i still get this error msg when i try to mount my share...

can it have something to do with the fact that i have enabled encrypted passwords on the samba server... is there anything i have to do different then... 

bash-2.05a# mount -t smbfs \\\\amnesiated\\samba /tmp/

mount: wrong fs type, bad option, bad superblock on \\amnesiated\samba,

       or too many mounted file systems

bash-2.05a#

----------

## Tuna

first.. check if 'amnesiated' (the windows computer) is listed in /etc/hosts

then.. the syntax is indeed

```
mount -t smbfs -o username=<username> //amnesiated/samba /tmp/
```

so no \\/// kombinations or similar

and.. indeed enabling the kernel options does not seem to be sufficent to mount a windows share.. as stated in the mount manual 'mount -t smbfs' only invokes smbmount.

check if that file is there?

i had the same problem and emerging samba cured all my problems.. though  i didnt like to install the whole samba package just for share access :/

----------

## d4h0od

added the host amnesiated to /etc/hosts but still get error msg  :Sad: 

```

bash-2.05a# mount -t smbfs -o username=d4h0od //amnesiated/samba /tmp/

mount: wrong fs type, bad option, bad superblock on //amnesiated/samba,

       or too many mounted file systems

bash-2.05a#

```

i cant find smbmount anywhere on my system so im doing "emerge samba" now and see if that works... but i dont like it either to install the entire package just to mount a samba share

----------

## d4h0od

now that i have emerged samba it seems to work.. almost...

when i do

```

bash-2.05a# mount -t smbfs -o username=d4h0od,password=password //amnesiated/samba /tmp/

15822: session setup failed: ERRSRV - ERRbadpw (Bad password - name/password pair in a Tree Connect or Session Setup are invalid.)

SMB connection failed

bash-2.05a#

```

but when i dont supply password in the command line like this and it ask for my password and i type it in then it works... 

```

bash-2.05a# mount -t smbfs -o username=d4h0od //amnesiated/samba /tmp/

Password:

bash-2.05a#

```

im not sure but i guess that this can have something to do with the fact that i have encrypted passwords on the samba server and when i supply the password in the command it is sent in plain-text and when it asks for the password it gets encrypted as i type it in and send it to the samba server and then the samba server gets the correct password and grants me access... but as i said im not sure... nor do i know how to fix this so that i can automount the samba share everytime i start up gentoo...

is there anyone who has a solution ?

----------

## ozric100

put it in your /ect/fstab file

like this

//<server-name>/<share-name>[TAB]/<mount-point>[TAB]<mount-options>[TAB]0 0 

You may have to put in username=foo passoword=bar in the options section, it wont show in process table, but will be plain text in the fstab so beware.  Well you get the idea.

----------

## eyevee99

What mount options do you recommend?  Do theyneed a file system setting?

----------

## ozric100

Yes,  I must have been sleepy when I posted that.  do a man on fastab and smb.conf most of the options are listed there.

----------

## RageX

just browsed the thread, so forgive me if i'm repeating someone.

i think you should be able to use mount -t smbfs so long as you have smb file system support configured in the kernel.  i have both that and samba, so i'm not sure.

regardless, if you're using name of the comp to mount to, i'd add it to the hosts file with the matching ip then use:

mount -t smbfs -o username=user,password=pwd //comp/share /linux/box

make sure the mount point on the gentoo box exists.

hope that helps  :Smile: 

----------

## eyevee99

```

//pixelacuity.home.box/data     /mnt/pixelacuity/data   smbfs   defaults,username=myuser,password=mypassword           0 0

//pixelacuity.home.box/sassy    /mnt/sassy              smbfs   defaults,username=myuser,password=mypassword           0 0

//pixelacuity.home.box/smooch   /mnt/smooch             smbfs   defaults,username=myuser,password=mypassword           0 0

```

The first option does not mount at startup, the other two do.

however, once booted typing:

mount -t smbfs -o username=myuser //pixelacuity.home.box/data /mnt/pixelacuity/data

Then enter mypassword.

and the share mounts correctly...

Any ideas why this doesn't mount correctly from /etc/fstab?

Also, I can't write to these shares...  what options do I need to write to them as my general user?

----------

## Shizatoga

If you aren't using a password for your smb share you must put "" for your password, here a snip from my fstab:

```

//cthulhu/distfiles /usr/portage/distfiles smbfs defaults,username=guest,password="" 0 0

```

As for setting user ownership for the shares use the uid option. Ex:

```

smbmount //cthulhu/distfiles /foo -o uid=myuser

```

fstab ex.

```

//cthulhu/distfiles /usr/portage/distfiles smbfs defaults,suid=myuser,username=guest,password="" 0 0

```

For more info do "man smbmount". Enjoy.

----------

## eyevee99

I have the password in fstab so that's fine.  The suid=blah bit is what I was missing.

However it still doesn't explain why the first share isn't being registered at boot time (thought I can manually mount it after that).

----------

## eyevee99

I added suid=myusername to the fstab entries...

I still do not have permissions on my normal user.

trying to copy to the directory give the following error "You do not have permission to write to this folder"

ideas?

----------

## Shizatoga

Try putting your password in quotes (i.e. "mypassword" )

Can you post your new fstab entrie? Also can you give a "ls -l" of your smb mounted dir.

----------

## eyevee99

here are the fstab entries:

```

//pixelacuity.home.box/data     /mnt/pixelacuity/data   smbfs   defaults,suid=myuser,username=myuser,password=mypassword             0 0

//pixelacuity.home.box/sassy    /mnt/sassy              smbfs   defaults,suid=myuser,username=myuser,password=mypassword             0 0

//pixelacuity.home.box/smooch   /mnt/smooch             smbfs   defaults,suid=myuser,username=myuser,password=mypassword             0 0

```

First entry never mounts at startup, but can be mounted at the prompt.

Normal user does not have permissions on these shares, only root.

password without quotes must be the correct way to enter it, else the second two shares wouldn't mount either.

NOTE: suid uses my linux username, username/password use my logins on the winxp box.

----------

## kerframil

 *eyevee99 wrote:*   

> here are the fstab entries:
> 
> ```
> 
> //pixelacuity.home.box/data     /mnt/pixelacuity/data   smbfs   defaults,suid=myuser,username=myuser,password=mypassword             0 0
> ...

 

Annoying, isn't it? A couple of points:

Firstly, the suid option seems to have no effect on smbfs. The options you should be using are uid and gid. I also recommend storing your username and password in a file (called smbpasswd for example), rather than fstab (if you really wanted to be secure you I suppose you could enable the CryptoAPI in your kernel and mount a small loopback block device to store the passwords on). Here's an example of such a file:

```
username=myusername

password=mypassword
```

You can then use the credentials option to point to that file. So your fstab line should look something like this:

```
//pixelacuity.home.box/data     /mnt/pixelacuity/data   smbfs   uid=myuser,gid=myuser,users,credentials=/path/to/smbpasswd             0 0
```

The users option will allow you to mount and unmount it as an ordinary user, and the uid/gid options will ensure you have the correct permissions (you can also use fmask and dmask to set the permission bits for files and directories contained inside the share from the point of view of how it appears in your Linux filesystem). The uid/guid is referrering to your SMB username/password, not your Linux username/password (see man smbmount).

Now here's the real problem: using /etc/fstab or mount -smbfs do give the same results. If you set up fstab as I said, you will have a successful mount as an ordinary user, and you will be able to unmount it.

BUT: you will *not* be able to create new folders/directories at the root of your mounted smb filesystem! However, you will be able to create and modify new directories and files under any existing directories inside the filesystem, if any are present   :Shocked: 

Why is this? Well, in my case I made a folder called /home/kerin/smb/home. I set up a fstab line with the options I spoke of, which will mount to that directory. Now, if I look at the permissions of the mount point before mounting as kerin, they look like this:

```
drwxr-xr-x   1 kerin    kerin
```

Good. Now I do a mount /home/kerin/smb/home. Great, it works. Now everything's fine inside the filesystem mount point, but if I check the permissions of the mount point again they look like this:

```
dr-xr-xr-x   1 kerin    kerin
```

 :Crying or Very sad:  See how the w bit got dropped. That mask on the directory now prevents me from modifying or creating new files and directories in /home/kerin/smb/home, but because I specified the uid/gid options, I have no problem in, say, /home/kerin/smb/home/someotherfolder.

This is really bad. If you mount as root, it preserves the mask the way it is (and should be), but if you mount as an ordinary user, that one difference makes it impossible to manipulate the effective "root" directory of your mounted filesystem!

When you unmount, the mask goes back to the way it was. I have tried and failed to find a way of preventing this behaviour. If there is no workaround, it seems to me that this makes truly seamless integration into a Windows network pretty much impossible. One should not have to be root to do this, but it's the only way around it that I've found so far.

Does anyone know any better?

----------

## Belthezar

That was the 100% on the money solution I was looking for and for me it is working perfectly!!

I really like the tip about a seperate password file too because I was not comfortable with my password in the fstab file directly.

I think I found a solution to the permissions problem also.  I logged in as my normal user and created a folder in my home folder.  This is what I'm using as the mount point.  When I then do a mount //server/share as the same user I get all the permissions I was wanting, and can create folders in the root of the sharepoint as well!  :Smile: 

So maybe that is the key, to have the mount point be under an existing folder that the particular user controls if that makes sense.

----------

## kerframil

 *Quote:*   

> That was the 100% on the money solution I was looking for and for me it is working perfectly!!

 

Most pleased I am too to hear it, I might add   :Smile: 

I haven't achieved quite the level of success you have (I'm sure I tried mounting in my home directory), but your report has encouraged me to re-examine that situation. I'll post again if I make a breakthrough, because there is obviously something at play here ...

----------

## eyevee99

mine all works, except the first windows mount still wont mount at boot.

```

//pixelacuity.home.box/data     /mnt/pixelacuity/data   smbfs   defaults,suid,uid=myuser,username=username,password=password         0 0

//pixelacuity.home.box/sassy    /mnt/sassy              smbfs   defaults,suid,uid=myuser,username=username,password=password         0 0

//pixelacuity.home.box/smooch   /mnt/smooch             smbfs   defaults,suid,uid=myuser,username=username,password=password         0 0

```

I haven't seperated out my passwords etc yet, but the above works.

mount -a will mount all three, but at boot time only the second two will mount.

It's really quite annoying.

:)

----------

## zojas

i do it slightly differently. I leave out the "users" option and add "noauto". then I must explicitly mount it as root like this:

```

mount -opassword=passwd /linuxmountpoint

```

then the w permission is still there for the user.

I suspect the "users" option is the culprit. if you take that out it may work, but you will still have to mount/umount only as root.

 *Quote:*   

> BUT: you will *not* be able to create new folders/directories at the root of your mounted smb filesystem! However, you will be able to create and modify new directories and files under any existing directories inside the filesystem, if any are present  
> 
> Why is this? Well, in my case I made a folder called /home/kerin/smb/home. I set up a fstab line with the options I spoke of, which will mount to that directory. Now, if I look at the permissions of the mount point before mounting as kerin, they look like this:
> 
> ```
> ...

 

----------

## lain iwakura

kerframil,

to answer your little problem, here's what works for me -- to keep write permissions on mounting of a smbfs  (mounting a fat32 partition using win2000:)

```
//queeny/d$             /path/you/want/da/fs/to/reside/on                    smbfs 

defaults,users,uid=myname,gid=users,dev,exec,rw,username=blah,password=blah

```

I also have samba emerged and configured (for the most part.)  I'd post my globals but I don't think those are at fault or would help.

This should do it!    :Razz: 

----------

## lain iwakura

 *eyevee99 wrote:*   

> mine all works, except the first windows mount still wont mount at boot.
> 
> ```
> 
> //pixelacuity.home.box/data     /mnt/pixelacuity/data   smbfs   defaults,suid,uid=myuser,username=username,password=password         0 0
> ...

 

sounds like your fstab file is more than one line for that entry.  make sure that entry is on one line -- including them zeros -- save, umount, then mount the dir and that will tell you if it will work on BOOT or not.

(p.s. -- don't reboot, for god's sake!!! ) heheh  :Razz: 

----------

## lain iwakura

 *Belthezar wrote:*   

> That was the 100% on the money solution I was looking for and for me it is working perfectly!!
> 
> I really like the tip about a seperate password file too because I was not comfortable with my password in the fstab file directly.
> 
> I think I found a solution to the permissions problem also.  I logged in as my normal user and created a folder in my home folder.  This is what I'm using as the mount point.  When I then do a mount //server/share as the same user I get all the permissions I was wanting, and can create folders in the root of the sharepoint as well! 
> ...

 

yeah, you don't wanna have the mofo to have root,root permissions -- obviously!    :Razz: 

yeah, just mount the smbfs to a dir your non-root user(s) can access and read my above post (2 up) for more help!  yay!

----------

## Valen

 *kerframil wrote:*   

> 
> 
> <SNIP>
> 
> BUT: you will *not* be able to create new folders/directories at the root of your mounted smb filesystem! However, you will be able to create and modify new directories and files under any existing directories inside the filesystem, if any are present  
> ...

 

Two options control the permissions of smbfs mounts: fmask and dmask.  fmask sets the permissions for every file on the share and dmask sets the permissions for every directory on the share.

I have used these options with some success:

```
username=valen,password=*,dmask=777,fmask=666
```

and for read only mounts I would guess that this would work:

```
username=valen,password=*,dmask=755,fmask=644
```

Hope this helps.

----------

## kerframil

Thanks for the tips, Valen, lain iwakura and zojas! I'll definitely check that out.

----------

