Friday, May 4, 2007

Mounting Samba Shares

Lately I went through great troubles just to mount a samba share on my CentOS 5 box. Research revealed that a lot of people were having the same issue (see, for example, http://www.linuxquestions.org/questions/showthread.php?t=453941) of inability to mount samba shares despite everywhere the suggested syntax was the same (as in various help manuals). After research on possible solutions, I've found some rather interesting points regarding mounting samba shares that follow:

The following syntax works perfect for mounting samba shares:

mount -t cifs -o user=username //servername/sharename mountpoint
Here are some very important points about how the mount utility works (or not works) when it comes to mounting samba shares:

1. For the -t parameter smbfs *won't* work. That value for the -t parameter has retired and no longer supported.

2. If you specify a user whose password is *blank*, you'll need to press enter when prompted for password. In this case, mount will fail with a permission denied error. So always specify a user who does have a password.

3. sharename *must* be the root of a share not a subdirectory of it. For example, if you have a server named myserver with the following shared directory structure,

RootShare
..... |
.......... SubDirOne
.......... SubDirTwo
............... |
..................... SubSubDirOne

then you can mount nothing but the directory RootShare. Trying to mount any of the sub-directories will result in the following error:

retrying with upper case share name
mount error 6 = No such device or address
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
4. mountpoint should be an already existing directory.

I hope this makes up for a crystal clear solution to a *very* common problem. Try googling for it and you'll see it seems like everyone on this planet has gone through this problem

3 comments:

ejan said...

I've posted this same solution to LinuxQuestions.org forums. You can view the post here.

Breck said...

Thank you very much for posting this. It solved my problem perfectly.

ejan said...

I'm glad it solved your problem.