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

















Tuesday, August 9, 2011

Simplest method to install latest Ruby on Rails(RoR) 3.x on Ubuntu(10.10)

Hi,

This is the post about installing latest RoR on Ubuntu10.10 using RVM(ruby version manager). Installing RoR using a RVM is the simplest method of all the methods because it has many advantages like you can control version while testing and it automatically resolves all the dependencies. Also plenty of help is available for using rvm.

At the end of article i have given all the commands you can copy paste into file and run it as a bash script it will do all the jobs for you.

 Follow the following steps,
install rvm using

 $bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

A>This  installs all the dependencies and the libraries

  # Dependencies for compiling Ruby
  $ sudo apt-get install curl bison build-essential autoconf zlib1g-dev libssl-dev libxml2-dev libreadline6-dev git-core subversion

  # openssl package for RVM
  $ rvm pkg install openssl

  # readline package for RVM
  $ rvm pkg install readline


B>this installs ruby , U can give version as 1.9.2 although

$rvm install 1.9.2-head -C --with-openssl-dir=$rvm_path/usr,--with-readline-dir=$rvm_path/usr

C>Test it  and use 1.9.2 as default version
 
$ rvm list
  =>
  rvm Rubies
  ruby-1.9.2-head [ x86_64 ]
  System Ruby
  system [ ]

  $ ruby -v
  => ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]

  $ rvm use --default 1.9.2
  => Using ruby 1.9.2 head

  $ ruby -v
  => ruby 1.9.2dev (2010-04-17 trunk 27376) [x86_64-linux]


4> Install sqlite(database and rails)
$sudo aptitude install libsqlite3-0 libsqlite3-dev  

$ gem install sqlite3-ruby
  $ gem install rails --pre
For detailed info you can visit this blog: http://rohitarondekar.com/articles/installing-rails3-beta3-on-ubuntu-using-rvm

Rohit has given nice explanation, And above instructions are taken from his blog.
Just remember that in rvm package has been replaced by pkg.


#This is the script to install the ruby1.9.2, rubygems1.8.6, rubyOnRails3.x
#author : rhaulpatil

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

# Dependencies for compiling Ruby
sudo apt-get install curl bison build-essential autoconf zlib1g-dev libssl-dev libxml2-dev libreadline6-dev git-core subversion

# openssl package for RVM
rvm pkg install openssl

# readline package for RVM
rvm pkg install readline

#this installs ruby , U can give version as 1.9.2 although
rvm install 1.9.2 -C --with-openssl-dir=$rvm_path/usr,--with-readline-dir=$rvm_path/usr

#list installed ruby packages
rvm list

#ruby version using
ruby -v

#use this version as default
rvm use --default 1.9.2
 
ruby -v 
 
# this installs develoment lib for sqlite otherwise of which gem install sqlite3-ruby will fail
sudo aptitude install libsqlite3-0 libsqlite3-dev  
 
#install sqlite-3 as a basic database
gem install sqlite3-ruby

#install the rails 3.x latest
gem install rails --pre