Saturday, April 09, 2011

Mounting windows shared drives in linux CIFS

This question comes again and again every time I ask for such a simple thing: Please use this windows network share to read/write files from a Linux server. Mounting CIFS in linux is easy.

First be sure you have smbfs installed. The below command should return a path identifying where the command is. This is needed so the mount command accepts a credentials file where Windows credentials are stored:
$ sudo find / -name  "mount.cifs"
/sbin/mount.cifs

Here is how to install it in Ubuntu:
$ sudo aptitude install cifs-utils

After that just follow the below steps, adapting them to your environment paths to get the Windows path mounted in Linux:
$ mkdir /mnt/linuxDirectory
$ mkdir -p /root/projects/cifs/
$ vi /root/projects/cifs/mount.txt
username=windowsUserName
password=windowsPassword
$ vi /etc/fstab
//windows.machine/volume/or/path/to/folder /mnt/linuxDirectory cifs auto,users,credentials=/root/projects/cifs/mount.txt,domain=windowsDomain,file_mode=0600,dir_mode=0700,uid=linuxUser,gid=linuxUser
$ mount /mnt/linuxDirectory
$ ls /mnt/linuxDirectory

No comments:

Followers