How to set up and mount NFS on Ubuntu?

To set up and mount NFS on Ubuntu, you need to follow these steps:

  1. Install NFS server software:
  2. Run the following command in the terminal to install NFS server software: sudo apt-get install nfs-kernel-server.
  3. Set up an NFS server.
  4. Edit the NFS server configuration file /etc/exports using the following command: sudo nano /etc/exports.
  5. Add the directory and access permissions you want to share in the file. For example, to share the /home/user/shared directory and allow all clients to access it, you can add the following line: /home/user/shared *(rw,sync,no_root_squash,no_subtree_check)
  6. Save and close the file.
  7. Start the NFS server.
  8. To start the NFS server in the terminal, run the following command: sudo systemctl start nfs-kernel-server.
  9. If necessary, you can use the following command to set the NFS server to start at boot: sudo systemctl enable nfs-kernel-server.
  10. Mount NFS share:
  11. Create a directory on the client side to mount the NFS share. For example, you can create a directory named “shared” under the /mnt/nfs directory: sudo mkdir -p /mnt/nfs/shared.
  12. Run the following command in the terminal to mount an NFS share: sudo mount server_ip:/home/user/shared /mnt/nfs/shared, where server_ip is the IP address of the NFS server.
  13. You can also use the following command to automatically mount NFS shares at startup: sudo nano /etc/fstab, and then add the following line: server_ip:/home/user/shared /mnt/nfs/shared nfs defaults 0 0
  14. Save and close the file.

Note: Ensure that both the server and client have their firewalls configured to allow NFS traffic to pass through in order to facilitate proper communication.

bannerAds