RHEL7: Mount and unmount CIFS and NFS network file systems.

Share this link

Note: This is an RHCSA 7 exam objective.

NFS network file system

To mount and unmount NFS network file systems, you need to set up a NFS server.

Install the NFS client package:

# yum install -y nfs-utils

Let’s assume that the /home/tools directory is exported by the nfsserver server.
If no working DNS, add an entry in the /etc/hosts file with the nfsserver name and its IP address.

Activate at boot and start the nfs-idmap service (RHEL 7.0 only):

# systemctl enable nfs-idmap && systemctl start nfs-idmap

Note: The nfs-idmap service is only required by NFSv4 when setting ACL by names or to display user/group names. It doesn’t allow you any UID/GID mismatches between clients and server.
All permission checks are still done with the UID/GID used by the server.

Activate at boot and start the nfs-client target (RHEL 7.1 and after):

# systemctl enable nfs-client.target && systemctl start nfs-client.target

Edit the /etc/fstab file and add the following line:

nfsserver:/home/tools /mnt nfs4 defaults 0 0

Execute the /etc/fstab file configuration:

# mount -a

To check the current configuration, type:

# mount | grep nfsserver
nfsserver:/home/tools on /mnt type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.42,local_lock=none,addr=192.168.1.49)

To unmount the NFS mounted directory, remove the previous line from the /etc/fstab file and type:

# umount /mnt

Note: if you get a message like “/mnt: device is busy”, to check that you are not in the mounted directory and no process is using it, type:

# fuser /mnt

CIFS network file system

To mount and unmount CIFS network file systems, you need to set up a CIFS file server.

Install the Samba client packages:

# yum install -y cifs-utils
# yum install -y samba-client

Let’s assume that the /shared directory is exported by the smbserver server.
If no working DNS, add an entry in the /etc/hosts file with the smbserver name and its IP address.

Edit the /etc/fstab file and add the following line:

//smbserver/shared /mnt cifs rw,username=user01,password=pass 0 0

Execute the /etc/fstab file configuration:

# mount -a

To check the current configuration, type:

# mount | grep smbserver
//smbserver/shared on /mnt type cifs (rw,relatime,vers=1.0,cache=strict,username=user01,domain=MYSERVER,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.48,unix,posixpaths,serverino,acl,rsize=1048576,wsize=65536,actimeo=1)

To unmount the CIFS mounted directory, remove the previous line from the /etc/fstab file and type:

# umount /mnt

To learn more about the Automounter, go to the LDAP client configuration tutorial.

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.00 out of 5)
Loading...

Leave a Reply

30 Comments on "RHEL7: Mount and unmount CIFS and NFS network file systems."

Notify of
Sort by:   newest | oldest
algorisms
Member
algorisms
I’m a little leery about putting plaintext in fstab like you have above on your smb server example. Passwords in plaintext makes my skin crawl. In case anyone is wondering, you can add a reference to a credentials file in the fstab entry and then keep a hidden file in your root directory that has the password in a safer environment. > touch /root/secret.txt && echo -e “username=user01/npassword=pass/n” >> /root/secret.txt > \\smbserver\shared /mnt cifs rw,credentials=/root/secret.txt 0 0 I’m not sure if this is the most secure manner of accomplishing this but it worked on my home labs nicely. That leaves… Read more »
algorisms
Member
algorisms

Additionally, I found that if you do not want to persistently mount a CIFS share, you can use the following:

> mount.cifs //fileserver/share /mountpoint
> mount.cifs //fileserver/share /mountpoint -o user=domain\username

If you require authentication, the share will bounce back asking for a password. You can also pass your password in using the modulo (%) to save waiting for the prompt but that’s considered insecure.

I’m not sure how to do this with NFS 100% yet.
I’m assuming it would look similar to the fstab entry above.

> mount -t nfs server:\stuff\you\want \mountpointyouwant

Not sure if that is right though… So much to learn…

Thaeimos
Member
Thaeimos

Hi,

first of all, thanks for this site. It´s a great help and it´s making me feel more confident about the exam.
Moving to the point of this comment, I just wanted to mention you that, in order for automounting a NFS share, you don´t need to enable in the client any unit.
It seems that the service “nfs-idmap” is static and this means that it works on demand, so there is no reason to enable nor start it. After adding the entry in the fstab file you are done.
Please check on your side and provide some feedback.

Regards

ak340
Member
ak340

Hi I get this error when trying to enable nfs-idmap

# systemctl enable nfs-idmap
Failed to issue method call: No such file or directory

ak340
Member
ak340

thank you for the time to reply, if the nfs-idmap is disabled will it affect my nfs share? planning to take the exam on July 10. appreciate if you can help 🙂

ak340
Member
ak340

thanks mr certdepot you are very helpful, so do you think I should not bother starting nfs-idmap if asks during exam to mount an nfs share?

Jaz
Member
Jaz

I know this question is not part of this exercise, but I need an answer.

What is the main difference between .mount and .automount files created for systemd mounting process? Why do we need .automount file when we can achieve our target from .mount file?

If enabled, doesn’t this .mount file also automounts on boot?

I need clear answer about differences b/w these two files.

Thank you

redhat0329
Member
redhat0329

Hi CertDepot,

Is it possible that on the exam a kerberos authentication key will be provided in order to mount the NFS share? Again, if its violation on NDA you may ignore this one. Thanks so much! 🙂

redhat0329
Member
redhat0329

Hi CertDepot, Base on Rhel7 docs nfs-secure.service is also used for mounting NFS. Can we enable this service also? Is it possible on the exam that we will be asked to download the sec-key/keytab key? Thanks!

Gjorgi
Member
Gjorgi

mount | grep ‘somestring’? You could just df -h and if it is mounted, it will show up in the list.

navideh
Member
navideh

Do we need to set Kerberos keytab for NFS client setting in exam?
or just “nfsserver:/home/tools /mnt nfs4 defaults 0 0 ” is enough.
I saw some discuses about creating a keytab on the comments!!!!

wpDiscuz

RHCSA7: Task of the day

Allowed time: 10 minutes.
Archive and compress the content of the /opt directory (create files if none exists).
Uncompress and unarchive the resulting file in /root

RHCE7: Task of the day

Allowed time: 15 minutes.
Configure a Samba server called MYSERVER, belonging to the MYGROUP group, sharing the /shared directory with the name "shared".

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...

Recent Comments