06 NFS
06 NFS
Implementing NFS
• Distributed File • Configuring Server
Systems Daemons
• NFS • /etc/exports
• Ports and Network • autofs
• Sharing home
Conversations
• Destination and Return directories in the
Ports Lab
• RPC-based Services • /etc/auto.home
Distributed File Systems
• Most networks have a central place where files are kept
and are available to any machine on the network
o This is a necessity whenever people work together
o If
you work in an office, you may have some files on your
own PC
o However, the files for your projects may reside on a file
server where anyone on your team can access them
• There are technologies that allow machines to make
their files available to anyone on the network, forming a
distributed file system 2
Distributed File Systems
• Our CS LAN has such a distributed file system
o You can log into any machine on the network, and you will
always land in your home directory…
o …even though you are not connected to the machine whose
hard drive has your home directory
o Your home directory lives on the hard disk of some network
machine…
o …but this disk is mounted whenever you log in to any
machine on the network!
3
Distributed File Systems
• There are two major file server packages that are
commonly used on Linux:
▪ Network File System (NFS)
▪ Samba
• Samba allows files to be shared between Linux and
Windows machines
• NFS only works on Linux
4
NFS
• Again, "NFS" stands for Network File System, and
it only works on Unix and Linux
o NFS allows each machine on the network to make some of
its directories available to other machines
o Unix and Linux have NFS as part of the kernel
• After you finish the first part of Project 3, every VM will
be both
o an NFS server and…
o an NFS client
NFS
• This means that each team will perform the setup for
both the client and server components of NFS
o Each machine will make the home directories for its users
available to other machines when you log into them
o Therefore, the home directories created on one virtual
machine will be available on all the other virtual machines
• NFS makes it seem like all shared directories are part of
one big file system.
• It does this through mount points
NFS
• A mount point is a directory on your machine where
other shared directories will appear as if they were
actually part of your local file system
• Directories used as mount points should be empty
• Shared NFS directories can be
o mounted automatically when the machine is booted or…
o made available from the command line – using the mount
command
Ports and Network Conversations
• Every machine on a network needs services from other
machines
o Web pages, file access, configuration info, etc.
o All of these services involve communication over the
network
• This communication takes place using packets
o Packets are chunks of information – sent out over a network
– that allow two computers to communicate
o When a file is transferred over the network, it is broken up
into multiple packets
Ports and Network Conversations
• On the Internet, there are two major packet protocols
➢ TCP: Transmission Control Protocol
➢ UDP: User Datagram Protocol
• UDP is simpler than TCP
o TCP establishes a connection between two machines
o UDP does not
• “Connection” means that packets can keep going back and
forth, as long as one machine needs the other's services.
• So most network services use TCP
Ports and Network Conversations
• Knowing the IP address of the machine providing a
service is not enough because you may need multiple
services from that machine
• For example it20 provides several services to each
machine on the IT Lab network
o DHCP o NIS
o DNS o ssh
• All these services are available SIMULTANEOUSLY
• When you need a particular service from it20, it is
not enough to simply send a packet to 10.0.0.1
Ports and Network Conversations
• How is a machine like it20 supposed to know what to
do with the packet it gets from your virtual machine?
• In order to allow a given host to provide more than
one service, you must provide additional information
in the packet -- a port
• A port is
➢ A communication channel
➢ At a specific IP address
➢ On a specific machine.
Ports and Network Conversations
• Ports are identified by their port number
o To get a service from another machine, you need its IP
address and the port number
o The combination of an IP address, a port, and the protocol
used is called a socket
• Port numbers from 0 to 1023 are special
o They are known as the well-known ports
o The well-known ports are given to widely used network
services, such as port 80 for a web server
o On Linux, only root can start a process that uses a well-
known port
Destination and Return Ports
• Two computers communicate by exchanging packets,
addressed to a specific port, at a specific IP address
• This is called a socket
• For most network services, the communication goes in
two directions
o Therefore,
when a client sends a packet to a server, it has to
have a destination socket, consisting of the server's IP
address and the port number for that particular service
o But
it also has to provide a return socket, where it can receive
packets back from the server
Destination and Return Ports
• The port number for the return socket is NOT the same
as the destination port number
o This allows your machine to get packets from multiple servers
o For
example, your browser can be receiving packets
simultaneously from many different web servers, even
though each server is listening on port 80
• Server ports are standardized, but clients pick their
return ports at random to receive packets from the
server
RPC-based Services
• NFS has been around in the Unix world for a long time –
so long in fact that it does not use network ports, which
came into common use long after Unix was created
• NFS uses a technology called remote procedure calls,
which allow a user on one computer to run a program
on another computer
• Instead of port numbers, RPC services use program
numbers, each of which is assigned to a specific
daemon
RPC-based Services
• On modern versions of Unix, these program numbers
have to be converted to Internet port numbers
• This is done through a an RPC port map program, which
runs as a background process on all Linux/Unix
machines
• When an RPC-based service like NFS is started, it tells
the port mapper what RPC program number it is using
• When another machine needs to use the service, it
contacts the port mapper on the machine providing the
service to learn the port number it should use
RPC-based Services
• Once the machine knows the port number, it creates a
remote procedure call and wraps it up in a TCP packet
sent the server
• This is knows as tunneling
• To find out what RPC program numbers are mapped to
which ports use the command rpcinfo -p
Configuring Server Daemons
• NFS provides its services through a number of
daemons, using software contained in two Ubuntu
packages
nfs-kernel-server
nfs-common
• The nfs-kernel-server package contains software
for daemons that provide the basic NFS services
• The nfs-common package contains software for the
daemons that help the nfs-kernel-server daemons
do their job
18
Configuring Server Daemons
• The configuration file for these daemons is
/etc/default/nfs-kernel-server
• The installations, that you will perform for NFS, will
automatically configure all these daemons to run when
you boot your virtual machine
• In addition, you will need to configure your VM...
1. As a server, to share your personal homes to the network
2. As a client, to mount other users' homes
19
/etc/exports
• Here, you are configuring your VM as an NFS server.
• If a machine wants to share a directory through NFS, it
must make an entry in /etc/exports
• Therefore, there will be a line in this file for each
directory you are sharing
• Each line will have the same format:
DIRECTORY_PATHNAME HOST(OPTIONS)
• DIRECTORY_PATHNAME is the absolute pathname of
the shared directory on your virtual machine
/etc/exports
• HOST is the machine or machines that can access the
shared directory – i.e., the whom
• You can specify the host in many ways
o By the hostname (only for machines inside the network)
o By the IP address for a machine
o All the machines in a specific network or subdomain
• We will use the last format in today's project
• OPTIONS specify how the directory is to be shared
/etc/exports
• Some of the more important options are:
ro Files in directory are read only
Files in directory can be changed if you have the proper
rw permissions
The root account on another machine does not have root
root_squash powers in this directory
Changes to the files are written to disc before another uses
sync accesses the file
Does not check permissions on parent directories of shared
no_subtree_check directories