RHEL7: Mount and unmount CIFS and NFS network file systems
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.
Leave a comment