Jump to content


Photo

How to mount a Windows share with smbmount


22 replies to this topic

#1 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 21 March 2005 - 11:52 PM

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 ;)
  • BycleIlliny likes this

#2 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 25 February 2006 - 11:14 PM

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 ^_^

#3 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 03 May 2006 - 04:54 PM

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.

#4 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 15 May 2006 - 04:06 PM

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.

#5 Shadowcat

Shadowcat

    Noob

  • Members
  • Pip
  • 20 posts

Posted 21 May 2006 - 10:19 PM

bah edit the original post lazybones :P


Which post .. ? [znx]
# aptitude install life
Couldn't find package "life".
#

#6 Andy72

Andy72

    Noob

  • Members
  • Pip
  • 3 posts

Posted 10 July 2006 - 02:40 PM

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...

#7 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 10 July 2006 - 09:53 PM

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).

^_^

#8 Andy72

Andy72

    Noob

  • Members
  • Pip
  • 3 posts

Posted 11 July 2006 - 05:21 PM

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...

#9 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 11 July 2006 - 09:41 PM

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.

#10 Andy72

Andy72

    Noob

  • Members
  • Pip
  • 3 posts

Posted 12 July 2006 - 07:02 PM

Thank you for your patience with me, but Iím sorry to say that it still not working. Itīs exactly the same as before, and I not sure that I can see something like running any boot scripts during the boot up (its sweep away very fast in the end, and can not break/pasue)Ö

If you have any more idea Iím happy too hear them otherwise itís ok, I now itís not easy to serve computers from distanceÖ :\

I have done some progress with Linux anyway, I can now log into linux from my windows pc, so its works auto from that direction (that way I need password, maybe I find a solution to shut it off)!

#11 samssf

samssf

    Noob

  • Members
  • Pip
  • 1 posts

Posted 20 September 2006 - 02: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.

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.

#12 anyweb

anyweb

    Administrator

  • Admin
  • PipPipPipPipPipPipPipPip
  • 3,689 posts

Posted 20 September 2006 - 06:24 AM

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
i do windows too

#13 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 20 September 2006 - 01:03 PM

/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.

#14 dustman

dustman

    Noob

  • Members
  • Pip
  • 2 posts

Posted 16 November 2007 - 10:26 PM

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 :(

#15 znx

znx

    Linux-Noob GURU

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

Posted 21 November 2007 - 02:37 PM

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 :)

#16 dustman

dustman

    Noob

  • Members
  • Pip
  • 2 posts

Posted 21 November 2007 - 09:13 PM

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

#17 Dungeon-Dave

Dungeon-Dave

    Linux-Noob Frequent Member

  • Moderator
  • PipPipPipPipPipPipPip
  • 972 posts

Posted 24 September 2008 - 09:04 PM

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).

#18 54speed

54speed

    Noob

  • Members
  • Pip
  • 1 posts

Posted 31 July 2009 - 04:02 PM

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.

#19 Dungeon-Dave

Dungeon-Dave

    Linux-Noob Frequent Member

  • Moderator
  • PipPipPipPipPipPipPip
  • 972 posts

Posted 02 August 2009 - 05:05 PM

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.

#20 jamesm6162

jamesm6162

    Noob

  • Members
  • Pip
  • 2 posts

Posted 23 August 2009 - 04:17 PM

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!

#21 Dungeon-Dave

Dungeon-Dave

    Linux-Noob Frequent Member

  • Moderator
  • PipPipPipPipPipPipPip
  • 972 posts

Posted 24 August 2009 - 09:29 PM

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

Can you check Windows logfiles and see what those say?

#22 jamesm6162

jamesm6162

    Noob

  • Members
  • Pip
  • 2 posts

Posted 03 September 2009 - 02:39 PM

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

#23 Dungeon-Dave

Dungeon-Dave

    Linux-Noob Frequent Member

  • Moderator
  • PipPipPipPipPipPipPip
  • 972 posts

Posted 07 September 2009 - 04:34 PM

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



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users