Thursday, December 18, 2008

Mounting Linux Share via CIFS

In this tutorial, I'll discuss on how to mount shared folder under Linux via CIFS. First, let us list the packages or things needed to get us started. Here are they:

For the server:

- kernel that supports CIFS (Most Linux Distro's come with this)
- Samba server

For the client
- kernel that supports also CIFS
- Samba client (optional)

Next, we have to consider what ports to be openned for the mount to work. Here are they all of which are tcp:

- 2049 or nfs
- 53
- 445
- 139

Once the said ports are openned we can now proceed on the installation

On the server side:

1. First install Samba

yum install samba

2. start samba

/sbin/service smb start

3. Then we'll add a new samba user

smbpasswd -a smbuser1

;this will prompt for password so take note of this

4. create the folder to share

mkdir /home/smbusershare

5. edit samba configuration file locate at /etc/samba/smb.conf

vi /etc/samba/smb.conf

6. Add an entry like this

[sharename]
path = /home/smbusershare
read only = no
valid users = smbuser1

7. Restart Samba

/sbin/service smb restart


On the client side:

1. Follow the first 2 steps on the server side procedure.

2. Create the mounting point

mkdir /home/client/mnt

3. Mount the filesystem via CIFS. Issue this command:

mount -t cifs //server ip/sharename /home/client/mnt -o username=smbuser1,password=password

4. It should now map the mounted filesystem

5. To check

either issue

df -h

you should see like this

Filesystem Size Used Avail Use% Mounted on
/dev/hda3 73G 2.2G 67G 4% /
/dev/hda1 244M 18M 213M 8% /boot
none 506M 0 506M 0% /dev/shm
//server ip/sharename 36G 17G 18G 48% /home/client/mnt

or check /etc/mtab

vi /etc/mtab

you should see this entry

//server ip/sharename /home/client/mnt cifs rw,mand 0 0

6. To mount it at boot just add the complete command for mounting at /etc/rc.local

Hope you find this discussion helpful. Thanks!!! Cheers and God Bless!!!!

No comments: