Post

Remote Home Directories In Linux Using Nfs Are Kind Of Slow Laggy

Welcome to our blog post, where we tackle a common issue faced by many sysadmins and DevOps engineers: slow and laggy remote home directories in Linux using NFS. We'll provide.

# Remote Home Directories In Linux Using NFS Are Kind Of Slow Laggy

Welcome to our blog post, where we tackle a common issue faced by many sysadmins and DevOps engineers: slow and laggy remote home directories in Linux using NFS. We’ll provide a practical solution for this problem, focusing on self-hosted infrastructure and automation within the scope of open-source tools.

Prerequisites

Before we dive into the solution, ensure you have the following software installed:

  1. A Linux server (Ubuntu 20.04 LTS or CentOS 8) with NFS and automount packages installed.
    1
    
    sudo apt-get update && sudo apt-get install nfs-kernel-server nfs-common autofs
    

    or for CentOS:

    1
    
    sudo yum install -y nfs-utils autofs
    
  2. Clients running the same OS with NFS and automount packages installed.
    1
    
    sudo apt-get update && sudo apt-get install nfs-common autofs
    

    or for CentOS:

    1
    
    sudo yum install -y nfs-utils autofs
    
  3. Ensure that the server and client systems are connected on the same network.

Solution

  1. Configure NFS Server

    Edit the /etc/exports file to define the shared directory path and permissions:

    1
    
    sudo nano /etc/exports
    

    Add the following line:

    1
    
    /path/to/your/directory your_client(rw,sync,no_subtree_check)
    

    Replace your_client with the hostname or IP address of the client system.

  2. Restart NFS Service

    1
    
    sudo systemctl restart nfs-kernel-server
    
  3. Configure Autofs on the Client

    Edit the /etc/auto.master file to mount the remote directory automatically at boot:

    1
    
    sudo nano /etc/auto.master
    

    Add the following line at the end of the file:

    1
    
    /path/to/your/local/directory auto.home --timeout=60 --ghost
    

    Replace your_local_directory with the path where you want to mount the remote directory locally.

  4. Create a Mount Point

    Create the local directory and mount point:

    1
    
    mkdir -p /path/to/your/local/directory/{home,auto.home}
    
  5. Configure auto.home

    Create a new file at /etc/auto.home:

    1
    
    sudo nano /etc/auto.home
    

    Add the following line:

    1
    
    home -fstype=nfs server_hostname:/path/to/your/directory
    

    Replace server_hostname with the hostname or IP address of the NFS server.

  6. Verify the Mount

    After rebooting the client system, verify that the remote directory is mounted correctly:

    1
    
    sudo mount -a
    

Troubleshooting

  • Check NFS and automount logs for any errors or warnings.
  • Ensure that the server and client systems are properly configured and connected.

Conclusion

By following these steps, you’ve implemented a self-hosted solution for remote home directories in Linux using NFS and autofs. With this setup, your users can seamlessly access their home directories from multiple devices without performance issues. Keep in mind potential security considerations, such as proper permissions and firewall rules to protect your infrastructure.

For more details on NFS and automount configurations, refer to the official documentation. Happy DevOps-ing!

This post is licensed under CC BY 4.0 by the author.