HOWTO: Mount Samba (CIFS) Share on Linux (Symbolic Link Redirect)

| No TrackBacks
Mounting a Samba share on Linux is fairly straightforward.  You'll need access to "/sbin/mount.cifs", and a spare mount-point.  For the sake of this demo, I'm going to mount a share on 192.168.1.100 to /mnt.

Continue reading for the HOWTO, and a gotch-ya to be aware of when dealing with symbolic links ...
I'm going to mount the home directory for user "mark" on 192.168.1.100 to /mnt via Samba.  As root, or a privlidged user via sudo, run:

(root@bermuda)~> /sbin/mount.cifs //192.168.1.100/mark /mnt -o user=mark


This command should complete successfully if the Samba server at 192.168.1.100 is configured correctly.  If it dosen't, and you see an error on the console from the mount.cifs command, check the system log for more information by running "dmesg".  Once mounted, you can check the mount-point details using the df command:

(root@bermuda)~> df -h /mnt
Filesystem            Size  Used Avail Use% Mounted on
//192.168.1.100/mark         30G  8.4G   21G  30% /mnt


The -h flag tells df to display the mount-point data in a human-readable format.  For more details, see the man 1 df.

(root@bermuda)~> ll /mnt
total 372
lrwxrwxrwx 1 mark mark      5 2008-04-11 01:08 core -> /core
drwxr-xr-x 2 mark mark      0 2008-11-19 10:16 Desktop


Neat, it worked!  But there's just one small problem: core is a symbolic link to /core on 192.168.1.100.  I wanted this to resolve to a directory, not another symbolic link.  If I try to change directories to /mnt/core, it won't work:

(root@bermuda)~> cd /mnt/core
bash: cd: /mnt/core: No such file or directory


This is happening because /core isn't a mount point on my localhost, /core is a mount-point on 192.168.1.100, our Samba share.  The trick is to set /proc/fs/cifs/LinuxExtensionsEnabled to 0 (zero):

(root@bermuda)~> umount /mnt

(root@bermuda)~> echo "0" > /proc/fs/cifs/LinuxExtensionsEnabled

(root@bermuda)~> /sbin/mount.cifs //192.168.1.100/mark /mnt -o user=mark


Now, let's check /mnt.  We should be able to navigate into /mnt/core with no issues thanks to echo "0" > /proc/fs/cifs/LinuxExtensionsEnabled.

(root@bermuda)~> ll /mnt
total 376
drwxrwxrwx 1 root root      0 2008-12-12 14:52 core
drwxrwxrwx 1 root root      0 2008-11-19 10:16 Desktop

(root@bermuda)~> cd /mnt/core

(root@bermuda)/mnt/core> ll | grep -i vms
drwxrwxrwx 1 root root 0 2008-11-18 23:17 vms


Awesome!  Now I can navigate into /mnt/core and access files in /core on the Samba server via the symbolic link in the home directory.

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on December 14, 2008 1:49 PM.

The Gagawa Project Live on Google Code! was the previous entry in this blog.

HOWTO: Using a Web Proxy with XML-RPC (Java) is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.