justlinux.com
Mon, 23-Nov-2009 09:49:47 GMT
internet.com
Forum: Registered Users: 73495, Online: 165
nhfs Here you can view your subscribed threads, work with private messages and edit your profile and preferences Registration is free! Calendar Find other members Frequently Asked Questions Search Home Home

Help File Library: Connecting to SMB Shares from Linux

Written By: John the Kiwi

It has come to my attention that SAMBA has not been well documented lately. Looking up FAQs, Help Files and any other documentation, I found myself getting confused and frustrated. So I decided to document what works for me and my simple network – being a long time Windows user it is very important to me that I can access my Windows servers while I try and make the shift to Linux. Most major Linux distributions come with SAMBA as an option during the installation phase, Red Hat, Mandrake and Suse all come to mind off the top of my head.

The example I am using here required no Windows registry tweaks or configuration; I can connect to both Windows 2000 and XP servers in my workgroup with their out of the box settings.

All that is needed to create is an account on the Windows box for the Linux machines to connect with in this example the account created on the server is username and the password is password, of course this is not what I really used. Of course, name resolution must also be set up for this to work, I use my Windows 2000 server as a DNS server for my network but using manually added hosts or making sure the workgroup is the same between all machines will work equally as well. Pinging by machine name will confirm that name resolution is working correctly and ready for drives to be mapped/mounted.

I have four drives I want to map every time I boot my Linux machines, shared directories that reside on my server which is named (appropriately) server”.

The shares are named \\server\documents, \\server\music, \\server\software, and \\server\website. I couldn't find a location that is recommended for mounting SAMBA shares, so I just threw them into the /mnt directory which works fine for me. As root create the subdirectories that are required

mkdir /mnt/documents
mkdir /mnt/music
mkdir /mnt/software
mkdir /mnt/website

No permissions need to be changed.

On the Windows 2000 machine, an owner and group need to be named, so create a group named samba and add the Linux user to the samba group.

Create a file to map the drives and place it in the /root directory, naming it drives. This will disable access to everyone but root. This is important to do because this file is plain text and stores passwords within.

As root, type

vi /root/drives

In that file, enter

mount -t smbfs -o username=username,password=password, uid=username, gid=samba //pig/documents /mnt/documents
mount -t smbfs -o username=username ,password=password, uid=username, gid=samba //pig/music /mnt/music
mount -t smbfs -o username=username ,password=password, uid=username, gid=samba //pig/website /mnt/website
mount -t smbfs -o username=username,password=password, uid=username, gid=samba //pig/software /mnt/software

Note that the first username and password is for the remote machine's account on the Windows server. You can test the permissions of the mounted drives by typing ls -l. If the permissions are correct the owner and group will be listed for each file.

Now all we need to do is make sure that the drives are mounted upon boot. This step isn't required if your server isn't always turned on, as it can be run when required by root when the drives are required.

Open the file /etc/rc.local and place the line

bash /root/drives
within. This will run every time the machine is rebooted and, because it points to a file in the /root directory, we don't have to worry about people seeing the plain-text passwords stored in it.

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
internet.commerce
Be a Commerce Partner











internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs