In this video, I’ll show you how to mount an NFS export on Oracle Linux 8.
I’ll assume you already have the NFS export configured on your server system.
But if not, check out the previous video on how to configure the NFS server.
The objectives of this video will be to: Install the nfs-utils package on the client
system. Manually mount the nfs export and modify some
files within it. Demonstrate root squashing.
And finally, automount the NFS export. We’ll start by installing the nfs-utils
package and manually mounting the NFS export. Within the terminal on my client system, I’ll
enter 'sudo dnf install nfs-utils'. Next, I’ll create a directory to use as
a mount point with 'sudo mkdir' and then I’m going to call it '/nfs-mount'.
Now, to mount the export, I’ll use 'sudo mount' followed by the IP address of my server
system, colon, slash, the name of the nfs export, and then path of the mount point I
just created. If we use 'ls –lh /nfs-mount', we can see
it has the three files contained within the export that we create in the previous video.
Let’s take a look at what happens when I modify one of these shared files.
I’ll go ahead and open the share text doc with 'vi /nfs-mount/shared-text.txt'.
I’ll add a new line of text. We’ll just say 'Hello World!'
And I’ll go ahead and save that file. Now if we return to our server system, we
can take a look at that file I just modified. So I’ll write vi /nfs-share/shared-text.txt
We can see that the file has the Hello World! text that I added while on the client system.
So everything looks like it’s working great. Let’s demonstrate root squashing.
We’ll start by opening up the exports file to remind us of what we configured.
I'll use vi /etc/exports When I set up this nfs server, I didn’t
specify any root squashing options. I just had the rw option listed, which means
by default the root access will be squashed when a client accesses the export as the root
user. To see this in action, we can return to our
client system, and try to run a command as root within our export.
Let’s say that I want to change the permissions on that text file we just modified.
I'll do ‘sudo chmod 766 /nfs-mount/shared-text.txt’. It’s going to say I don’t have permissions
to do this. If we trusted the client system and it’s
users to have root access, we could adjust our etc/exports file on the server.
I’ll go ahead and return to our server system. Then, within the etc/exports file, I’ll
add the no_root_squash option and save the file.
I’ll restart the NFS service to so that we reload the updated exports file with 'systemctl
restart nfs-server'. Returning to our client system, since we’ve
turned off root squashing, now when I run that chmod command, it allows me to do it.
With ls -lh, I can see that the permissions have been updated.
Let’s say that we’re done with that export, I can unmount the share, using 'sudo umount
/nfs-mount'. Now if we us ls –lh to look at that mount
point, we can see that it’s empty. We’ve seen how to mount and unmount the
share manually, but next let’s take a look at automounting the export when the system
starts. To do this, we’ll need to add the share
to the /etc/fstab file, which is the file system table.
I’ll open the file with ‘sudo vi /etc/fstab'. Your file will probably look different than
mine. I just have a simple virtual machine, so my
file is pretty basic. I’ll go to the end of the file and add our
NFS export. The syntax here is the device name, the mount
point, filesystem type, any options, and then values for dump and pass.
On the next line, we’ll add the NFS export information.
Which is the IP address of my server system, colon, slash, the name of the share.
Then the mount point on my client system, which is /nfs-mount, the filesystem type is
nfs. For options I’ll put rw, and dump and pass
will be 0 and 0. I’ll go ahead and save that file.
Then I could restart the system. Or I could use 'sudo mount –a' to automatically
mount the file systems. If we take a look at our mount point with
'ls –lh /nfs-mount'. There’s the content of the NFS export.
Each time the system starts, the NFS export will automatically be mounted.
That’s all there is to connecting to NFS export from a client system.
To learn more about Oracle Linux, check out the Oracle Linux 8 Learning Path.
And visit the Linux Learning Library for videos on Oracle Cloud Infrastructure, Oracle Linux
Virtualization Manager, and other Oracle products. Thanks for watching!