Jump to content
znx

How to mount a Windows share with smbmount

Recommended Posts

After seeing the how to mount a fat32 partition I thought I'd show you how to mount a share.

 

First off you need to make sure the share it setup correctly on your Windows system, I'll only focus on sharing with WinXP.

 

Its not hard on WinXP. First off right-click on the folder you wish to share and select "Sharing and Security".

 

Select "Share this folder".

 

You can now set the Share name, you can also fiddle with the maximum number of users allowed at one time (the default is normally good enough).

 

If you want to heighten the security in this share you can click on "Permissions" and remove the default "Everyone" group (select and click Remove). After this you can click Add. Type the username that will be used to allow access (this has to be a valid user on your WinXP machine). Click Ok, and Ok again. The folder icon should alter and a hand will be holding the folder. This indicates a network share.

 

Ok so you need to know these things:

The hostname of the WinXP PC (eg winpc). Right click on "My Computer" click on "Computer Name". Look at the "Full Computer Name".

 

The sharename of the folder (eg shared) Do you remember what you called it :P.

 

A user/pass for the winxp system. This is only required if you altered the permissions (i.e. if its not sharing to Everyone).

 

Phew 50% of the way there.

 

Ok so onto the Linux system, its relatively simple:

 

Make the directory you want to mount the share to.

mkdir /mnt/share

 

Next either...

 

Mount the share with user/pass:

smbmount //winpc/shared /mnt/share -o username=user,password=pass,rw

 

Or mount the share without a user/pass (this is true if Everyone is still set)

smbmount //winpc/shared /mnt/share -o rw

 

Hopefully thats it. Now you can use the share. You cannot create symbolic links or chmod the system (this is restriction on the WinXP side).

 

If you wish to allow users on the linux side access to the share then you will need to alter the options. Adding in uid= or gid= to allow access to users or groups respectively by mounting the drive with there permissions. Here's an example:

 

smbmount //winpc/shared /mnt/share -o rw,uid=znx

 

This will mount the drive as if user znx had done it. Thus he will have rw access to the shared.

 

Hands up who I managed to confuse ;)

  • Like 1

Share this post


Link to post
Share on other sites

Decided to append some more to this:

 

Make a file /root/.creds (you will be root!)

username = znx
password = mypassword

 

Make sure the file is closed permissions...

chmod 0600 /root/.creds

 

Now edit /etc/fstab and add a line for the share:

//winpc/shared  /mnt/share  smbfs  credentials=/root/.creds,rw,uid=znx  0  0

 

Now the share can be mounted just by doing:

mount /mnt/share

 

Simple enough ^_^

Share this post


Link to post
Share on other sites

A problem was encountered using the smbmount command saying something like:

 

Usage: mount.smbfs service mountpoint [-n] [-o options,...]" followed by the list of options and "This command is designed to be run from within /bin/mount by giving the option '-t smbfs'.

 

You can overcome this using the mount command:

 

mount -t smbfs -o username=USER,password=PASS //server/share /mnt/share

 

Replacing USER/PASS as before.

Share this post


Link to post
Share on other sites

Expanding again :)

 

If you wish to open access to other users you can use the "umask" option with mount. You will need to understand the octal modes for file permissions a little to use this fully.

 

For instance:

umask 022 relates to 755 rwxr-xr-x (755 + 022 = 777).

 

If you are confused by this you can use umask=000 .. this will give read/write/execute permissions to ALL users.

 

Now to show umask in both the command line:

 

mount -t smbfs -o username=USER,password=PASS,umask=022 //server/share /mnt/share

 

And in fstab:

 

//winpc/shared  /mnt/share  smbfs  credentials=/root/.creds,rw,umask=022  0  0

 

Using umask allows you to adjust the permissions of the mounted share.

 

Summing up you can therefore control user (uid=), group (gid=) and permissions (umask=) on the mounted share.

Share this post


Link to post
Share on other sites

Thanks a lot for this guide!!

 

I followed your first example, the one without user/password and got it works superb :-)

 

But, How do I save this setting, dont want mount it manually evereytime I restart the computer...

 

I Have tried to edit the fstab but get error, can someone help a real Noob with a coode that NOT supose to have a password or username.... (i have a xbox and other stuff conected to the network and want not to setupp password, yes I m lazy...)

 

BR /Andreas

 

_________

Edit:

This line works good in fstab:

//servername/sharename /media/sharename smbfs rw 0 0

 

But after restart I need to type sudo mount -a

 

So again, why does my Kubuntu not automatically do this during restart...

Share this post


Link to post
Share on other sites
Thanks a lot for this guide!! I followed your first example, the one without user/password and got it works superb :-)

 

Yay!

 

So again, why does my Kubuntu not automatically do this during restart...

 

You are there, any normal system would auto mount that with no issues.

 

Interestingly enough I know why this is. There is a bug with kubuntu (and ubuntu) that means it will hang if samba is auto mounted from fstab. I believe it has to do with the kernel module not being installed early enough.

 

So to work around this, do the following:

 

/etc/fstab add the "noauto" option to ensure that its not going to be auto mounted.

//servername/sharename /media/sharename smbfs rw,noauto 0 0

 

The open up /etc/rc.local (make one if its not there) and add:

mount /media/sharename

 

By the time that rc.local is run the kernel module will be there and all should be well (proof of this is your ability to mount -a after its all booted).

 

^_^

Share this post


Link to post
Share on other sites

Hi, think I'm need some more help! :-(

 

Fixed the noauto and the fstab and restarted the computer, but the disk are not mounted (and it.s now not possible to use the mount -a command because the noautu).

 

As before when I click on the icon for the share folder in desktop I get the messege that only root can mount it... (I have even added more rights to the useracount besides admin also root, disks...)

 

Is there a way to verify that the rc.local has been started? It works fine if I type sudo /etc/rc.local (and password) in the terminal...

Share this post


Link to post
Share on other sites
Hi, think I'm need some more help! :-(

 

Ah .. my fault I think, do this:

chmod +x /etc/rc.local

 

Adding executable permissions to it.

 

If it runs the script .. you should see (as the last thing) something like:

* Running local boot scripts

 

Or similar.

Share this post


Link to post
Share on other sites

You people need to stop posting answers to questions unless you know your advice will work. I've lost about 30 hours in the last 4 days because of this.

 

I too have the same problem.

 

I installed Ubuntu 6.06 dapper drake as dual boot. Followed instructions and installed it correctly. Everything is great... except whenever I click on a drive in "Computer" I get a message that says "Only root can mount /dev/sdc1". And yes, I have tried everything I can think of. My fstab looks fine. I've tried sudo and sudo su to root.

 

Helpful suggestions please. Obivously lots of people have had this issue if I received the error on a clean install.

Share this post


Link to post
Share on other sites
samssf Posted Today, 01:17 AM

You people need to stop posting answers to questions unless you know your advice will work. I've lost about 30 hours in the last 4 days because of this.

if we don't post howto's then how will people learn ?

 

I installed Ubuntu 6.06 dapper drake as dual boot. Followed instructions and installed it correctly. Everything is great... except whenever I click on a drive in "Computer" I get a message that says "Only root can mount /dev/sdc1".

 

ok lets be clear here, are you trying to mount ANOTHER computers (windows xp) 'share' or are you trying to mount your dual boot NTFS drive ? To be clear, THIS POST is about how to mount ANOTHER computers share from within linux, it is not about how to mount an NTFS drive/partition within linux.

 

if that's the case then you need to read the 'how to mount an NTFS drive in 5 minutes or less... post'

 

if this is not the case then please give us details of what you have tried and what your exact error is,

 

the more details the better, oh and welcome to the forums,

 

cheers

anyweb

Share this post


Link to post
Share on other sites
/dev/sdc1

 

That is a local drive, what this howto is for is remote windows share. Check out the link that anyweb provided.

 

It should be made clear to all, this tutorial requires two separate machines, one a linux system the other a windows system, I'm sorry if there was any confusion with regards to this.

Share this post


Link to post
Share on other sites

i tried all the methods stated in this thread, but all i get is this

dustman@dustman-laptop:~$ smbmount //smb://ionut/ /home/dustman/Muzica/jean/ -o ro
11060: Connection to smb: failed
SMB connection failed

 

where "//smb://ionut" is the network path of the share folder i want to mount, and "/home/dustman/Muzica/jean/ " is the path i want to mount the share folder

 

With the second method i get:

dustman@dustman-laptop:~$ sudo mount -t smbfs -o guest //smb://ionut /home/dustman/Muzica/jean/
11318: Connection to smb: failed
SMB connection failed

 

basicly the same stuff as the first method. What am I doing wrong? :|

 

 

P.S. the network has only two users...my laptop and "ionut" computer...so there are no username and password set. In windows it works like a dream, but in ubuntu is doesn't :(

Share this post


Link to post
Share on other sites

Remove the //smb: from the front of your lines. It sees the smb: as the name of the PC its trying to connect to!

 

$ smbmount //IPADDRESS/ionut /home/dustman/Muzica/jean/ -o ro

 

Or

 

$ sudo mount -t smbfs -o guest //IPADDRESS/ionut /home/dustman/Muzica/jean/

 

There we go :)

Share this post


Link to post
Share on other sites
Remove the //smb: from the front of your lines. It sees the smb: as the name of the PC its trying to connect to!

 

$ smbmount //IPADDRESS/ionut /home/dustman/Muzica/jean/ -o ro

 

Or

 

$ sudo mount -t smbfs -o guest //IPADDRESS/ionut /home/dustman/Muzica/jean/

 

There we go :)

 

yes, yes....it's working :D i figured it out.... thank you for answering :)

 

 

Cheers!

 

 

Radu

Share this post


Link to post
Share on other sites

Just a quick footnote: "smbfs" should now read "cifs" for newer versions of SAMBA. I can't tell what version it changed; I know SMBFS still works on my FC4 home box but not on my Fed7 server at work (had to use CIFS).

Share this post


Link to post
Share on other sites

I have tried many different things in the terminal to get read AND write access to my windows xp shared folder in a mounted folder. I can read and write if i go into smb://server/SharedDocs/ but in the folder i mounted it to, all the files are read only. I'm trying to get read and write access in the folder i mounted it to, is this possible?

 

The windows XP computer is on the same network as my kubuntu 9.04 which is the computer I cam trying to do this on.

 

Examples of what I've tried:

smbmount //192.168.0.101/SharedDocs /home/kyle/Server -o rw,umask=000

smbmount //192.168.0.101/SharedDocs /home/kyle/Server -o rw,uid=kyle

sudo smbmount //192.168.0.101/SharedDocs /home/kyle/Server -o -username=kyle,password=,dir_mode=0777,file_mode=0777

(in the last one on here I wasn't completely sure about what to do for the username and password)

 

Thanks for any help.

Share this post


Link to post
Share on other sites

Firstly, I'd not recommend using 777 on any directory/file. For testing, pop it on, then examine the ownership of files etc - but it should then be changed back to something more secure.

 

Secondly, you need to match the XP credentials versus the Linux ones: Linux will connect to that share and emulate the user, but then you'll need to map local (Linux) users to that remote user so from XP's point of view, it's the same user each time - I think the SUID and SGID bits will do this.

 

Also, check the file ownership from the XP side - are the files owned by "Kyle" or by "guest"? I know under Windows that unmatched credentials will drop the incoming connection down to "guest" access which is usually disabled by default in XP now, but some people enable it to diagnose sharing issues then forget that every unmatched incoming username maps to the guest user.

 

Can you also look at the security logs under XP and see what they say?

 

Oh - one final point... check the ownership/permissions of the mount point AFTER it's mounted. I made that mistake once.

Share this post


Link to post
Share on other sites

I have followed your instructions exactly, however when I try to mount (whichever way), I am prompted for another password (After having entered the password for root priviledges).

I have tried all the passwords it can possibly be, but keep getting:

mount error(13): Permission denied

 

Also when I go to Places->Network I can see all my Windows shares, but when I try to enter any of them (including shareddocs) I get permission denied.

 

Why is this?

 

Please help!

Share this post


Link to post
Share on other sites

My guess is that it's asking for a Windows password, not Linux one.

 

Can you check Windows logfiles and see what those say?

Share this post


Link to post
Share on other sites

My guess is that it's asking for a Windows password, not Linux one.

 

Can you check Windows logfiles and see what those say?

 

Hi,

Dumb question: where would I find the Windows logfiles?

 

Thanks

Share this post


Link to post
Share on other sites

Windows Event Viewer. Should find it in "Manage" (if you right-click "My Computer")

Share this post


Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...