How to Install and Configure NFS Server on Ubuntu 24.04

Choose a different version or distribution

Introduction

Before we begin talking about how to install and configure NFS Server on Ubuntu 24.04, let's briefly understand – What is NFS Server?

An NFS Server, known as Network File System Server, is a computer system that stores and shares files across a network. It facilitates easy access and sharing of files among different devices like computers, servers, and even cloud instances. By functioning as a server, it allows clients to remotely access files over a network.

NFS Server simplifies file management and collaboration, enabling seamless file sharing between multiple users and devices. This network file system serves as a central storage hub for users to access and manage files efficiently and securely.

In this tutorial, you will install and configure NFS Server on Ubuntu 24.04. We will also address a few FAQs on how to install and configure NFS Server on Ubuntu 24.04.

Advantages of NFS Server

  1. Centralized Storage: NFS Server offers a centralized storage solution, allowing multiple clients to access and share files and directories across a network.
  2. High Performance: Provides fast and efficient file access speeds, ideal for applications that require quick data retrieval.
  3. Scalability: Easily scales to accommodate growing storage needs while maintaining consistent performance levels.
  4. Ease of Management: Simplifies file management tasks with user-friendly administration tools.
  5. Cross-Platform Support: Supports various operating systems, enabling seamless file sharing between different client platforms.

Install and Configure NFS Server on Ubuntu 24.04

Install NFS Server

apt -y install nfs-kernel-server

Open /etc/idmap.conf file in your editor and in line 5, uncomment and change to your domain name

Domain = vegastack

Open /etc/exports file in your editor and add settings for NFS exports, for example, set [/home/nfsshare] as NFS share

/home/nfsshare 10.0.0.0/24(rw,no_root_squash)

Create a directory using mkdir

mkdir /home/nfsshare

Restart the NFS server

systemctl restart nfs-server

For fundamental export options,

Option Description
rw It permits both read and write requests on an NFS volume.
ro It permits only read requests on an NFS volume.
sync It responds to requests only after changes have been committed to stable storage. (Default)
async This option allows the NFS server to deviate from the NFS protocol by responding to requests before any changes made by those requests have been committed to stable storage.
secure This option requires that requests originate from an Internet port number less than IPPORT_RESERVED (1024).. (Default)
insecure This option accepts connections from all ports.
wdelay It slightly delays committing a write request to disk if it suspects that another related write request is in progress or may arrive soon.(Default)
no_wdelay This option has no effect if async is also set. Normally, the NFS server slightly delays committing a write request to disk if it suspects another related write request is in progress or may arrive soon. This enables multiple write requests to be committed in one operation, improving performance. However, if the NFS server mainly receives small, unrelated requests, this behavior could reduce performance, so the no_wdelay option is available to disable it.
subtree_check This option enables subtree checks. (Default)
no_subtree_check This option disables subtree checks, which has minor security implications but can improve reliability in certain situations.
root_squash It redirects requests from uid/gid 0 to the anonymous uid/gid. However, this does not apply to other sensitive uids or gids, such as user bin or group staff.
no_root_squash It disables root squashing, which is primarily beneficial for diskless clients.
all_squash It maps all uids and gids to the anonymous user, making it useful for NFS-exported public FTP directories, news spool directories, and similar use cases.
no_all_squash It disables all forms of squashing. (Default)
anonuid=UID These options specifically assign the uid and gid of the anonymous account. They are particularly useful for PC/NFS clients where you want all requests to appear as if they come from a single user. For instance, the export entry for /home/joe in the example section below maps all requests to uid 150.
anongid=GID It refers to the setting specified above (anonuid=UID).

FAQs to Install and Configure NFS Server on Ubuntu 24.04

What packages do I need to install to set up an NFS server on Ubuntu 24.04?

Install the nfs-kernel-server package using the apt command.

What are some common options used in the /etc/exports file?

Common options include rw, ro, sync, async, no_subtree_check, no_root_squash, and all_squash.

What ports does NFS use?

By default, NFS uses port 2049 for TCP traffic.

How do I check the exported NFS shares

Use the exportfs command to list the currently exported NFS shares.

How do I check the NFS client and server logs?

NFS client logs and NFS server logs are often found in the same log files on a system. Specifically, these logs are typically located in /var/log/syslog or /var/log/messages.

What other ports may need to be opened for NFS?

Depending on the NFS version, additional ports may be needed:

  • NFSv3 uses ports 111 (rpcbind), 2049 (nfs), 4045 (nlockmgr)
  • NFSv4 uses port 2049 (nfs)

How do I start the NFS server after installation?

Use the systemctl command to start the NFS server service: sudo systemctl start nfs-kernel-server.service

Conclusion

We hope this tutorial helped you understand how to install Plasma on Ubuntu 24.04.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.