Tuesday, January 24, 2012

How NFS Works?

How Does It Work?

Well, beyond the business of filehandles, there is the entire protocol of how the NFS clients and servers actually talk to each other. The main parts of the communication between the client are the nfs client software, and the portmapper, the mountd and the NFSd on the server. There are four main steps to getting an NFS mount to happen. Lets say that there is an NFS server that is exporting /users/jey/, and that we are looking for /users/jey/linux.doc:

1. The client software asks the server's portmapper, "Hello NFS server, what port number can I find mountd at?" To which the server replies, "Hello NFS client, please ask on port number 923." Now, the NFS client knows that if it wants to mount (use an NFS share) something, it will need to ask the mountd on port 923 for it.

2. The NFS client then asks the mountd "Hello NFS mountd, what is the filehandle for export: /users/jey?" The server responds with the filehandle.

3. With this filehandle, the client then asks the portmapper for the NFS port "Hello portmapper, what is the NFSd that is to be used with /users/jey?" The server responds with the port number assigned to it.

4. The NFS client then contacts the server's NFSd on the port it received in step 3, and says "Here is the filehandle, and I'm looking for linux.doc" The NFSd replies with the filehandle for the object.

The remote NFS system can now talk with the NFSd and can perform file operations using the provided filehandle.

The Stateless File system:

What makes NFS such a powerful file protocol is that it is stateless. Being stateless means that at no time do either the client or server go into a state that depends on further information. This means that either the NFS client or the NFS server can physically reboot, and once restarted, the communications can happen again.

Reference:

#man 8 rpcd.mountd
#man 8 rpcd.nfsd
#man exportfs
#man exports

Export options:

root_squash : Map requests from root user to anonymous user
no_root_squash : Dont root_squash
all_squash : Map all users to anonymous users

Saturday, December 24, 2011

How files are stored/retrieved in ext2 filesystem

The space in ext2 is split into blocks. Block is sequence of bits and bytes. These blocks are grouped into block groups.

+------------------------+------------+---------------------+------------+
|Boot Sector|Block Group1|.....................|Block Groupn|
+------------------------+------------+---------------------+------------+

Each block group contains Super block, Filesystem Descriptor, Block bitmap, Inode bitmap, Inode table, Data blocks. Inode contains file permission, ownership, size and its location on the disk.

When a new file is created, the ext2 FS tries to put the file in its parent directory's block group so referencing is easy. If no block is free in the block group, then FS will place the file in new block group.

If you run ls or find command to list/search a particular file, the command inturn reads /proc/mounts file to get the list of mounts and calls getdents64 system call to get the struct linux_dirents which will get the directory/file starting with the parent of the given directory/file.

External reference: http://en.wikipedia.org/wiki/Ext2; http://linux.die.net/man/2/getdents64

Monday, July 13, 2009

Pearl Millet Fields


I got stuck with a tight schedule of 4 months and unable to publish any posts. Recently i have visited my village where i saw pearl millet fields which was looking beautiful. Then i google'd about the millet cultivation and found that African countries cultivate millet in large numbers.

Millet consumption was high during olden days where the people led a healthy life. Now a days these sort of grain consumption is very less and consumed as medicines or health drinks with various ingredients and preservatives.

Saturday, February 28, 2009

Pumping station


Age old water pumping station:
Age old typical water pumping station build during british rule in india. Ages ago there were no electric motors in use to water plants or crops. Only diesel engines were used to suck the water from the river. The disadvantage of diesel engines were not powerful enough to pump the water to a longer distance. So our grandpa's decided to built a station which can pump the water with out any mechnical device. As a result, the below shown pumping station was designed and built.

Pumping station working concept:
Water will be sucked from the river using diesel engine and hiked to the top of the pumping station which has a small tank at the top which will then release the water. The speed of the released water was speed enough to reach a longer distance.

Day before the Harvest

149th Day of my Paddy field: