In this video, we'll talk about AutoFS.
When you are setting up AutoFS for a directory,
pre-AutoFS content is no longer accessible.
A common error, for instance, is that you set up
home directories for this home LDAP
and you mount it on slash home.
You know what happens to all original home directories,
no longer accessible.
So make sure that when in etc.auto.master,
you identify the directory that AutoFS should manage.
It's a new directory that is not yet used for anything else.
Also in auto.master, you identify a secondary file
that is used for additional mount information.
And that is one thing that is a little bit weird about AutoFS.
There is the main file.
There is a secondary file.
So there's always two files and two directories
involved in configuring auto mounting through AutoFS.
Now, the contents of this file in etc.auto.master
looks like slash data etc.auto.nfsdata.
What does that mean?
Well, slash data is the directory
that AutoFS should manage.
And it is further specified in etc.auto.nfsdata.
And next, in etc.auto.nfsdata, you
will identify the subdirectory on which to mount
and what to mount exactly.
So that would look like files, colon, rw,
nfsserver, colon, slash, nfsdata.
Now, about this files, this files is a subdirectory.
So in the end, you end up with the directory
slash data slash files.
So if you are in this slash data directory
and you access the files directory,
then AutoFS will wake up and it will automatically
mount the share.
To do this, you do need to make sure
that the AutoFS service is installed and started.
So dnf install and systemctl enable AutoFS.
And one tip on the exam, you might
want to have a look at etc.auto.misc.
It's a very nice syntax example.
If you are a little bit lost in the syntax,
you don't forget it exactly.
If you understand etc.auto.misc, you
will be all right on the exam.
Let me show you.
Let me start with the dnf install minus y AutoFS.
And then I'm checking the etc.auto.master.
So what do we see?
Well, we see an example line like slash misc etc.auto.misc.
So slash misc is managed by AutoFS
and it's further specified in etc.auto.misc.
So what is in etc.auto.misc?
Let's check it out.
As you can see, we have one example line for CD.
So if you go to slash misc slash CD, then with these options,
the device slash dev CD ROM will be mounted.
If the target starts at the column,
then AutoFS is interpreting it as a device.
The most important line for your exam
is this one, indicating that as we access slash misc slash
Linux, with the options RO and soft,
an NFS mount is done to ftp.example.org
column slash pub slash Linux.
It's a little bit misleading that the name has FTP,
but by the syntax of the target, you
can see that it's an NFS share.
So we need something like that.
Let me show you how to do it.
So back to etc.auto.master, where
I'm going to add slash NFS data.
And I'm further specifying it on etc.auto.nfs data.
That's all.
And then I need to go to etc.auto.nfs data.
And in there, I'm specifying files
minus RW NFS server column slash NFS data.
Don't forget to systemctl restart autofs.
And now if we go into the directory,
well, let's first go in the root directory.
There you can see that suddenly we have a directory NFS
data in the root directory.
So let me go in this NFS data.
Let me use ls minus 8 to show you that there is nothing.
But if I'm using CD files, that is working anyway.
And that is because AutoFS is taking care of it.
You can see that when you use mount,
you see that there is etc.auto.nfs data.
That is the AutoFS service that is listening
and which is taking care of mounting
this specific share for me.
And that's how AutoFS works and makes accessing target
directories convenient.