Connect automatically to shared folder in Ubuntu
Posted by The Technocrat | Filed under Operating Systems
In a windows environment, you automatically get connected to your H: drive (or sometimes Z:) when you log in. For people using Ubuntu, this doesn’t happen natively. Here’s how to restore this functionality:
First, make sure you are able to resolve server names via WINS. If you can’t, you might as well do that now… it makes operating on a windows network a lot easier.
OK, give the Terminal (Applications > Accessories > Terminal) this command:
sudo apt-get install samba smbfs
Now go ahead and make a folder called ‘H-drive’ or whatever. Just don’t use spaces. I chose to make it in my home directory. You can use the FIle Manager, or just type in:
sudo mkdir /home/<username>/H-drive
(so mine was ‘sudo mkdir /home/technocrat/H-drive’)
Now type in:
sudo gedit /etc/fstab
We’re going to tell Ubuntu to connect your server folder to the folder you just made. Copy these two lines to the end of the file, and change as neccessary. If you don’t know what server your stuff is on, or what the share name is, ask your administrator.
# mount H drive as a folder in home dir
//<servername>/<sharename> /home/<username>/H-drive cifs exec,credentials=/etc/cifspw 0 0
(Where servername/sharename is your network folder, and /home/username/H-drive is where you made the folder on your system.)
We’ve told Ubuntu to get the proper username and password from a file at /etc/cifspw. That file doesn’t exust yet, so let’s make it. Enter this at the console:
sudo gedit /etc/cifspw
and enter this in the file:
username=(your windows network username)
password=(your windows network password)
Save and close. Now give this to the console to lock down the security on that file:
sudo chmod 600 /etc/cifspw
And then kick off the mount process you you can try it out:
sudo mount -a
You should be able to navigate to your H-drive folder by clicking Places > Desktop and going to Home/(username)/H-drive. You should see your stuff there!
modified from starkos
September 22, 2008 at 2:07 pm
nice work, dude