Mount CIFS (SMB) on Linux using /etc/fstab

Mount using /etc/fstab 

The below /etc/fstab entry can mount CIFS shares during boot:
//192.168.1.2/myresource    /mnt/mysource     cifs defaults,username=myuser%mypassword

The below /etc/fstab entry can save the credential under another file which is more secure:
//WindowsHost/Sharename /LocalMountPoint cifs username=,credentials=/etc/cifsauth{any file},domain=my_domain 0 0

Two zeros at end of line are important as it will prevent boot failure when windows share is unavailable.

Format of credentials file (/etc/cifsauth)
username=
password=


Mount using command line

# mkdir /mnt/cifs

## using servername
# mount -t cifs //server-name/share-name /mnt/cifs -o username=shareuser,password=sharepassword,domain=YOUR_DOMAIN
## You may substitute  YOUR_DOMAIN with your HOSTNAME if you don't have a domain or you are using local account.

## You can also use IP address
# mount -t cifs //192.168.1.1/share-name /mnt/cifs -o username=shareuser,password=sharepassword,domain=YOUR_DOMAIN

##Mount with read-write
mount -t cifs //server-name/share-name  /mnt/cifs -o username=shareuser,password=sharepassword,domain=YOUR_DOMAIN,rw,file_mode=0777,dir_mode=0777



References:
  1. http://go-linux.blogspot.hk/2008/09/smbfscifs-filesystem-etcfstabuser-info.html
  2. http://pvalentino.blogspot.hk/2007/10/redhat-cifs-mounting-with-fstab-and.html
  3. http://www.cyberciti.biz/faq/linux-mount-cifs-windows-share/

Comments

Popular Posts