NFS
(Network File Sharing method for Linux Installation)
From Server
Note:
Put all Linux dump cd’s to the server in the directory path /var/ftp/pub
# vi /etc/exports
/var/ftp/pub
*(ro,sync) (For all the
client users access this directory ie [*])
Note: Assume if you want to share the
/var/ftp/pub to particular client, the command as follows:
/var/ftp/pub 192.168.10.2
/255.255.255.0 (rw,sync)
(Read /Write access permission)
:wq!
#
exportfs –r (read all shared directories)
#
exportfs –av (append and verbose all shared directories)
#
service nfs start / restart
#
service portmap start / restart
To Client
Note
: Put the Linux 1st cd to the client machine and boot. Follow the
commands.
boot : linux askmethod
Linux installation through network
1)NFS
image
ii)HARDDRIVE
2)FTP
3)HTTP
4)CDROM
Select NFS image
Servername : server1.example.com (or) 192.168.0.20 – server ip
Redhat Dir : /var/ftp/pub
Now
the installation starting
NFS (Network File Sharing for some folders
Some
examples mounting through NFS
#
vi /etc/exports
/mnt/cdrom
*(ro,sync)
/mnt/floppy
*(rw,sync)
/home/user2
*(ro,sync)
:wq!
#
exportfs –r (read all shared directories)
#
exportfs –av (append and verbose all shared directories)
#
service nfs restart
#
service portmap restart
To Client
#
showmount –e 192.168.10.1
#
mount 192.168.10.1:/var/ftp/pub /data1
#
mount 192.168.10.1:/mnt/cdrom /data2
#
mount 192.168.10.1:/mnt/floppy /data3
# cd /data1
# ls
# cd /data2
# ls
#
cd /data3
#
ls
NFS Overview
File
sharing service.
RPC
based service, so it requires Portmap.
Packages:
·
nfs-utils
Provides:
nfsd - Provides userland portion of NFS service.
lockd - NFS lock manager (kernel module)
rpciod -
rpc.mountd - Provides mounting services.
rpc.rquotad - Returns quota information.
rpc.statd - Used by lockd to recovery locks after a
server crash.
·
portmap
Provides
portmap program. Portmap maps calls made by other hosts to the correct RPC
service. Because portmap is compiled with tcp wrappers support (libwrap), those
that need to access portmap must be given access via /etc/hosts.allow and/or
/etc/hosts.deny.
Ports
·
TCP/UDP 111 - portmap
·
UDP 2049 - nfsd
·
The other NFS related services vary in the
port numbers they use. Clients contact portmap to find out the port number the
other RPC services use.
Required Services
Listed
in startup order:
·
NFS Server
portmap
nfs
·
NFS Client
portmap
nfslock
Configuration
/etc/exports
·
NFS server configuration file.
·
Format:
It is
critical that there not be any spaces
between the host/network and it's options.
·
Example:
#
Allow all hosts in the somewhere.com domain to mount /var/ftp/pub read-only
/var/ftp/pub *.somewhere.com(ro)
#
Allow all hosts to mount /var/www/html read-only and allow certain hosts
#
mount it read-write
/var/www/html
*(ro) 192.168.1.0/255.255.255.0(rw) 192.168.2.10(rw)
#
Allow certain hosts to mount /usr read-only and another read-write as root
/usr 172.16.0.0/255.255.0.0(ro)
172.16.1.10(rw,no_root_squash)
#
Allow access to /usr/local by everyone, but only as the anonymous user
/usr/local *(ro,all_squash,anonuid=100,anongid=100)
·
Restrictions
Root can't mount an nfs share as root unless
no_root_squash is used. Normally when root mounts a share, NFS maps root to the
local user nobody.
You can't export a directory that is a parent or child of
another exported directory within the same file system.
e.g.
You can't export both /usr and /usr/local unless /usr/local is a separate file
system.
·
Common Export Options
no_root_squash -
Remote hosts can access local shares as root (Dangerous!)
ro - Read-only
rw - Read/Write
sync - All file system writes must be
committed to disk before the request can be completed.
all_squash - All remote users are mapped to a local
anonymous user.
anonuid - Specify the uid to user for anonymous
access.
anongid - Specify the gid to user for anonymous
access.
/etc/fstab
·
Used for NFS client configuration
·
Example:
server:/usr /usr
nfs
user,soft,intr,rsize=8192,wsize=8192
0 0
·
Common NFS related mount options
soft - Processes return with an error on a
failed I/O attempt
hard - If a process tries to access an
unavailable share, it will hang until data is retrieved.
intr - Allows NFS requests to be interrupted or
killed if the server is unreachable
nolock - Disable file locking in order to work with
older NFS servers
rsize - Sets the number of bytes NFS reads from a
share at one time (default 1024)
wsize - Sets the number of bytes NFS writes to a
share at one time (default 1024)
* Setting rsize and wsize to 8192
greatly increases performance.
Auto Mounting NFS shares
Requires
autofs package to be installed.
Create
entry in /etc/auto.misc for the NFS share:
ftp -fstype=nfs,intr,soft 192.168.1.20:/var/pub/ftp
If
the default autofs setup is used, whenever someone accesses /misc/ftp, the
remote NFS share on 192.168.1.20 will be automatically mounted. The options
specified in the /etc/auto.misc have the same meaning as when they are used in
/etc/fstab.
NFS Utilities
exportfs
·
Used to maintain the table of exported file
systems.
·
Example Usage:
exportfs
-r # Refresh the share listing after modifying
/etc/exports.
# This MUST be done in order for
your changes to take effect.
exportfs
-v # Display a list of shared directories
exportfs
-a # Exports all shares listed in /etc/exports
# To
export a filesystem not in /etc/exports
exportfs
192.168.1.0/255.255.255.0:/tmp
#
Unexport a filesystem
exportfs
-u 192.168.1.0/255.255.255.0:/tmp
showmount
·
Show mount information for an NFS server.
·
Does not require that any local NFS services
be running in order to use it.
·
Example Usage:
showmount
-e 192.168.1.67 # Shows available shares
on host 192.168.1.67
showmount
-a 192.168.1.67 # Shows the clients
connected to host 192.168.1.67
# and the shares
they have mounted.
rpcinfo
·
Reports RPC information.
·
Can determine if RPC services are running on
a host.
·
Example Usage:
rpcinfo
-p 192.168.1.77 # Display list of RPC
services running on 192.168.1.77
No comments:
Post a Comment