LWM-Linux/08 - Advanced Linux Administration/Network File Systems (NFS).md

3.5 KiB

etwork File Systems (NFS)

Network File System (NFS) Overview:

NFS is a distributed file system protocol that allows a user on a client computer to access files over a network in a manner similar to how local storage is accessed. NFS was originally developed by Sun Microsystems in 1984 and has since become a widely used protocol for file sharing in Unix-like operating systems.

Key Features of NFS:

    1. Transparent access to remote files
    1. Support for heterogeneous environments
    1. Stateless protocol (versions 2 and 3)
    1. Caching for improved performance
    1. User authentication and access control

NFS Versions:

    1. NFSv2 (1989): The first widely used version
    1. NFSv3 (1995): Improved performance and added features
    1. NFSv4 (2000): Major revision with enhanced security and internet-friendly features
    1. NFSv4.1 (2010): Added parallel NFS (pNFS) for improved scalability
    1. NFSv4.2 (2016): Added server-side copy and space reservation

NFS Architecture:

NFS follows a client-server model:

    1. NFS Server: Exports file systems to be shared
    1. NFS Client: Mounts the exported file systems
    1. RPC (Remote Procedure Call): Facilitates communication between client and server

NFS Components:

    1. MOUNT protocol: Handles the mounting of file systems
    1. NFS protocol: Manages file and directory operations
    1. Portmapper/RPCBIND: Maps RPC program numbers to network port numbers
    1. NFS Daemon (nfsd): Handles client requests on the server
    1. Lock Manager (lockd): Manages file locking
    1. Status Monitor (statd): Provides crash and recovery functions

NFS Operation:

    1. Server exports file systems
    1. Client discovers available exports
    1. Client mounts desired file system
    1. Client accesses files using NFS protocol

Security Considerations:

    1. Authentication: Kerberos (NFSv4), AUTH_SYS (older versions)
    1. Authorization: Access control lists (ACLs) or traditional Unix permissions
    1. Encryption: RPCSEC_GSS (NFSv4)
    1. Firewall configuration: Proper port management

Performance Tuning:

    1. Adjust read and write buffer sizes
    1. Optimize network settings (MTU, TCP window size)
    1. Use appropriate mount options (e.g., rsize, wsize)
    1. Implement caching strategies

Common NFS Commands:

    1. exportfs: Maintain table of exported file systems
    1. showmount: Display mount information for an NFS server
    1. mount/umount: Mount and unmount NFS shares
    1. nfsstat: Display NFS statistics

Troubleshooting NFS:

    1. Check network connectivity
    1. Verify NFS services are running
    1. Review server logs (/var/log/messages, /var/log/syslog)
    1. Use tcpdump or Wireshark for packet analysis
    1. Test with different NFS versions or mount options

NFS Alternatives:

    1. Samba (SMB/CIFS): Better for Windows integration
    1. AFS (Andrew File System): Designed for large-scale distributed computing
    1. GlusterFS: Scalable network filesystem
    1. Ceph: Distributed object store and file system

Best Practices:

    1. Use NFSv4 when possible for improved security and performance
    1. Implement proper access controls and user mapping
    1. Regularly update NFS software to address security vulnerabilities
    1. Monitor NFS performance and adjust settings as needed
    1. Implement redundancy and failover mechanisms for critical deployments

NFS in Modern Environments:

    1. Container orchestration: NFS can be used as persistent storage for Kubernetes
    1. Cloud computing: Many cloud providers offer NFS-compatible file storage services
    1. Hybrid environments: NFS can bridge on-premises and cloud storage