RHCSA - Part18 - NFS client, Samba client
NFS client
Install nfs-utils:
# yum install -y nfs-utils
Optional: If the NFS server allows remote browsing of exports list (nfs-idmapd + rpcbind), display the shares with showmount:
# showmount -e srv.example.local
or
# showmount -e <srv_IP_address>
Create the mount point then mount the remote share:
# mkdir /mnt/mount_dir
Temporarily mount the remote share:
For NFS3 # mount -v -t nfs -o vers=3,rw,sync srv.example.local:/srv/share /mnt/mount_dir or for NFS4 # mount -v -t nfs4 -o rw,sync srv.example.local:/srv/share /mnt/mount_dir or for NFS 4.2 # mount -v -t nfs -o sec=sys,vers=4.2,rw,sync srv.example.local:/srv/share /mnt/mount_dir
Persistent mount across reboots: Edit in /etc/fstab:
# vi /etc/fstab [...] # for NFS 3 srv.example.local:/srv/share /mnt/mount_dir nfs vers=3,rw,sync 0 0 # for NFS 4 srv.example.local:/srv/share /mnt/mount_dir nfs vers=4,rw,sync 0 0 # for NFS 4.2 srv.example.local:/srv/share /mnt/mount_dir nfs sec=sys,vers=4.2,rw,sync 0 0
Mount the share:
# mount -av
Umount the share:
# umount /mnt/mount_dir
Samba
Install cifs-utils and optionally samba-client (for multiuser and remote browsing):
# yum install -y cifs-utils samba-client
Optional: Display the shares using smbclient:
# smbclient -L srv.example.local
Create the mount point then mount the remote share:
# mkdir /mnt/samba
Create the credentials file /root/creds.txt
(to hide user/password from /etc/fstab):
# vi /root/creds.txt user=alice pass=pass
Persistent mount across reboots: Edit in /etc/fstab:
# vi /etc/fstab [...] //srv.example.com/custom_share /mnt/samba cifs credentials=/root/creds.txt 0 0
For multiuser:
# vi /etc/fstab [...] //srv.example.com/share /mnt/mount_dir cifs multiuser,credentials=/root/creds.txt 0 0
Optional: samba version in fstab:
If the server requires a specific client version, add the version in fstab mount options vers=3.0
, vers=3.1
, vers=4.0
, etc. …
Mount the share:
# mount -av
Umount the share:
# umount /mnt/mount_dir
For multiuser browsing, use cifscreds:
# su - alice $ cd /mnt $ ls -al ls: cannot access mount_dir: Permission denied ??????????? ? ? ? ? ? mount_dir $ cifscreds add srv Password:...... $ ls -al drwxr-x-r-x. 2 alice alice 0 Feb 20 20:00 mount_dir