Lab #17: NFS
Date: April 17, 2008
Due Date: April 21, 2008

In this lab, we'll use your physical machine as the NFS server, and your virtual machine as the NFS client.

NFS Home Directories

  1. Exporting /home
    1. On your server host, edit /etc/exports to export /home. Be sure to limit exports to your client machine only.
      su
      vim /etc/exports
      
    2. Export the filesystems.
      exportfs -a
      
    3. Check the exports. Notice that some options are specified that you didn't put in /etc/exports. You can also see your exports via /proc.
      exportfs -v
      cat /proc/fs/nfs/exports
      
    4. Check which RPC services are running. Start the services that you need for the NFS server to run, then check your RPC services again.
      rpcinfo -p
      
  2. Mounting /home
    1. If a student user doesn't exist on your client, create one now.
      useradd student
      
    2. Verify that student's UID and GID match on the client and server. If they do not match, use vipw to edit the passwd file on the client and vim to edit the group file.
      client> grep student /etc/passwd
      server> grep student /etc/passwd
      
    3. Log into the client as root and unmount /home if it exists as a separate partition. The df command will show you which partitions are currently mounted.
      df -h
      su
      umount /home
      
    4. Attempt to mount the /home partition from your NFS server. This will fail because the server's firewall won't permit access. Use rpcinfo to verify this fact.
      mount -t nfs SERVER_IP_ADDRESS:/home /home
      rpcinfo -p SERVER_IP_ADDRESS
      
    5. Configure your server's firewall so your host can be an NFS server. Firewalling NFS is difficult because the mountd port is randomly set each time NFS starts. You'll need to configure it to use a fixed port, 4002, to make firewalling possible. The other two ports you need are fixed by default and you can find them with rpcinfo or by using Wireshark a few times while you're attempting to mount the filesystem to determine which ports you need to open.
      vim /etc/sysconfig/network                 # Set MOUNTD_PORT=4002
      service nfs restart
      rpcinfo -p
      wireshark &
      vim /etc/sysconfig/iptables
      service iptables restart
      
    6. Check the new mount. Turn in the output of these commands as part of your lab file.
      df -h
      ls -l /home
      ls -l /home/student
      
    7. Unmount the filesystem, then create a new entry in /etc/fstab so that the filesystem will be mounted on boot.
      umount /home
      vim /etc/fstab
      mount /home
      
    8. Login to the client as user student.
      ssh student@localhost                   # Or login via the VMWare console
      
    9. Login as student on the server too. Verify that student's home directory is the same on both the client and server.
      client> echo "spam eggs" >spamneggs
      server> cat spamneggs
      

    NFS Performance Testing

    Now we'll check the performance of your NFS server from the client. We'll just look at the basics. For more in-depth performance tuning of NFS, we would need to use a tool like iozone and the NFS Optimization Chapter of the NFS HOWTO.

    1. Run nfsstat on your NFS server to see your current RPC and NFS statistics. Note that lists the number of each type of NFS operation.
      nfsstat
      
    2. Time the creation of a 256M file on the client's local disk.
      time dd if=/dev/zero of=/tmp/bigfile bs=1M count=256
      
    3. While on the client, time the creation of a 256M file on the NFS disk. How much faster is the local disk write than the NFS write?
      time dd if=/dev/zero of=/home/bigfile bs=1M count=256
      
    4. Check your NFS stats on the server again. How are they different? How many writes did it take to create that 256M file?
      nfsstat
      
    5. Time the compression the local file. Note that compression uses a mixture of reads and writes to the disk.
      time bzip2 /tmp/bigfile
      
    6. Time the compression the local file. While it's still faster to use the local disk than NFS, note that the advantage is smaller with bzip2 than with dd. Why is this true?
      time bzip2 /tmp/bigfile
      
    7. Check your NFS stats on the server again. How are they different? How has the ratio of reads and writes changed?
      nfsstat
      
 

©2008 James Walden, Ph.D.