chapter6 2 omar
TRANSCRIPT
-
8/3/2019 Chapter6 2 Omar
1/26
CIT-315
OPERATING SYSTEM ADMINISTRATION
The Network File System
-
8/3/2019 Chapter6 2 Omar
2/26
Background2
A network file system is any computer file system
that supports sharing of files, printers and other
resources as persistent storage over acomputer
network. The first file servers were developed in the1970s, and in 1985 Sun Microsystems created the
file system called "Network File System" (NFS)
which became the first widely used network file
system. [Wikipedia]
-
8/3/2019 Chapter6 2 Omar
3/26
Transparency3
Ideally, anetwork file system should appear to its
users to be aconventional, centralized file system.
The multiplicity and dispersion of its servers and
storage devices should be made invisible, i.e. no
distinction between local and remote files.
It is up to the network file system to locate the files
and to arrange for the transport of the data.[Wikipedia]
-
8/3/2019 Chapter6 2 Omar
4/26
Performance4
The most important performance measurement of a
network file system is the amount of time needed to
satisfy service requests.
In conventional systems, this time consists of a disk-
access time and a small amount of CPU-processing
time.
[Wikipedia]
-
8/3/2019 Chapter6 2 Omar
5/26
Performance (contd)5
In a network file system, a remote access has
additional overhead due to the distributed
structure. This includes the time to deliver the
request to a server, the time to deliver the responseto the client, and for each direction, a CPU
overhead of running the communication protocol
software. [Wikipedia]
-
8/3/2019 Chapter6 2 Omar
6/26
Concurrent File Updates6
A network file system should allow multiple client
processes on multiple machines to access and update
the same files.
Updates to the file from one client should notinterfere with access and updates from other clients.
Concurrency control or locking may be either built
into the file system or be provided by an add-on
protocol. [Wikipedia]
-
8/3/2019 Chapter6 2 Omar
7/26
NFS Server Configuration Files7
There are 3 main configuration files to edit in
order to set up an NFS server:
/etc/exports
/etc/hosts.allow (security)
/etc/hosts.deny (security)
-
8/3/2019 Chapter6 2 Omar
8/26
The /etc/exports File8
This file contains a list of entries where each entry indicates:
Which volume to share
How is the volume to be shared
Format:
/dir1/dir2 host1(options) host2(options)
Example:
/another/exported/directory 192.168.0.3(rw,sync)
-
8/3/2019 Chapter6 2 Omar
9/26
Specifying the Host Name9
Either one of theses ways can be used to specify the
specify the host name:
The direct hostname or IP
Wildcards in the hostname, such as *.zu.ac.ae will
match all hosts that end in .zu.ac.ae
-
8/3/2019 Chapter6 2 Omar
10/26
Specifying the Options10
rw - Read and write access
ro - Read-only access
sync - Writes are committed to the disk without
delays. The data is safer; puts more strain on thesystem; By default it is turned off
no_root_squash - Trust the client's root account
-
8/3/2019 Chapter6 2 Omar
11/26
Rules for Exporting File Systems11
1. Any FS (or subset of an FS) can be exported
2. You cannot export a subdirectory of an FS where the FS
is already exported, unless the subdirectory is on a
different physical device.3. You cannot export the parent directory of an exported
FS, unless the parent is on different physical device.
4. You can only export local FS.
-
8/3/2019 Chapter6 2 Omar
12/26
NFS Daemons12
3 programs that provide NFS services:
rpc.portmapper - Maps calls made from other
machines to the correct NFS daemons. (Server & client)
rpc.nfsd - Translates NFS requests into actual requests
on the local filesystem. (server)
rpc.mountd - Services requests to mount and unmount
filesystems. (server)
-
8/3/2019 Chapter6 2 Omar
13/26
NFS Processes13
The following programs should be running:
portmapper , mountd, and nfs
To check for this:
$ rpcinfo pProgram vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100012 1 udp 821 mountd
100012 1 tcp 823 mountd100003 2 udp 2049 nfs
100003 2 tcp 2049 nfs
-
8/3/2019 Chapter6 2 Omar
14/26
Starting/Stopping NFS Processes14
To start NFS:
# /etc/init.d/nfs start
To stop NFS
# /etc/init.d/nfs stop
To check status:
# /etc/init.d/nfs status
-
8/3/2019 Chapter6 2 Omar
15/26
Re- exporting the File Systems15
# /usr/sbin/exportfs r
sends the appropriate signals to the rpc.nfsd and
rpc.mountd daemons to re-read the /etc/exports file
and update their internal tables
/usr/sbin/exportfs
Lists all exported file system
-
8/3/2019 Chapter6 2 Omar
16/26
Mounting an Exported File System16
To mount a filesystem, use the mount command:
# mount server:/exported/dir /dir/to/mount
serveris the name of the server from which you want to mounta filesystem,
/exported/dir is the directory listed in its /etc/exports file,and
/dir/to/mount is the location on your local machine where youwant to mount the filesystem.
-
8/3/2019 Chapter6 2 Omar
17/26
Options with the Mount Command17
Characteristic Description
rw Read/write
ro Read-only
bg Background mount intr Interruptible mount
soft client can return failure
retrans maximum retried transm
wsize write size rsize read size
-
8/3/2019 Chapter6 2 Omar
18/26
Example of Mount Command18
mount -o rw,bg,intr,soft,retrans=6 ser:/export/bin /bin
bg: should the initial mount fail, the mount process
places itself in the background and continue untilsuccessful
intr: if mount process is pending I/O on a mounted
partition, it is ok to interrupt
-
8/3/2019 Chapter6 2 Omar
19/26
Finding Mounted File Systems19
On the NFS server, use the following command to list
the set of clients who are mounting filesystems from it
# /usr/sbin/showmount
From the client, to find out the list of exported file
systems by a server:
# /usr/sbin/showmount e citserver
-
8/3/2019 Chapter6 2 Omar
20/26
Unmounting a File System20
For example, to unmount /mounted/fsys, you
can use:
# umount /mounted/fsys
If files are being used on a mounted filesystem, you
cannot unmount it.
All files must be closed before the unmount can be
done.
-
8/3/2019 Chapter6 2 Omar
21/26
Unmounting with Open Files?21
Use lsof N to find out information about files
opened by processes. Then you have 2 options:
Use umount f to force the filesystem to unmount
Bring system to single-user mode and then unmount the
filesystem
-
8/3/2019 Chapter6 2 Omar
22/26
Mounting File systems Automatically
22
You can use the file /etc/fstab to specify all the
partitions that need to be mounted at boot time
Example of /etc/fstab line entry:
server:/usr/local/pub /pub nfs
rsize=8192,wsize=8192,timeo=14,intr
-
8/3/2019 Chapter6 2 Omar
23/26
Remounting File Systems23
To remount the filesystems that are already listed in
the fstab file:
# mount -a
To remount a single filesystem that already has an
entry in the fstab file:
# mount /dir/to/mount
-
8/3/2019 Chapter6 2 Omar
24/26
The Automount24
One drawback to using /etc/fstab:
Regardless of how infrequently a user accesses theNFS mounted file system, the system must dedicateresources to keep the mounted file system.
Overall system performance may degrade whenthe system is maintaining mounts to a large numberof systems.
Alternatively, we can use the kernel-based
automount utility, to automatically mount andunmount NFS file systems, based on demand.
-
8/3/2019 Chapter6 2 Omar
25/26
To Setup Automount on a Client25
Adding this line to /etc/auto.master:
/export/home /etc/auto.home --timeout=120
Create a new file called /etc/auto.home and add
the following line:* -fstype=nfs,rw,hard,intr,rsize=2048,
wsize=2048,nosuid,nfsvers=3
citserver:/export/home/&
-
8/3/2019 Chapter6 2 Omar
26/26
Setting up Automount (contd)26
To start the auto-mounter daemon on the client:
# /etc/init.d/autofs start
Example of what the mount command will display:
automount(pid4633) on /export/home type autofs
(rw,fd=5,pgrp=4633,miniproto=2,maxproto=3)