Saturday, September 3, 2011

Mounting Windows Share on the linux


Hi All,

I have explained the procedure of mounting Windows share on Linux with full permissions so that you can read,write,edit the files with full permissions. If you do normal mount editors like vim, utilities like cscope will not works correctly, so its necessary to mount the share with correct options and permissions for which you may need to compile the kernel with correct config setting which are explained below.

Why:
My this post is dedicated to all the developers who use linux to edit the source code files for the windows projects, i mean, when you use linux for editing files by mounting windows share on linux. This saves your lot of time while compiling source code on windows.If you keep your database on linux and try to compile on windows it takes around 6 times more time to compile, when machines are in LAN(its just my experience), and if your project is too big then it will take more than. So its better to keep source code on the machine on which compilation is done, rather on the machine where you edit the files.

For ubuntu 12.04 directly follow step 3, step 1 and 2 are only for old ubuntu release.

1> Linux kernel settings
while compiling kernel please enable following options in the .config file.
This is must other wise call to mount.cifs will fail
      a>  FUSE (dont know whether it is must)
      b> SAMBA File System
      c> CIFS File System(with the xattr and POSIX new support, which is must as i think, these are sub-options under cifs)
     
2> Windows settings
As i think there is inbuilt support for CIFS on windows-xp(atleset its on my pc)
      a> Share the folder with maximum permission(read, write, special permission whatever you can) to everyone.
     
3> mounting using cifs
i have shared my  D drive on windows, which i have mounted under directory /home/rahul/mnt. Using command

if mount.cifs gives error command not found please install it by
sudo apt-get install cifs-utils
sudo aptitude install cifs-utils
sudo yum install cifs-utils

$sudo mount.cifs //192.168.92.44/D$ /home/rahul/mnt -o user=rahul.patil,pass=password,rw,uid=rahul,gid=rahul,noserverino

above command sometimes causes to mount in only read mode, so use real uid and gid numbers instead of names to mount in read write mode.


$sudo mount.cifs //192.168.92.44/D$ /home/rahul/mnt -o user=rahul.patil,pass=password,rw,uid=1000,gid=1000,noserverino



 a generalize command would be:

sudo mount.cifs //<ip_addr_or_name_of_windows_mc>/<share_name>  <mount_dir_on_linux> -o user=<windows_user_login_name>,pass=<passwrd_of_windws_login>,rw,uid=<linux_use_name_or_id>,gid=<linux_goup_name_or_id>,noserverino


Errors while mounting the drive or suddenly you find that ls is not showing files/folders in the directory on target(Linux) machine:

1>  You may get this error while remounting the drive on target(Linux) machine

 [sudo] password for rahul:
mount error(12): Cannot allocate memory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

2> mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Dmesg could help you in above error

#dmesg
[  313.232501]  CIFS VFS: Send error in SessSetup = -13
[  313.232507]  CIFS VFS: cifs_mount failed w/return code = -13
[  314.293943] Status code returned 0xc0000234 NT_STATUS_ACCOUNT_LOCKED_OUT

if dmesg shows above error then your windows account is locked out. Please unlock your windows account or ask administrator to unlock it. 

I dont know root cuase of the error, but the solution is restart the host(windows) machine.

3> Mount is only in read mode and shows root.root as owner and group for all the files
3.1 rather than giving user_name and group_name use uid and gid


Feel free to contact me if u found error @
rahul.deshmukhpatil@gmail.com

















No comments:

Post a Comment