Monday, May 14, 2012

autofs - auto mounting on Linux and Mac

I broke my head by working on weekend just to find out the way to do auto mounting of NFS file server on a Fedora and Mac book. Please follow the steps below to be head safe :P.

On Mac(10.6.8) -->

1. Open DirectoryAccess utility from  /System/Library/Core services/Directory Utility

2. select "BSD Flat File and NIS"

3. select edit

4. Domain name : mydomain.net
    Servers:  amt-admin1.mydomain.net
                  amt-admin2.mydomain.net

5.check "Use NIS domain for auth."

6. write following in /etc/auto_master

/homes auto.homes_amt  -resvport
/volume  auto.vols_amt  -resvport

7. restart autofs daemon as 
sudo launchctl stop com.apple.autofsd
sudo launchctl start com.apple.autofsd







On Linux (Fedora 13) -->



1. add "mydomain.net" in search row in /etc/resolv.conf file

it will look like -
====================================
[akashmahan@team lib]$ cat /etc/resolv.conf
# Generated by NetworkManager
domain mydomain.net
search domain.net  mydomain.net
nameserver 100.206.194.55
nameserver 100.209.194.55
====================================

2.  system --> administration -> authentication....
 Add your laptop to NIS domain

OR  modify /etc/yp.conf  to look like as --
======================================
[akashmahan@team lib]$ cat /etc/yp.conf
# generated by /sbin/dhclient-script
domain mydomain.net server 100.209.194.131
======================================

3. modify /etc/auto.master to look like
=====================================

[akashmahan@team lib]$ cat /etc/auto.master
/net    /etc/auto.net
/volume yp:auto.vols_amt       -intr,bg,tcp
/homes  yp:auto.homes_amt  -intr,bg,tcp

====================================

4. Restart ypbind and autofs as -
====================================
/etc/init.d/ypbind restart
/etc/init.d/autofs restart
====================================


Above procedures will mount the NFS server file system on your laptops. e.g my NFS file server /volume directory will be mounted on /volume directory of my laptop. If you do a "ls" in "/volume" directory on laptop, you will find nothing. You need to do a cd to specific directory then only that will be mounted.





Friday, June 24, 2011

FreeBSD Processes getting stuck in "pipewr" state

I have one FreeBSD installed server. I installed JRE on it for my java development. I wrote a simple java program that will call some freeBSD scripts on the server. So, my java code was looking as below-

+++++++++++++++++++++++++++++++++++++++++++++++++++

String [] cmd = {"/bin/sh", "-c", "someScript"};
Process proc = Runtime.getRuntime.exec(cmd);
+++++++++++++++++++++++++++++++++++++++++++++++++++

so, when I ran "top" command on the console of my freeBSD server, then I got following output
===========================================================================
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
34200 mahak 1 118 0 37172K 33320K pipewr 5 70.4H 100.00% someScript
82189 jaibhi 32 72 0 957M 11988K CPU2 7 0:00 100.00% java
60975 root 1 -8 0 5176K 3244K CPU1 4 22:44 0.98% find
===========================================================================

as you can see, "pipewr" in italics..is the state of the process. someScript got stuck in "pipewr" state for long time. This is because my Java process is forking another process i.e "someScript". And someScript when executed directly then it prints some output on console. So, when someScript is forked from a java process, then a pipe is created between java and someScript. Since, someScript is trying to write back the output to this pipe, it doesn't find proper stream or redirection for writing its output.

so, there are two solutions to this problem-
1. Modify the "String [] cmd = {"/bin/sh", "-c", "someScript"};" line of code to "String [] cmd = {"/bin/sh", "-c", "someScript > tempFile "};".
By doing this we are redirecting the output of someScript to a tempFile. So, someScript will never ever stuck in "pipewr" state
2. create java IO streams to read the output given by execution of someScript.

Friday, May 6, 2011

Laptop touchPad stops working on Ubuntu

Hi all,

If your laptop's touchpad stops working on Ubuntu then try following steps-
1. vi ~/ .gconf/desktop/gnome/peripherals/touchpad/%gconf.xml

2. set the value of "touchpad_enabled" attribute to "true". save and close the file

3. Run -
$ killall gnome-session


-akash

Friday, January 14, 2011

Akash Mahakode: Linux : Provide password to sudo on same prompt

Akash Mahakode: Linux : Provide password to sudo on same prompt: "Hi All, As we know whenever we need to execute some script/program on Mac/Linux with root permissions for a user, then we run that script wi..."

Thursday, January 13, 2011

Linux : Provide password to sudo on same prompt

Hi All,

As we know whenever we need to execute some script/program on Mac/Linux with root permissions for a user, then we run that script with "sudo". E.g

$sudo ./some_script
password:

After execution of the command on terminal, a password prompt comes and waits for user to provide password. I have been searching for the methodology that will not wait for password prompt. Because lots of coding efforts needs to be provided to provide password on "password" prompt.
So, the solution is simple, just type -

$ echo password | sudo -S ./some_script

I have sudo 1.7.0 version installed on my Ubuntu machine.
This will not wait for the password prompt and you would be able to run ./some_script with sudo permissions.