Nfs ��� linux mint

How to setup NFS server in Linux Mint (Ubuntu based)?

One of my NFS server running on Fedora was overloaded and I had to set up a new one. This time, I choose Linux Mint.

Setting up NFS server on Linux Mint was a breeze. Since the method we followed may be useful to other developers, I thought of sharing them here.

What is Linux Mint?

Linux Mint is a Ubuntu based Linux OS with growing popularity. Since its Ubuntu based, it inherits all the traits of Ubuntu release and add few additional functionality.

I have been using Linux Mint for about three years now starting from Linux Mint 5 till the latest Linux Mint 9. I am a great fan of this OS.

What is NFS?

The Network File System (NFS) protocol was developed by Sun Microsystems in 1984. NFS builds over Open Network Computing Remote Procedure Call, commonly called SUN ONC.

Step 1: Install NFS server and other dependent applications

Open a terminal on the Linux Mint desktop and issue the below command.

This will install three packages the are essential for clutter free operation of NFS.

Step 2: Configure the NFS server

NFS exports from a server are controlled by the file /etc/exports . Each line begins with the absolute path of a directory to be exported, followed by a space-separated list of allowed clients.

For example: To export the /var/nfs directory so that it can be accessed by any client, please insert the below line in the file – /etc/exports .

Note: Allowing any client to access your box can be potentially harmful. Please reconsider your decision before doing so.

To allow access to machines with a particular set of IP addresses, please insert the below line in /etc/exports .

Other options that can specified along with the IP address include:

ro:

The directory is shared read only; the client machine will not be able to write it. This is the default.

rw:

The client machine will have read and write access to the directory.

no_root_squash:

If no_root_squash is specified, then root on the client machine will have the same level of access to the files on the system as root on the server. This can have serious security implications. You should not specify this option without a good reason.

no_subtree_check:

If only part of a volume is exported, a routine called subtree checking verifies that a file that is requested from the client is in the appropriate part of the volume. If the entire volume is exported, disabling this check will speed up transfers.

sync

By default, all but the most recent version (version 1.11) of the exportfs command will use async behavior, telling a client machine that a file write is complete – that is, has been written to stable storage – when NFS has finished handing the write over to the file system. This behavior may cause data corruption if the server reboots, and the sync option prevents this.

Источник

Easy NFS Share Setup In Ubuntu, Linux Mint Or Debian With Simple NFS GUI (Server And Client)

NFS (Network File System) is a distributed file system protocol that allows sharing directories and files with others over a shared network. Using it allows access to files on remote hosts as if they were local files.

Setting up a NFS mount on Ubuntu or Linux Mint can be quite a tedious task. Enter Simple NFS GUI. This is a GUI tool to easily set up a machine as a NFS server or client that should work on Ubuntu, Linux Mint and Debian.

Simple NFS GUI takes care of the whole NFS share configuration process. When setting up a NFS server, the tool automatically sets up the /etc/exports configuration, and secures the server via /etc/hosts.deny and /etc/hosts.allow . For setting up a NFS client, the application automatically creates a directory for the mount point, as well as add the NFS mount to the /etc/fstab file with the users option, so it can be mounted by non-root users. The application also installs the required NFS packages for both server and client.

Читайте также:  Установка windows 10 получение обновлений очень долго

I should note that while Simple NFS GUI automatically adds the network file system mount in /etc/fstab , it sets it so the NFS is not mounted until it’s accessed. You can change the NFS line created by Simple NFS GUI from /etc/fstab and replace noauto with auto to automatically mount it at boot time, but this may cause the boot process to stall.

If you need to create multiple NFS shares, run the Simple NFS GUI setup process multiple times, specifying a different NFS share folder each time.

Installing and using Simple NFS GUI to set up a NFS client or server

1. Simple NFS GUI requires Gambas 3 — adding a PPA on Ubuntu and Linux Mint is required.

Ubuntu, Linux Mint and flavors / derivatives: Simple NFS GUI requires Gambas 3. I’m not sure why but Gambas 3 is not available in Ubuntu or Linux Mint, while it is available in Debian (the version in Debian jessie is too old though, but newer Debian versions all have the required Gambas 3 version). The Gambas developers are maintaining a PPA to allow installing the latest Gambas 3 in Ubuntu, Linux Mint, as well as Ubuntu flavors like Lubuntu, Kubuntu, Xubuntu, Ubuntu MATE, and so on. Add the PPA and update the software sources:

2. Download and install Simple NFS GUI

Visit this page, scroll down to the bottom and click the blue Download Now button. Next, install the downloaded DEB package. In Ubuntu, the Gambas 3 dependencies will be automatically pulled from the Gambas 3 PPA which should be added on your system as explained above.

3. Starting the Simple NFS GUI application

Don’t run Simple NFS GUI from your applications menu as it won’t work. That’s because the application needs to be started as root, and its application menu entry runs it without admin privileges.

If your system still has gksu (Ubuntu 16.04 and older, Linux Mint 18.x and older, Debian stretch or sid — debports), you can run Simple NFS GUI by using this command:

For Ubuntu 18.04 and newer, Linux Mint 19 and newer, or Debian buster, which don’t have gksu , you’ll need to run the application with sudo , like this:

Now you can use Simple NFS GUI to set up a machine as a NFS client or server.

Use Simple NFS GUI to set up a machine as a NFS client

To setup a machine as a network file system (NFS) client using Simple NFS GUI, start the application, select Client and click Next :

On the next screen, click the . button under Select server to select the server IP address :

It may take a while until the IP list is populated, because a package may be need to be installed on your system to detect the IPs, and the IP detection may take a bit to run as well.

After the server list is populated, select the NFS share server IP from the dropdown. You’ll also need to enter the full path of the server’s shared NFS folder, and enter a name for this folder (the name needs to only contain letters).

Here how this should look:

Once you’re done, click the Set this machine as a Client button. Simple NFS GUI will ask you to recheck the data — if everything is ok, press Yes and the setup process is completed.

(Rerun the procedure if you want to add multiple folders.)

You’ll now need to reboot your system. The NFS share should show up in your file manager, but it won’t be mounted by default. Click it and it will be mounted as long as the remote NFS share server can be accessed.

Use Simple NFS GUI to set up a machine as a NFS server

Choose Server from the initial Simple NFS GUI screen and click Next :

On the second screen, click the . button under Select the client to select the NFS client IP address. Like I mentioned in the client section above as well, it may take a while until the IP list is populated, because a package may be need to be installed on your system to detect the IPs, and the IP detection may take a bit to run as well.

Once the client IP list is populated, select a client IP from the dropdown. You’ll also need to enter the full path of the shared NFS folder. This is how it should look after entering all the required information:

Next, click the Set this machine as Server button. Simple NFS GUI will ask you to recheck the client IP and the server’s folder path. If everything is ok, click Yes .

(If you want to allow multiple clients to access your NFS server, rerun this procedure for each client.)

Читайте также:  Пропинговать диапазон адресов linux

There’s only one step left: reboot your computer.

Источник

How to Configure NFS Server and Client on Linux Mint 20

NFS (Network File System) works in the form of a client-server model where the machine sharing the directories is known as the NFS server whereas the machine accessing those directories is known as the NFS client. In our previous post, we shared with you how to configure the NFS client and server on the Debian system. This post will be about how to configure the NFS server and client on Linux Mint 20.

Note:

For the demonstration, we will be using the two machines with the following details:

NFS Server (Linux Mint 20)

NFS Client (Linux Mint 20)

Setting up NFS server

Step 1: Install NFS Server

On the machine to be setup as an NFS server, you will need to install nfs-kernel-server. First, update the local repository index:

Enter the password for sudo.

Then install nfs-kernel-server package as follows:

After running the above command, the system will prompt with the y/n option. Hit y to continue the installation.

After the installation is completed, you can verify it by running the following command in Terminal:

If you see the below similar output, it shows the NFS server has been installed successfully.

Step 2: Create an Export Directory

On the server machine, create an export directory you want to share with the clients. Let’s say we want to export two directories /var/nfsshare and /var/nfs-share1. First, we will have to create these directories. Run the following commands with sudo to do so:

As these directories were created with sudo, therefore the root user currently owns them. You can verify it by running the ls commands as follows:

From our two export directories (/var/ nfs-share and /var/ nfs-share1), we will change the ownership of one of the directory /var/ nfs-share to nobody:nogroup. We will not change the ownership of the second directory; it will remain owned by the root user.

Run the following command to change the ownership of /var/ nfs-share directory from root to nobody:nogroup:

You can confirm the new owner through the following command:

The following output confirms that the /var/ nfs-share is now owned by nobody:nogroup.

Step 3: Configure and Share the NFS Exports

Next, we will configure NFS for the sharing of the export directories. The NFS configuration file is /etc/exports which determine which clients will have access to the exported directories.

In the /etc/exports file, add the configuration lines using the following syntax:

  • export_directory is the directory you want to share.
  • client is the IP address or the subnet of the client that wants to access the shared directories. To find the IP address of a machine, you can visit our post on How to Find the IP address.
  • options specify how the resources should be shared.

These configuration lines basically specify the directories we are going to export and who can access them.

In order to share our NFS export directories (/var/ nfs-share and /var/ nfs-share1) to client IP addres 192.168.72.191, we will add following lines in the configuration file /etc/exports.

Our configuration lines specify the directories (nfs-share and nfs-share1) we want to export to the client 192.168.72.191 with read-write, sync, and no_subtree_check options. In the second entry, you can find the no_root_squash option which gives the client root permission on the server. You can visit more information about the options on the exports man page.

Save and close the file.

Now you will have to share the exports configured in the /etc/exports. You can do so using the following command in Terminal:

The following output shows that the NFS server is exporting the shared directories to the clients.

Alternatively, you can also export the shares by restarting the NFS service:

You can also check the NFS service status to ensure if it is actively running. Here is the command to do so:

The following output indicates the NFS server is running fine without any issues.

Step 4: Add a Firewall Rule for NFS Traffic

First, check if a firewall is enabled on your server by running the following command in Terminal:

If you see the active status in output, it means the firewall is enabled. Therefore, now you will have to add a rule in the firewall for NFS traffic.

Using the following syntax, add a rule in the firewall to allow clients to NFS port 2049.

For example, you can run the following command to allow client subnet 192.168.72.0/24 access to NFS server port 2049:

Now to check if the firewall rule has been added successfully, run the following command:

Читайте также:  Linux посмотреть днс сервера

The following output shows the rule has been added which allows the connection from 192.168.72.0/24 to port 2049.

Setting up NFS Client

Step 1: Install NFS Client

On the machine to be setup as an NFS client, you will need to install nfs-common package on it. You can install it as follows:

First, update the local repository index:

Enter the password for sudo.

Then install nfs-common package:

After running the above command, the shell will prompt with the y/n choice. Press y to continue the procedure.

After the installation of client package is completed, you can verify it as follows:

If you see the below similar output, it shows the NFS client has been installed successfully.

Step 2: Create Mount Points

To mount the NFS shares on your client machine, you will first have to create the mount points. We will be creating two directories for our mount points:

Step 3: Mount NFS Shares on the Client Manually

Now that we have the mount points, we can mount the NFS shares exported from the NFS server on the client. Use the following syntax to mount the NFS shares:

In the above command syntax:

  • NFS_server: Enter IP address of NFS server
  • NFS_export: Enter NFS export directory shared by the NFS server
  • client_mountpoint: Enter the mount point of the client where you want to mount the NFS export directory.

We have run the following commands to mount the NFS shares:

The above commands mount the shares from:

  • /var/nfs-share directory on the NFS server (192.168.72.170) to the client’s local mount point /media/nfs-share
  • /var/nfs-share1 directory on the NFS server (192.168.72.170) to the client’s local mount point /media/nfs-share1.

Now run this command to verify if the mounting has been successful:

The output of the df command is as follows which shows the NFS mounts at the bottom.

Using the below command, you can also determine how much space is actually used by each mount point.

As we have created the mount points under the /media directory, the system will create one link to that mount point in the left panel of File Manager. Therefore, you can access the shared directories from your File Manager.

You will also find one link to mount point on the Desktop.

Step 4: Mount the NFS shares at startup (automatically)

In the previous step, we have seen how to mount the NFS shares on the client manually. But when you restart the system, they get unmounted. Therefore, after restarting the system, you will have to again mount it. To avoid this manual procedure, again and again, you can make the mount permanent on your system by configuring it in the /etc/fstab file. This configuration will make the NFS shares to automatically mount at startup.

Open the /etc/fstab file using the Nano editor as follows:

In the file, add entries for your shares that you want to mount at startup:

Then save and close the file.

Now after every restart, the NFS shares will be automatically mounted at their specified mount points.

Step 5: Test NFS Access

To test the NFS access, create a new file in each shared directory in your client machine. First, create a sample.txt file as sudo in the /media/nfs-share:

Then create a second file sample1.txt as sudo in the /media/nfs-share1:

Now check the ownership of both files:

You will see the ownership of the sample.txt file is nobody user and nogroup group. Even though this file was created as sudo but the NFS server has now translated its ownership to the server’s nobody:nogroup. This shows the root user on the NFS client cannot carry the administrative jobs on the NFS share.

The ownership of the other file sample1.txt is owned by the root user and root group. It is due to the no_root_squash option that we configured in the /etc/exports file. It enables the root user on the NFS client to function as root and performs administrative jobs.

Now, also check if you can access both files from the NFS server.

Unmount NFS Share

In case, you no longer want the NFS shares, you can easily unmount them from your machine. To unmount the NFS shares, use the following syntax:

In our example, it would be:

This is how you can setup the NFS server and client on Mint. In this post, you have learned how to install the NFS server and client, configure and share NFS export directories, and mount/unmount the NFS shares on the client.

Ummara Mushtaq is a Telecommunication engineer with two years of experience in server support and networking. She writes technical articles based on Linux system administration for LinuxWays.

Источник

Оцените статью