Debian / Ubuntu Linux: Setup NFSv4 File Server

Here’s how you can set up an NFSv4 file server on a Debian-based Linux system (such as Debian or Ubuntu):

  1. Install the necessary packages:
    sudo apt-get update
    sudo apt-get install nfs-kernel-server
  2. Create a directory that will be shared over NFS. This directory will be the root of the NFS file system. For example:
    sudo mkdir /nfs
  3. Modify the ownership and permissions of the directory to allow clients to access it. For example:
    sudo chown nobody:nogroup /nfs
    sudo chmod 755 /nfs
  4. Edit the /etc/exports file to add the directory that you want to share over NFS. The /etc/exports file is used to configure the NFS file server. You can add the following line to the file:
    /nfs *(rw,sync,no_root_squash)
  5. Restart the NFS server to apply the changes:
    sudo systemctl restart nfs-kernel-server

Your NFS file server is now set up and ready to serve files. Clients can mount the NFS file system by specifying the IP address of the NFS server and the path to the exported directory. For example:

mount -t nfs SERVER:/nfs /mnt

Where SERVER is the IP address of the NFS server, and /mnt is the mount point on the client system.

Note that this setup assumes that you are using NFSv4. If you want to use an earlier version of NFS, you may need to make additional modifications to your setup.

Leave a Comment