Page 1 of 5 123 ... LastLast
Results 1 to 10 of 47

Thread: [HOW TO] Mounting smbfs Shares Permanently

  1. #1
    Join Date
    Jul 2006
    Beans
    107

    Lightbulb [HOW TO] Mounting smbfs Shares Permanently

    I was wandering about mounting samba shares as non-root user and I found a good solution searching around the web.

    You can find the original article on JustLinux.

    So I paste and copy this how-to in ubuntuforums.

    If I'm breaking any copyright I will not hesitate to delete this post.

    Mounting smbfs Shares Permanently Help File

    By Ray Cowan

    This document provides help on mounting smbfs shares permanentantly. These can be shares on a Windows computer or on a Linux/UNIX server running Samba.

    Throughout this document, I use the term Windows computer to indicate the server. It can be either a Windows computer or a Linux/UNIX server running Samba.

    The Windows username and Windows password refer to the username and password on either the Windows computer or the Linux/UNIX server running Samba.
    Mounting the Share

    To mount an smbfs share from a Linux workstation at the command line, you can use either the smbmount command or use mount -t smbfs. Both command will work the same. When you use mount -t smbfs, the mount program actually passes the command over to smbmount for execution. Throughout this document I'll use smbmount instead of mount -t smbfs.

    An example would look like this:
    Code:
    smbmount //servername/sharename /mountdirectory -o username=mywindowsusername,password=mywindowspassword
    The mount equivalent is:
    Code:
    mount -t smbfs //servername/sharename /mountdirectory -o username=mywindowsusername,password=mywindowspassword
    //servername/sharename refers to the name of the Windows computer and the name of the share.

    /mountdirectory refers to the directory you use as the mount point on the Linux workstation. It can be any directory as long as the user executing the command has rights to it.

    Whether you need to supply a username and password depends on what type of security you have on the Windows share. If you have a share created with no password on it, you shouldn't need to provide a username and password. If the share happens to be on a Windows NT server that is part of a domain, you would need to provide a domain login name and password.
    Making the Mount Permanent

    smbmount does not make the mount permanent. If the Linux workstation is rebooted, you will have to mount the share again. To make the mount occur each time you start the Linux workstation, you can put an entry in your /etc/fstab file. An example file would look like this:
    Code:
    LABEL=/ / ext3 defaults 1 1
    LABEL=/boot /boot ext3 defaults 1 2
    none /dev/pts devpts gid=5,mode=620 0 0
    LABEL=/home /home ext3 defaults 1 2
    none /proc proc defaults 0 0
    none /dev/shm tmpfs defaults 0 0
    /dev/hda3 swap swap defaults 0 0
    /dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0
    /dev/hdd4 /mnt/zip100.0 auto noauto,owner,kudzu 0 0
    /dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
    //servername/sharename /mountdirectory smbfs username=windowsuserename,password=windowspassword 0 0
    The last line in the file is the line that will mount the Windows share. You would add a line similar to that in your /etc/fstab file for each share you want to mount. Once again the username and password are only needed if the Windows share is set up to require them. If a username and password are not required, you may just replace them with the word defaults.

    An important thing to remember is that there is no space between the comma and the word password. If you put a space there, it won't work.
    Providing Security

    The /etc/fstab is readable by everyone so it obviously wouldn't be a good idea to have your Windows password in it. The way to get around this is by using what is known as a credentials file. This is a file that contains just the username and password. The best place to put this file would be in your home directory. Here is how to do it.

    Create a file in your home directory named .smbpasswd (the period at the start of the filename makes it a hidden file). Modifify the permissions on the file so only you have permission to read and write to it. The only thing in the file is your Windows username and password. Here's the commands you would enter to create the credentials file:
    Code:
    cd
    echo username=mywindowsusername > .smbpasswd
    echo password=mywindowspassword >> .smbpasswd
    chmod 600 .smbpasswd
    Substitute your Windows username and password in the commands. No one else except root would be able to read the contents of this file.

    Once that is created, you would modify the line in the /etc/fstab file to look like this:
    Code:
    //servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/.smbpasswd 0 0
    You can also use the credentials option in the smbmount command for security reasons. That command would look like this:
    Code:
    smbmount //servername/sharename /mountdirectory -o credentials=/home/myhomedirectory/.smbpasswd
    Providing Read/Write Access to the Share

    Another problem with mounting the Windows share as shown in the /etc/fstab file above is that only the root user would have read/write access to the share. All other users would have read only access to it. If you wanted read/write access to it for yourself, you need to specify your userid or groupid. That would change the line in /etc/fstab to look like this:
    Code:
    //servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/. smbpasswd,uid=mylinuxusername,gid=mylinuxgroupname 0 0
    Whatever user and or group you specified in the line would have read/write access to the mounted share. You can use either the user or group name or the user or group numerical ID. Either should work.

    If you had several users you wanted to have read/write access to it, create a group and add those users to the group. Then specify just that groupid in the /etc/fstab file. You wouldn't need to specify a userid. The line in etc/fstab would look like this:
    Code:
    //servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/. smbpasswd,gid=sambausersgroup 0 0
    You can see the man pages on smbmount, smbumount, mount, and fstab for more details.

    Troubleshooting

    If you have trouble mounting your Windows shares from /etc/fstab, here are some things to try.

    The most important thing is to try to mount the share using the mount -t smbfs command from the command line. This is what will be executed when the the Linux workstation is booted up and the mounts in /etc/fstab are initialized. If you can't sucessfully mount the share with mount -t smbfs, it won't work in /etc/fstab. Work the bugs out with mount -t smbfs. Once it works, it should then work in /etc/fstab.

    One of the most common problems with mount -t smbfs is a file not found error. The file not found is smbmnt, which is used by smbmount. It's usually a result of the smbmnt command not being in the path when the mount command executes. The mount command usually resides in the /bin directory and smbmnt resides in /usr/bin. To fix this problem, you need to create links to smbmnt in the /bin directory. To accomplish this, execute these commands as root:
    Code:
    ln -s /usr/bin/smbmnt /bin/smbmnt
    ln -s /usr/bin/smbmount /bin/smbmount
    Another problem occurs when a non-root user tries to mount a Windows share using smbmount. To allow them to do it you need to setuid root the smbmnt command. Since smbmnt usually resides in /usr/bin, you can accomplish it with this command as root:
    Code:
    chmod u+s /usr/bin/smbmnt
    This will not work if you setuid the smbmount command. It is specifically written so that it won't execute if it is setuid root.

    To allow non-root users to unmount the shares, you need to setuid the smbumount command. Execute this as root:
    Code:
    chmod u+s /usr/bin/smbumount
    Debian testing user.
    Don't underestimate the power of *nix manual!!!
    Code:
     geco@biohazard:~$ man man

  2. #2
    Join Date
    Sep 2006
    Location
    SE Michigan, USA
    Beans
    31

    Re: [HOW TO] Mounting smbfs Shares Permanently

    Geco, be assured your HowTo has been used successfully. Good jub!

    I have an interesting result when using /etc/fstab: The HAL (hald) fails to come up cleanly *sometimes* (which makes me think network state is involved). I've set it aside for now until I can find out how to get some clues - any appreciated.
    Expert Opinions $5 Shutup $10

  3. #3
    Join Date
    Sep 2006
    Beans
    5
    Distro
    Ubuntu 6.06

    Re: [HOW TO] Mounting smbfs Shares Permanently

    Okay I had to use cifs vs smbfs. Everything works except for the implementation of the credentials file. Syslog says:

    CIFS VFS: No username specified
    CIFS VFS: cifs_mount failed w/ return code = -22

    The file exists and contains the proper username and password, the owner <myusername> has R/W access, the line in fstab looks like:

    //<servername>/photos /data/Photos cifs ro,credentials=/home/<myhomedirectory>/.smbpasswd 0 0

    If I go with standard username and password in fstab it works fine.

    What am I missing?

  4. #4
    Join Date
    Sep 2006
    Beans
    5
    Distro
    Ubuntu 6.06

    Re: [HOW TO] Mounting smbfs Shares Permanently

    Quote Originally Posted by vadar007 View Post
    Okay I had to use cifs vs smbfs. Everything works except for the implementation of the credentials file. Syslog says:

    CIFS VFS: No username specified
    CIFS VFS: cifs_mount failed w/ return code = -22

    The file exists and contains the proper username and password, the owner <myusername> has R/W access, the line in fstab looks like:

    //<servername>/photos /data/Photos cifs ro,credentials=/home/<myhomedirectory>/.smbpasswd 0 0

    If I go with standard username and password in fstab it works fine.

    What am I missing?
    Duh, needed to install smbfs (apt-get install smbfs)....

  5. #5
    Join Date
    Jul 2006
    Beans
    2

    Re: [HOW TO] Mounting smbfs Shares Permanently

    Anyone know how to mount a folder nested within a share on a windows computer?

    In other words:
    smbmount //server/share/folder mountpoint

    Unfortunately this doesn't work for me. I want to only mount the folder within the share, not the whole share.

    Suggestions?

  6. #6
    Join Date
    Aug 2006
    Location
    Nashville, TN
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: [HOW TO] Mounting smbfs Shares Permanently

    I am unable to change the group permissions for folders within the samba share. i have tried

    Code:
    chmod 777 -R foldername
    this does not work... what am i doing wrong?

  7. #7
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: [HOW TO] Mounting smbfs Shares Permanently

    This how-to has been added to the ubuntu wiki:

    How to mount smbfs shares
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  8. #8
    Join Date
    Jan 2006
    Location
    Sterling Heights, MI
    Beans
    142
    Distro
    Ubuntu 6.06 Dapper

    Re: [HOW TO] Mounting smbfs Shares Permanently

    Quote Originally Posted by meyersjd View Post
    Anyone know how to mount a folder nested within a share on a windows computer?

    In other words:
    smbmount //server/share/folder mountpoint

    Unfortunately this doesn't work for me. I want to only mount the folder within the share, not the whole share.

    Suggestions?
    While this is easy in Windows, it is not possible using smbmount. You can only mount actually shared resources. Sorry.

  9. #9
    Join Date
    Oct 2006
    Location
    Wellington, New Zealand
    Beans
    17
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: [HOW TO] Mounting smbfs Shares Permanently

    I've only been using Ubuntu for a week so please bear with me...

    I am unable to permanently mount a samba share. I have samba running, I can access the share via network:/// and can mount the share manually using:
    Code:
    sudo mount -t smbfs //ugly/music /home/bigbadsi/mnt/ -o credentials=/root/.smbcredentials
    Have have already set up /root/.smbcredentials and the contents of this file looks like this:
    Code:
    username=uglysamba
    password=uglysamba
    I have set up the user uglysamba on the remote windows box (as a limited user) and set the password to uglysamba.

    The share won't mount automatically after a reboot. This is my /etc/fstab file:
    Code:
    # /etc/fstab: static file system information.
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc            /proc           proc    defaults        0       0
    /dev/sda5       /               ext3    defaults,errors=remount-ro 0       1
    /dev/sda1       /media/sda1     ntfs    defaults,nls=utf8,umask=007,gid=46 0       1
    /dev/sda3       /media/sda3     vfat    defaults,utf8,umask=007,gid=46 0       1
    /dev/sda6       none            swap    sw              0       0
    /dev/hda        /media/cdrom0   udf,iso9660 user,noauto     0       0
    //ugly/music /home/bigbadsi/mnt smbfs credentials=/root/.smbcredentials 0 0
    I have tried changing the last line of /etc/fstab to read (as per http://ubuntuguide.org/wiki/Dapper#H..._a_samba_share):
    Code:
    //ugly/music /home/bigbadsi/mnt smbfs credentials=/root/.smbcredentials,dmask=777,fmask=777 0 0
    I have also tried changing the last line of fstab to:
    Code:
    //ugly/music /home/bigbadsi/mnt/ smbfs defaults 0 0
    After reboot mount doesn't show my share.

    Is this a permissions issue at startup, do I need to include other options in /etc/fstab or am I missing something else? Also, is there a log I should have checked (I looked in /var/log/samba but didn't know what I was looking at)?

    Thanks.

  10. #10
    Join Date
    Mar 2006
    Location
    Kitakyushu Japan
    Beans
    9,361
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: [HOW TO] Mounting smbfs Shares Permanently

    Quote Originally Posted by meyersjd View Post
    Anyone know how to mount a folder nested within a share on a windows computer?

    In other words:
    smbmount //server/share/folder mountpoint

    Unfortunately this doesn't work for me. I want to only mount the folder within the share, not the whole share.

    Suggestions?
    it should be smbmount //server/share\folder mountpoint

    ie, reverse slash to specify the folder name.

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •