![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Outdated Tutorials & Tips Outdated Tutorials & Tips |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
A Carafe of Ubuntu
![]() Join Date: Jul 2006
Location: Paris
Beans: 106
|
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 Code:
mount -t smbfs //servername/sharename /mountdirectory -o username=mywindowsusername,password=mywindowspassword /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 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 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 Code:
smbmount //servername/sharename /mountdirectory -o credentials=/home/myhomedirectory/.smbpasswd 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 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 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 Code:
chmod u+s /usr/bin/smbmnt 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 Lenny user. Don't underestimate the power of *nix manual!!! Code:
geco@biohazard:~$ man man |
|
|
|
|
|
#2 |
|
5 Cups of Ubuntu
![]() Join Date: Sep 2006
Location: SE Michigan, USA
Beans: 26
Ubuntu 8.04 Hardy Heron
|
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 |
|
First Cup of Ubuntu
![]() Join Date: Sep 2006
Beans: 5
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 | |
|
First Cup of Ubuntu
![]() Join Date: Sep 2006
Beans: 5
Ubuntu 6.06
|
Re: [HOW TO] Mounting smbfs Shares Permanently
Quote:
|
|
|
|
|
|
|
#5 |
|
First Cup of Ubuntu
![]() 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 |
|
Just Give Me the Beans!
![]() |
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 |
|
|
|
|
|
#7 | |
|
Day Old Decaf
![]() Join Date: Jan 2006
Location: Sterling Heights, MI
Beans: 142
Ubuntu 6.06 Dapper
|
Re: [HOW TO] Mounting smbfs Shares Permanently
Quote:
|
|
|
|
|
|
|
#8 | |
|
自己犠牲の精神
![]() Join Date: Mar 2006
Location: Kitakyushu Japan
Beans: 7,890
Xubuntu 8.04 Hardy Heron
|
Re: [HOW TO] Mounting smbfs Shares Permanently
Quote:
ie, reverse slash to specify the folder name.
__________________
1) Samba server howto in progress | 2) mount windows/samba shares with CIFS + unicode | 3) best FTP server howto
4) NFS server/client howto | 5) Easy cross-platform LAN file sharing with FTP 6) Fix samba browsing!!! | 7) Fix Pulse audio Happy Ubunting!![]() |
|
|
|
|
|
|
#9 | |
|
A Carafe of Ubuntu
![]() |
Re: [HOW TO] Mounting smbfs Shares Permanently
Quote:
|
|
|
|
|
|
|
#10 |
|
5 Cups of Ubuntu
![]() Join Date: Oct 2006
Location: Wellington, New Zealand
Beans: 15
Ubuntu 9.10 Karmic Koala
|
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 Code:
username=uglysamba password=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 Code:
//ugly/music /home/bigbadsi/mnt smbfs credentials=/root/.smbcredentials,dmask=777,fmask=777 0 0 Code:
//ugly/music /home/bigbadsi/mnt/ smbfs defaults 0 0 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. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|