Persistent Mounts (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hello Cybrarians and welcome back
00:00
to the Linux+ course here at Cybrary.
00:00
I'm your instructor Rob Gels,
00:00
and in today's lesson,
00:00
we're going to be discussing persistent mounts.
00:00
Now, upon completion of today's lesson,
00:00
you're going to be able to understand
00:00
how those persistent mounts work,
00:00
you can also create
00:00
a persistent mount entry using the /etc/fstab file,
00:00
and we'll talk a little bit about
00:00
the purpose of /etc/crypttab.
00:00
Now, in the previous lesson,
00:00
recall that we created two file systems,
00:00
the ext4 file system,
00:00
and the xfs file system,
00:00
and we mounted both in the mount directory.
00:00
But then we also unmounted
00:00
those file systems using the umount command.
00:00
If we were to reboot this Linux system right now,
00:00
we wouldn't see those files systems anymore.
00:00
What if we wanted those file systems to be persistent?
00:00
What if we wanted them to stay mounted after a reboot?
00:00
How do we do that? Well, let's find out
00:00
>> with some demo time.
00:00
>> Here we are in our CentOS environment,
00:00
and as I alluded to previously,
00:00
the etc fstab file is used to
00:00
configure persistent mounts and
00:00
so what we'll do to get started,
00:00
we'll take a look at this file.
00:00
What we're actually interested in
00:00
is just these lines here at the bottom.
00:00
These are a couple of columns, 1,
00:00
2, 3, 4, 5,
00:00
6 columns that indicate how to
00:00
persistently mount any file system on a Linux system.
00:00
From left to right,
00:00
the columns are going to be the file system UUID.
00:00
Sometimes in this column here instead of UUID,
00:00
you might also see a label or
00:00
a device dev stb-1 or dev sdc-1.
00:00
I prefer to use a UID just for safety sake.
00:00
We'll next see the mount point or
00:00
where the file system is being mounted.
00:00
We see some of these here like root,
00:00
boot, home, and swap.
00:00
The third column indicates the file system types.
00:00
For example, we see xfs,
00:00
ext4, and swap.
00:00
Then this fourth column indicates the options.
00:00
In this case they're just a false and
00:00
that's all we're going to use for this lesson.
00:00
These last two columns are
00:00
used to indicate whether or not you take
00:00
a dump of the file system and it dumps
00:00
out the running state of
00:00
the file system if there's an issue
00:00
or if you do a file system check and fsck
00:00
on boot to make sure that
00:00
the file system itself is working normally.
00:00
That is what we need to modify in order to
00:00
mount their file systems that
00:00
we created in the previous lesson.
00:00
What we can do first,
00:00
let's go and clear our screen by hitting
00:00
Ctrl L. Let's use
00:00
a Blkid command to display
00:00
all of the block devices and their UUIDs.
00:00
As I said, I like to use
00:00
the UUIDs in order to add stuff to etc fstab.
00:00
Now, we can see that the last two lines
00:00
are the only two that we care about.
00:00
Our file systems for ext4
00:00
and xfs at dev stb-1 and sdc-1 respectively.
00:00
Now, if we wanted to grab those,
00:00
we can just copy and paste these in one at a time,
00:00
but we'd have to go in and out of
00:00
the etc fstab file with Vim.
00:00
I'm actually going to show you
00:00
a neat little trick that I like to use.
00:00
We're going to use Blkid and then
00:00
we're going to pass that using
00:00
the pipe to tail and we'll do
00:00
tail and [inaudible] at the last two lines.
00:00
Now we've got the last two lines and now what we want
00:00
to do is just grab the second column,
00:00
the second entry here, the UUID.
00:00
We can see that everything in here
00:00
is separated by a space.
00:00
We can use another command called cut.
00:00
Then we can see that the delimiter, in other words,
00:00
the things that break up that line are
00:00
spaces and we can say that we only
00:00
>> want the second field.
00:00
>> Now we can see that all that gets output is the UUID.
00:00
The very final thing I need to do to put all that into
00:00
etc fstab is I need to use these error redirections.
00:00
What I'm going to do is direct this content to append,
00:00
to add to the end of etc fstab.
00:00
If we just use one arrow,
00:00
it would overwrite etc fstab, we don't want to do that.
00:00
We use two arrows, go into the right,
00:00
and that indicates that we're going to append
00:00
etc fstab all of the UUIDs. We can hit "Enter".
00:00
Now if we go back into Vim etc fstab,
00:00
we'll see that our last two lines are the UUIDs for
00:00
the ext4 and xfs file system.
00:00
Now, I'm going to clean these up a little bit,
00:00
I don't really need these quotation marks.
00:00
Those are fine, but for consistency sake,
00:00
I like to remove them.
00:00
I'm going to add the two mount points
00:00
we're going to use for these two file systems,
00:00
so mount ext4 and mount xfs.
00:00
Now I need to specify the file system types.
00:00
We have ext4 and we have xfs.
00:00
Then for the last parts here,
00:00
we're just going to use defaults and
00:00
00 for these as well.
00:00
This is just a demo.
00:00
But if you want to read up on that,
00:00
certainly go ahead and check out
00:00
information on setting up
00:00
etc fstab and the different options
00:00
you can set on different file systems.
00:00
Now let's go ahead and we'll add
00:00
00 for this as well and hit
00:00
Escape: WQ to write and quit out of the file in Vim.
00:00
Now if we do a tab on this file as well,
00:00
you can see that our changes have been made.
00:00
Our last two lines are added and we're all good.
00:00
Now, if we wanted to see if these are mounted,
00:00
well, let's try and run the mount command,
00:00
mount, grip SD.
00:00
Wow, that's weird. We don't have
00:00
them mounted. Well, why is that?
00:00
Well, recall that we unmounted
00:00
these file systems at the end of the last lesson.
00:00
Just because we added in that
00:00
etc fstab doesn't mean they've been remounted,
00:00
we still have to remount them.
00:00
Normally upon reboot,
00:00
the file system will read from etc fstab or
00:00
rather the Linux operating system will read from
00:00
etc fstab and it will mount anything in there.
00:00
But luckily for us, the mount command has an option,
00:00
the dash a option that automates
00:00
all file systems that it finds in etc fstab.
00:00
We're going to run mount dash a.
00:00
Once that's run, we can run mount again
00:00
>> and grip for SD.
00:00
>> We'll see that stb-1 and sdc-1 have been added.
00:00
Now, if we reboot our system,
00:00
it would come back up exactly the same stb-1 and
00:00
sdc-1 would be there because
00:00
they have been added to etc fstab.
00:00
We have one final thing to touch on in this lesson.
00:00
Let me clear my screen with Ctrl
00:00
L. That thing that we need to
00:00
touch on is the etc crypttab file.
00:00
This file is used to
00:00
persist a mount for an encrypted drive.
00:00
Now, Linux uses something called
00:00
Linux Unified Key setup for Drive Encryption.
00:00
These drives are decrypted during the boot process,
00:00
so this information easily put into the etc crypttab
00:00
file so that Linux knows how to
00:00
>> decrypt the drive on boot up.
00:00
>> Now, I don't actually have an encrypted drive to show,
00:00
so I really have no etc crypttab.
00:00
In fact, this is just an empty file.
00:00
But be aware of
00:00
etc crypttab for the purposes of the exam,
00:00
understand that etc crypttab
00:00
is used when you're working with
00:00
encrypted drives so that the drive
00:00
can be decrypted upon boot.
00:00
We will talk about much and
00:00
drive encryption later in this course.
00:00
But with that, we come to the end of the lesson.
00:00
In this lesson, we talked about
00:00
persisting a mount by adding entries,
00:00
the etc fstab file,
00:00
and we also talked about what
00:00
the etc crypttab file is used for.
00:00
Thank you so much for being here and I look
00:00
forward to seeing you in our next lesson.
Up Next