Introduction

This page describes AlexisHuxley's experiences running:

  1. an NFS server on an OpenVz VE

  2. the automounter on an OpenVz VE

Analysis

To my knowledge there are three NFS implementations for Linux. Each of them exhibits some problems running in an OpenVz virtual machine:

Debian package name

problems

nfs-kernel-server

requires patching kernel; see http://wiki.openvz.org/NFS_server_inside_VE

nfs-user-server

no locking, file size limited to 2GB

unfs3

no locking, lchown() not implemented

For my own personal use, being able to read and write files of sizes larger than 2GB was essential so I had to go with the unfs3. This meant I had to contend with the following problems:

  1. rdiff-backup seems to be one of the few programs needing lchown()

  2. when the automounter invokes mount and umount then it wants to write to /etc/mtab, which on a VE is a symlink to a read-only 'file' under /proc; although mount and umount can be told not to write to this file, there is no convenient way to get the automounter to relay this request to them
  3. the Debian automounter package suffers from bug whereby the mountpoints are removed as the autmounter exits and they are not recreated when it is next started.

Procedure

  1. On the server install the unfs3 package.
  2. On the clients install the nfs-common package.
  3. On the HN add the following to /etc/modules:

    autofs4
    nfs 
    (The HN may not be the NFS server, so it would not load these modules and VEs don't have the power to load modules.)
  4. Ensure all VE clients mount the server with the -nolock option.

  5. To work around the disappearing mountpoints edit /etc/init.d/autofs, locate the line:

    : echo LOCALOPTIONS $localoptions 

    and immediately after it add:

    mkdir -p $dir 
  6. To get the automounter to invoke mount and umount with the -n option so as to not write to /etc/fstab, run:

    dpkg-divert --add --rename /bin/mount
    dpkg-divert --add --rename /bin/umount
    cat > /bin/mount <<'EOF'
    #!/bin/sh
    if [ "X$MOUNT_MTAB" = Xfalse -a $(/usr/bin/basename $0) = mount ]; then
        exec $0.distrib -n "$@"
    elif [ "X$MOUNT_MTAB" = Xfalse -a $(/usr/bin/basename $0) = umount ]; then
        exec $0.distrib -in "$@"
    else
        exec $0.distrib "$@"
    fi
    EOF
    chmod 755 /bin/mount
    ln -f /bin/mount /bin/umount
    echo "export MOUNT_MTAB=false" >> /etc/default/autofs 
    and restart the automounter.
  7. Be sure that the portmapper is started automatically at boot-time on the client and server.
  8. To fix rdiff-backup, see GettingRdiffBackupWorkingOnUnfs3.

See also


CategoryProcedure

UsingNfsWithOpenVz (last edited 2010-03-22 11:51:17 by AlexisHuxley)