Linux (or UNIX in general) can share directories with other machines in a network with the NFS utilities. These are a set of programs (daemons) that might have been installed with you put Linux in your machine. How to make NFS work is a complicated matter that requires a post (or posts). In this post I will only explain how to configure the different options to share directories via NFS. I assume therefore that NFS runs in your machine when it boots.
The configuration file for NFS is /etc/exports There you write which directories have to be shared, with which machines, and the possible options. An example of an entry in that file is the following:
/usr/local/ host1.localnetwork.domain(rw)
This means that the host called host1.localnetwork.domain can access the directory /usr/local from the machine where you are working, and can read and write (rw) in it.
A general entry has the following format (there can be many entries in the file):
directory host(options)
Here directory is the directory from the local machine that you want to share across the network. The host is the name of the host or hosts that are allowed to access the given directory. You can put a single host as in the example above, or you could give a range with something like *.localnetwork.domain which means all hosts whose names end in localnetwork.domain. You can also put * which means any host connected to yours; it could be in the local network, or in any part of the world if you are connected to the Internet without any restricitions like firewall, so be carful when you use the star symbol (called a wild card). You can also specify the hosts with a combination of IP numbers and netmask (don’t worry if you do not know what I mean). For example, a host entry like 159.12.2.0/255.255.255.0 means all hosts with IP number from 159.12.2.1 to 159.12.2.254 This is equivalent to 159.12.2.0/24
Some options you can include are the following:
1. rw the machines authorised can read and write in the given directory
2. ro for read-only
3. async is a technical option that means when a client (a machine that has shared a directory from yours, say) writes something the server (your machine) will not wait for the file to be written in the hard disk and continue the "connection" with the client
4. sync is the opposite of the previous option: the server waits for files to be written to the disk before it informs to the client that the operation is done. If you do not put any of these two options the sync one will be assumed.
For more information you can look at the manual page of exports (man exports) or of the program exportfs. I will post on this program in the future, and more on NFS details too.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment