Tuesday, January 25, 2011

How to Mount Windows Shares Permanently under Ubuntu

Windows shares or Samba shares from another Linux system can be mounted permanently under Ubuntu so you don't need to mount them every time you boot your computer. You need to define those shares in your /etc/fstab. Follow the steps below.

1. Install Samba File System.

sudo apt-get install smbfs

Guest Shares (Unprotected)

1.Create the mount folder.

sudo mkdir /media/shares

You can place this directory where ever you want to. e.g, your Home directory or at the desktop as well.

2. Edit /etc/fstab

gksudo gedit /etc/fstab

And paste this line at the end of that file.

//servername/sharename  /media/shares  cifs  guest,uid=1000,iocharset=utf8,codepage=unicode,unicode  0  0

Where server name can be your server's name or its ip address. Share name is obviously the name of shared directory. /media/shares is the mount directory.

Save and close this file.

3. Test your shares.

sudo mount -a

Password Protected Shares

1. Create a file within your home directory that will contain your credentials for accessing the shares.

gksudo gedit /home/<username>/.smbcredentials

Where <username> is your username. In that file, include these 2 lines.

username=<user name for accessing the share>
password=<password for accessing the share>

Add the intended information against each field and save and close this file.

2.Change the permissions on newly created file for blocking un-authorized access.

sudo chmod 600 /home/<username>/.smbcredentials

3.Edit /etc/fstab

gksudo gedit /etc/fstab

And paste this line at the end of that file.

//servername/sharename /media/shares cifs credentials=/home/<username>/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

Where server name is your server name. Share name is the name of shared direcotry. <username> is your own username.

Save and exit this file.

4. Test your shares.

sudo mount -a

If there are no errors reported, you can safely reboot.

For further approaches, please see the wiki page here.



Related Posts:

File System , Windows