Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to mount a Windows share with smbmount
#1

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.



Code:
mkdir /mnt/share




 

Next either...

 

Mount the share with user/pass:



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



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

 



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

Reply
#2

Decided to append some more to this:

 

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



Code:
username = znx
password = mypassword




 

Make sure the file is closed permissions...



Code:
chmod 0600 /root/.creds




 

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



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




 

Now the share can be mounted just by doing:



Code:
mount /mnt/share




 

Simple enough :)

Reply
#3

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

 



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

 



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




 

Replacing USER/PASS as before.

Reply
#4

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:

 



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




 

And in fstab:

 



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

Reply
#5

bah edit the original post lazybones :P

 

 

Which post .. ? [znx]

Reply
#6

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

Reply
#7

Quote:Thanks a lot for this guide!! I followed your first example, the one without user/password and got it works superb :-)
 

Yay!

 

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



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




 

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



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

 

:)

Reply
#8

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

Reply
#9

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

Ah .. my fault I think, do this:



Code:
chmod +x /etc/rc.local




 

Adding executable permissions to it.

 

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



Code:
* Running local boot scripts




 

Or similar.

Reply
#10
Thank you for your patience with me, but I
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)