Welcome To My Blog
here i will try to collect as much as i can of articles and
toutorials talking about linux and open source software

if you want to share me this and be an author Contact me
subscribe to RSS or subscribe to Email Newsletter

Auto mounting a Samba share in Linux

Posted by ahmedhamdy_27 Monday, February 22, 2010

Buzz It

So you have that Samba server up and running and you can connect to it from Windows and Mac with ease. But when you turn to another Linux box that doesn’t have Konqueror, Nautilus, or Dolphin you can’t figure out the riddle of connecting. Or maybe you want to have this share mounted at boot time? How do you manage it?From the command line of course. Yes there are plenty of GUI tools that will allow you to connect to a Samba share easily, but they don’t help you set up anything to connect automatically. For that you will need to employ a few command line tools. But once it is finished, your system will be seamless.

What you will need
First I am going to assume you have your Samba server set up and you are able to connect to it from other machines. Outside of that you will need only one piece of software installed on your Linux machine: smbclient. This will be in your distributions’ repositories so just open up your Add/Remove Software utility, search for smbclient, select it, and click Apply.
Once smbclient is installed you are ready to go.

A test
Let’s first test to make sure your Linux box can see the Samba share. You will need either sudo or root access to do this. Issue the command:
smbclient //IP_TO_SAMBA_SERVER/SHARE_NAME -U USERNAME
Where:

  • IP_TO_SAMBA_SERVER is the IP address of your Samba server.
  • SHARE_NAME is the share you want to connect to.
  • USERNAME is the user name you connect to the share with.
If all is well you should see something like this:
Enter wallenmusic’s password:
Domain=[MONKEYPANTZ] OS=[Unix] Server=[Samba 3.2.5]
smb: \>
If you see that you can type quit and then hit the Enter key to escape this prompt.

Setup
The first thing you need to do is create a directory to mount the Samba share to. I created the directory /data with the command:
sudo mkdir /data
Once that directory is created you can then mount it with the command:
mount -t smbfs -o username=USERNAME //IP_TO_SAMBA_SERVER/SAMBA_SHARE /data
Where:
  • IP_TO_SAMBA_SERVER is the IP address of your Samba server.
  • SHARE_NAME is the share you want to connect to.
  • USERNAME is the user name you connect to the share with.
Now if you check the /data directory you should see a listing of the contents of the Samba share.

Automount
Let’s make that share automount at boot. This will require editing your /etc/fstab file, adding an entry for this Samba share. In this file (again you will have to have either root or sudo access) you will add a line like this:
//IP_TO_SAMBA_SERVER/SAMBA_SHARE� /data smbfs username=USERNAME,password=PASSWORD, 0 0
Where:
  • IP_TO_SAMBA_SERVER is the IP address of your Samba server.
  • SHARE_NAME is the share you want to connect to.
  • USERNAME is the user name you connect to the share with.
  • PASSWORD is the password for the Samba user
Once that entry is saved unmount the /data directory with the command:
umount /data
so you can test your automount entry.
Now, enter the command:
mount -a
If there are no errors you should see the contents of the Samba share in the /data directory.
That’s it. Congratulations, you now have an automounted Samba share on your Linux machine.

Blog Widget by LinkWithin
Add to Technorati Favorites
blog comments powered by Disqus
Loading...

BEST WAY TO SAY THANKS

Labels

ubuntu apache mysql backup gnome audio players compile kernel grub restore security themes web hosting 3d games Clonezilla centos cpanel database fun games gmail gzip kernel linux games mod_deflate monitoring tools music making open ssh recovery redhat reinstall grub rsync ssh * Apt-Get * Howto 3d acceleration AMANDA Ardour Bacula Duplicity E-Books Extract files from ISO FlyBack Graphics Card IP Failover and Web Cluste IP Failover and Web Cluster IPv6 Jokosher K9Copy KDE Karmic Linux Linux Set Date and Time Linux Tools Linux backup tools Linux commands Networking Nginx Open VPN Operating system PATH ReZound Remote Desktop Solutions for Linux Reverse Proxy Load Balancer SLAMPP Samba Sweep Time Vault Traverso DAW Ubuntu Tweak Webmin Windows vs Linux antivirus audi studio auto mount bash block ip block users blog editor boot caching check mail dangerous .caution dd deadly commands debian directory listing dns docks dvd easyapache error 18 fedora find fixing partitions table fork() bomb glxinfo hacking handbrake help image initrd install linux iptables jack jaunty lamp ldap lfs linus linux live linux vs windows log mac osx man mod_rewrite mount network boot ntfs open courseware open source books opengl openshot own distro packup php print in linux print over wireless ptr recompile redirect restore disk restore mbr reverse dns rip dvd screen server share desktop speed up linux spf ssmtp stream desktop swatch syslog syslog-ng top toutorials useful applications vi video editor vim vlc vmlinuz wallpapers whm xsplash

Recent Posts

archive

BEST WAY TO SAY THANKS