Let's talk about systemd mounts.
That's probably not something you
will find on the RHCSA exam, but it's
what's happening behind the scenes,
and I need you to understand.
So lines in ETC FSTEP are converted to systemd mounts.
You can check the directory run systemd generator
for these automatically generated files.
Mounts can be created using systemd.mount files.
It's a unit type, and you use these mount unit files
to be more specific in defining dependencies.
That's one of the big advantages of systemd mounts.
You want to see what it looks like?
Use systemctl cat tmp.mount, or have a look at the files that
were automatically generated.
And let me show you how we can use this knowledge
to convert the mount that we just added into ETC FSTEP
to a systemd mount.
So I'm going to run systemd generator.
And in run systemd generator, we can
see that there are different mount
files that have been created.
Now, these mount files follow the convention
that the name is the name of the directory where
the device should be mounted, like here, files.mount.
That's the one we just created.
When I use cat on files.mount, what do we see?
We see what it wants to mount.
So devdisk by UUID.
That's a file system reference to the UUID that I just used.
And where is files and type is XFS and options is no fill.
That's exactly what we use, right?
So what if I copy this files.mount
into etc systemd system?
Then I'm going to use systemctl daemon reload.
If you create files for systemd, you
should always use daemon reload.
And now I can use systemctl enable.
Minus minus now is not needed, but I'm
going to enable files.mount.
Oh, no, it's giving me that this is missing information.
The unit files have no installation config.
So what do we need?
We need an install section.
And this install section, well, is easily created.
So I'm going to use my favorite editor, etc systemd system
files.mount.
And there, I'm going to add an install section.
And in this install section, wanted by is multi-user.target.
I don't want to think about the targets too much at this moment.
Just add it to the multi-user.target,
and that will do it.
Now, I'm also going to remove this.
No, I'm not going to remove this.
Sorry, I changed my mind.
This is making sure that this mount will only
happen once the block device is present.
So now that I have my install section,
I need to daemon reload, and I should
be able to enable files.mount.
Well, that is looking OK.
Then I can get back to etc fstab and remove the last line
from etc fstab.
And then let's reboot to figure out if this is working.
So let's check it.
Systemctl status files.mount.
And what do we get?
Well, we get the mount is active.
And lsblk, if you want to double check,
is showing that this nvme0n1p4 is mounted on slash files.
So that worked.
So systemd mounts can be an alternative
for the etc fstab mounts.