automount SAMBA and NFS server

First install automount service:
# yum install -y autofs
The main configuration file is auto.master.
# vi /etc/auto.master
There I will setup the home directory of LDAP users to be setup by the /etc/auto.guests file.
/home/guests /etc/auto.guests
Now setup the content of the file /etc/auto.guests
In first position I will use a * which means anything. On exam use a NFS server. At end of line use & which means any file.
* -rw nfsserver:/home/guests/&
on SAMBA use the following which are a little more complicated:
* -fstype=cifs,username=ldapuser,password=password ://
The structure of file is the same. First is directory which by * means anything. Then there is alist of mount options
fstype=cifs tell automount that is a SAMBA server.
username=ldapuser,password=password – completly open the share to all LDAP users.
:// – this is the path to SAMBA server.

Configuring NFS and automount
Setup the NFS environment. First search the server packages:
# yum search nfs
This will tell us what we need. We need a nfs-utils t create a small NFS server.
# yum install -y nfs-utils
Create the file /etc/exports
# vi /etc/exports
Here I say what I’m exporting /data
mount options -rw
to whom I want to open it *(rw,no_root_squash)
Here I can put an IP address because NFS works with local machines only.
/data -rw *(rw,no_root_squash)
Start the server:
# systemctl start nfs
If is not starting, check the status with:
# systemctl status -l nfs
!!!!! Create the directory in order to share it before starting the server:
# mkdir /data
# cd /data
# touch file1
# systemctl start nfs
On client I will connect to NFS
# showmount -e localhost
This is show the mounts that are exported to server with localhost.
Mount the directory from NFS server to the mount point /mnt:
# mount localhost:/data /mnt
Now I should see the files from mount point:
# ls /mnt
Create automount to NFS environment:
edit the file /etc/auto.master and add the line:
/nfsserver /etc/auto.nfsserver
Create the file with name:
# vi /etc/auto.nfsserver
What I want to do? If somebody will go to directory blah on nfs server, will go to remote host /data
blah -rw localhost:/data
restart teh autofs:
# systemctl restart autofs
Automount have created the directory automatically:
# cd /nfsserver
Now there is nothing there but if I use:
# cd blah
Will go to directory