+ All Categories
Home > Documents > Introduction to the Network File System (NFS)

Introduction to the Network File System (NFS)

Date post: 04-Feb-2022
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
76
Summer 2006 Introduction to the Network File System (NFS) What was life like before NFS? CIS 4407
Transcript
Page 1: Introduction to the Network File System (NFS)

Summer 2006

Introduction to the Network File System(NFS)

☞ What was life like before NFS?

CIS 4407

Page 2: Introduction to the Network File System (NFS)

Summer 2006

Introduction to the Network File System(NFS)

☞ NFS is built on top of:

➳ UDP - User Datagram Protocol (unreliable delivery)

CIS 4407

Page 3: Introduction to the Network File System (NFS)

Summer 2006

Introduction to the Network File System(NFS)

☞ NFS is built on top of:

➳ UDP - User Datagram Protocol (unreliable delivery)

➳ XDR - eXternal Data Representation (machine

independent data format)

CIS 4407

Page 4: Introduction to the Network File System (NFS)

Summer 2006

Introduction to the Network File System(NFS)

☞ NFS is built on top of:

➳ UDP - User Datagram Protocol (unreliable delivery)

➳ XDR - eXternal Data Representation (machine

independent data format)

➳ RPC - Remote Procedure Call

CIS 4407

Page 5: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

☞ “mount” protocol establishes initial link between client

and server machines

CIS 4407

Page 6: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

☞ NFS protocols provide a set of RPCs for remote file

operations

CIS 4407

Page 7: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

☞ NFS protocols provide a set of RPCs for remote file

operations

➳ Searching a directory

CIS 4407

Page 8: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

☞ NFS protocols provide a set of RPCs for remote file

operations

➳ Searching a directory

➳ Reading a set of directory entries

CIS 4407

Page 9: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

☞ NFS protocols provide a set of RPCs for remote file

operations

➳ Searching a directory

➳ Reading a set of directory entries

➳ Manipulating links and directories

CIS 4407

Page 10: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

➳ Accessing file attributes

CIS 4407

Page 11: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

➳ Accessing file attributes

➳ Read and writing files

CIS 4407

Page 12: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

➳ Accessing file attributes

➳ Read and writing files

➳ Notably missing are open() and close()

CIS 4407

Page 13: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

➳ There is no equivalent to UNIX file tables on the server

side (therefore NFS is stateless on the server side)

CIS 4407

Page 14: Introduction to the Network File System (NFS)

Summer 2006

Two protocols - mount protocol and NFSprotocols

➳ There is no equivalent to UNIX file tables on the server

side (therefore NFS is stateless on the server side)

➳ Each request must provide full set of arguments

including a unique file identifier and offset

CIS 4407

Page 15: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

☞ Performance (even with UDP)

CIS 4407

Page 16: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

☞ Performance (even with UDP)

➳ Modified data may be cached locally on the client

CIS 4407

Page 17: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

☞ Performance (even with UDP)

➳ Modified data may be cached locally on the client

➳ Once the cache flushes to the server, the data must

be written to disk before results are returned to the

client and the cache is flushed

CIS 4407

Page 18: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

☞ File write operation semantics

CIS 4407

Page 19: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

☞ File write operation semantics

➳ UNIX semantics (without NFS)

CIS 4407

Page 20: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

☞ File write operation semantics

➳ UNIX semantics (without NFS)

➠ Writes to an open file are visible immediately to other

users who have the file open at the same time

CIS 4407

Page 21: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

☞ File write operation semantics

➳ UNIX semantics (without NFS)

➠ Writes to an open file are visible immediately to other

users who have the file open at the same time

➠ The file is viewed as a single resource

CIS 4407

Page 22: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➳ Session semantics (ala Andrew file system)

CIS 4407

Page 23: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➳ Session semantics (ala Andrew file system)

➠ Writes to an open file are not visible to others having

it open at the same time

CIS 4407

Page 24: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➳ Session semantics (ala Andrew file system)

➠ Writes to an open file are not visible to others having

it open at the same time

➠ Once a file is closed the changes are visible only in the

sessions opened later

CIS 4407

Page 25: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➳ NFS claims to implement UNIX semantics

CIS 4407

Page 26: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➳ NFS claims to implement UNIX semantics

➠ there are two client caches: file blocks and file

attributes

CIS 4407

Page 27: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➳ NFS claims to implement UNIX semantics

➠ there are two client caches: file blocks and file

attributes

➠ cached attributes are validated with server on an open()

CIS 4407

Page 28: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➳ NFS claims to implement UNIX semantics

➠ there are two client caches: file blocks and file

attributes

➠ cached attributes are validated with server on an open()

➠ the biod process implements read-ahead and delayed-

write techniques

CIS 4407

Page 29: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➠ newly created files may not be visible to other sites for

up to 30 seconds

CIS 4407

Page 30: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➠ newly created files may not be visible to other sites for

up to 30 seconds

➠ it is indeterminant whether writes to a file will be

immediately seen by other clients who have the file open

for reading

CIS 4407

Page 31: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➠ newly created files may not be visible to other sites for

up to 30 seconds

➠ it is indeterminant whether writes to a file will be

immediately seen by other clients who have the file open

for reading

➠ If a single NFS stat() request hangs, it can hang up

UNIX commands, like “df”!

CIS 4407

Page 32: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➠ “magic cookies” (random numbers) used to short-cut

future validations. Given to client from server, client can

use it to re-connect whenever a server comes back up

after a crash.

CIS 4407

Page 33: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

Network File System, FSINFO Call DH:0x75867c04Program Version: 3V3 Procedure: FSINFO (19)object

length: 12hash: 0x75867c04type: Linux knfsd (new)version: 1encoding: 0 0 0

auth_type: no authentication (0)fsid_type: major/minor/inode (0)fileid_type: root (0)

authentication: nonefile system ID: 3,2 (inode 4112441)

major: 3minor: 2

CIS 4407

Page 34: Introduction to the Network File System (NFS)

Summer 2006

inode: 4112441file ID: root inode

CIS 4407

Page 35: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➠ The original NFS protocol can be spoofed (no

encryption nor authentication). The first attempts to

add authentication were not all that good (see USAH p.

492).

CIS 4407

Page 36: Introduction to the Network File System (NFS)

Summer 2006

NFS problems

➠ The original NFS protocol can be spoofed (no

encryption nor authentication). The first attempts to

add authentication were not all that good (see USAH p.

492).

➠ Note that “stale cookies” can make a client hang

(solution: remount the filesystem on the client to make

it get a new, fresh cookie).

CIS 4407

Page 37: Introduction to the Network File System (NFS)

Summer 2006

What are the differences in v2 and v3?

See RFC1813 http://www.ietf.org/rfc/rfc1813.txt for

a full descript of v3. There is a good summary at

nfs.sourceforge.net of the differences in v2 and v3:

☞ In v2, clients can access only 2 gigabytes of a file. In

v3, much larger (64 bit)

CIS 4407

Page 38: Introduction to the Network File System (NFS)

Summer 2006

What are the differences in v2 and v3?

See RFC1813 http://www.ietf.org/rfc/rfc1813.txt for

a full descript of v3. There is a good summary at

nfs.sourceforge.net of the differences in v2 and v3:

☞ In v2, clients can access only 2 gigabytes of a file. In

v3, much larger (64 bit)

☞ v3 supports larger reads and writes

CIS 4407

Page 39: Introduction to the Network File System (NFS)

Summer 2006

What are the differences in v2 and v3?

☞ Idea of “Weak Cache Consistency” introduced in v3 to

help detect if modifications are happening to an object

(file or directory).

CIS 4407

Page 40: Introduction to the Network File System (NFS)

Summer 2006

What are the differences in v2 and v3?

☞ Idea of “Weak Cache Consistency” introduced in v3 to

help detect if modifications are happening to an object

(file or directory).

☞ Server-based access checks

CIS 4407

Page 41: Introduction to the Network File System (NFS)

Summer 2006

What are the differences in v2 and v3?

☞ v3 supports “safe asynchronous writes”, where a server

is permitted to reply before it has synced data to the

drive.

CIS 4407

Page 42: Introduction to the Network File System (NFS)

Summer 2006

Starting NFS on Linux

[root@sophie root]# more /etc/exports#/home/exports monet.cs.fsu.edu(ro,no_root_squash,insecure)

[root@sophie root]# /etc/init.d/nfs startStarting NFS services: [ OK ]Starting NFS quotas: [ OK ]Starting NFS daemon: [ OK ]Starting NFS mountd: [ OK ]

[root@sophie root]# /etc/init.d/iptables stopFlushing firewall rules: [ OK ]Setting chains to policy ACCEPT: filter [ OK ]Unloading iptables modules: [ OK ]

CIS 4407

Page 43: Introduction to the Network File System (NFS)

Summer 2006

Starting NFS on Linux

On the client side:

mount sophie:/etc/exports /mnt-tmp

CIS 4407

Page 44: Introduction to the Network File System (NFS)

Summer 2006

Starting NFS on Linux

What is actually done when on a Linux machine when

you run /etc/init.d/nfs

exportfs # /etc/exportsrpc.rquotadrpc.nfsdrpc.mountd

CIS 4407

Page 45: Introduction to the Network File System (NFS)

Summer 2006

Starting NFS on Solaris

shareall # /etc/dfs/dfstab, not /etc/dfs/sharetabmountdnfsd

CIS 4407

Page 46: Introduction to the Network File System (NFS)

Summer 2006

NFS Security

☞ Don’t export to hosts for which non-trusted users have

root access.

CIS 4407

Page 47: Introduction to the Network File System (NFS)

Summer 2006

NFS Security

☞ Don’t export to hosts for which non-trusted users have

root access.

☞ If you don’t control root on the machine then don’t

export the file system.

CIS 4407

Page 48: Introduction to the Network File System (NFS)

Summer 2006

NFS Security

☞ Don’t export to hosts for which non-trusted users have

root access.

☞ If you don’t control root on the machine then don’t

export the file system.

☞ Block NFS traffic at your router/firewall, if possible.

CIS 4407

Page 49: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

☞ You can adjust the number of nfsd (and biods, if

system uses biod)

CIS 4407

Page 50: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

☞ You can adjust the number of nfsd (and biods, if

system uses biod)

☞ Use nfsstat -c to see client-side NFS traffic

CIS 4407

Page 51: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

☞ You can adjust the number of nfsd (and biods, if

system uses biod)

☞ Use nfsstat -c to see client-side NFS traffic

☞ Use nfsstat -s to see server-side NFS traffic

CIS 4407

Page 52: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

/usr/sbin/nfsstat -s

Server rpc stats:calls badcalls badauth badclnt xdrcall28 0 0 0 0Server nfs v3:null getattr setattr lookup access readlink2 7% 10 35% 0 0% 2 7% 3 10% 0 0%read write create mkdir symlink mknod8 28% 0 0% 0 0% 0 0% 0 0% 0 0%remove rmdir rename link readdir readdirplus0 0% 0 0% 0 0% 0 0% 0 0% 1 3%fsstat fsinfo pathconf commit0 0% 2 7% 0 0% 0 0%

CIS 4407

Page 53: Introduction to the Network File System (NFS)

Summer 2006

CIS 4407

Page 54: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

☞ Tuning with mount command:

➳ rsize=n → Set the read buffer size to n bytes.

CIS 4407

Page 55: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

☞ Tuning with mount command:

➳ rsize=n → Set the read buffer size to n bytes.

➳ wsize=n → Set the write buffer size to n bytes.

CIS 4407

Page 56: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

☞ Tuning with mount command:

➳ rsize=n → Set the read buffer size to n bytes.

➳ wsize=n → Set the write buffer size to n bytes.

➳ timeo=n → Set the NFS timeout to n tenths of a

second.

CIS 4407

Page 57: Introduction to the Network File System (NFS)

Summer 2006

Tuning NFS

☞ Tuning with mount command:

➳ rsize=n → Set the read buffer size to n bytes.

➳ wsize=n → Set the write buffer size to n bytes.

➳ timeo=n → Set the NFS timeout to n tenths of a

second.

➳ retrans=n → The number of NFS retransmissions.

CIS 4407

Page 58: Introduction to the Network File System (NFS)

Summer 2006

Automounting

☞ Original implementations were buggy, and some

(Ultrix) required reboots to straighten out problems.

CIS 4407

Page 59: Introduction to the Network File System (NFS)

Summer 2006

Automounting

☞ Original implementations were buggy, and some

(Ultrix) required reboots to straighten out problems.

☞ For most production environments, the reasons for

automounting are less of an issue.

CIS 4407

Page 60: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

☞ NFS v4 (RFC3530 – http://www.ietf.org/rfc/rfc3530.txt)

CIS 4407

Page 61: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

☞ NFS v4 (RFC3530 – http://www.ietf.org/rfc/rfc3530.txt)

1. adds state (NFS was originally stateless)

CIS 4407

Page 62: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

CIS 4407

Page 63: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

2. file delegation – the client can work on a local copy of

a file until another client requests the same file

CIS 4407

Page 64: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

2. file delegation – the client can work on a local copy of

a file until another client requests the same file

3. multiple RPCs in a single request

CIS 4407

Page 65: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

2. file delegation – the client can work on a local copy of

a file until another client requests the same file

3. multiple RPCs in a single request

4. better security

CIS 4407

Page 66: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

5. improved ACL support

CIS 4407

Page 67: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

5. improved ACL support

6. folding currently disparate parts into a single NFS

mechanism (no longer lock, mount, stat, nfs)

CIS 4407

Page 68: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

☞ AFS – Andrew File System

CIS 4407

Page 69: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

☞ AFS – Andrew File System

1. has been in development since the late 1980s

CIS 4407

Page 70: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

☞ AFS – Andrew File System

1. has been in development since the late 1980s

2. better security than nfs

CIS 4407

Page 71: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

3. AFS can be used in global configurations; Morgan

Stanley, for instance, has a global AFS network (25,000+

hosts over 6 continents (good slide presentation at

http://www-conf.slac.stanford.edu/AFSBestPractices/Slides/MorganStanley.pdf)

CIS 4407

Page 72: Introduction to the Network File System (NFS)

Summer 2006

Beyond NFS

3. AFS can be used in global configurations; Morgan

Stanley, for instance, has a global AFS network (25,000+

hosts over 6 continents (good slide presentation at

http://www-conf.slac.stanford.edu/AFSBestPractices/Slides/MorganStanley.pdf)

4. OpenAFS – IBM released a branch for open source

development

CIS 4407

Page 73: Introduction to the Network File System (NFS)

Summer 2006

Windows Shares

“A share is a directory or other resource, such as a

printer or CD-ROM drive, that is designated to be used

among network users.”

Shares achieve a similar effect as between an NFS server

and client, with much less fuss :)

CIS 4407

Page 74: Introduction to the Network File System (NFS)

Summer 2006

Windows Shares

Creating a share is simple: right-click on the drive or

directory and select the Sharing option.

CIS 4407

Page 75: Introduction to the Network File System (NFS)

Summer 2006

Windows Shares

You can also create multiple share names for the same

device/directory. Think of it as NFS-mounting the same

file system at more than one place in the file system

hierarchy.

CIS 4407

Page 76: Introduction to the Network File System (NFS)

Summer 2006

Windows Shares

Windows Services for UNIX adds much UNIX

functionality to Windows, including NFS support.

CIS 4407


Recommended