Now don't worry,
mounting our filesystems is far easier than trying to mount horses.
We've already seen a little bit of our mount command when we've been
working with ext4 filesystem, our ISO filesystem, our btrfs.
So the command is mount the device to a mount‑point. To
unmount it, we use the umount command, and we can either
umount the device or the mount‑point.
Often, the mount‑point is most easy.
If we want to ensure that our filesystem is mounted at boot time,
we can add it through to our filesystem table, /etc/fstab.
Usually, we want to mount by the unique identifier, the UUID of
the filesystem, rather than by a device name.
The device name may not be detected the same each time.
So what is, say, /dev/sda today might turn out to be sdb the following day.
So very often where we're using hardware as our devices, we would go through
and use the UUID to mount our filesystems. To read that UUID, we have the
command, blkid. So we're going to move out to our command line, and we're
going to look at the basics of mounting and unmounting using the mount command
and the umount command, but also checking our UUID with the blkid and
persisting our mounts in the fstab file. And here we are back working on our
Alma Linux 8 system. And we're going to investigate a little bit about our
mount command.
If I go through and just hit the mount command by itself, we can see that we get
a vast amount of verbose information because there are very many memory resident
filesystems, as well as disk‑based filesystems.
To drill down a little bit, we can use, then mount ‑t for the type.
If I do something like iso9660, we can then see our
ISO filesystem being mounted.
If we wanted to look at, let's say, our xfs filesystems, we can go through and
include xfs. If we wanted to look at ext4 filesystems, ext4, I think, was our
encrypted filesystem, that's now no longer mounted. But we can get an idea or
summary of what is mounted by going and include, then the filesystems that we
want to particularly check on.
If I want to mount my filesystem, I can go through and
say mount, then our /dev/loop1p2.
This is my xfs filesystem and mount it through to, let's say, the data
directory. If I go back now and check the xfs filesystems, we see now that's
correctly showing. To umount it, again, unmount the device, but normally, I use
a umount command against the directory, the mount‑point, as that tends to be
easier. If we want to persist the mount, what is loopp1 today and partition 2
might be different tomorrow.
So we're generally going to be using a UUID.
We can use the command, blkid, and then /dev to
specify our device, and then loop1/p2.
And we should be able to, then go through and read the
information. So we can see we've got the label on it.
We've got the UUID.
We've got our block size, the type, and even the partition UUID.
But we're looking in the filesystem UUID. I'm going to just go through
and copy that to my paste buffer, and we can then go through and add it
to my /etc and fstab, my filesystem table.
Let's move this to the top of the screen, and hit Enter. We can see the
existing entries are by their UUID. I can then go through and insert a new
line, and I can just paste this in. The quotes don't make any difference so
are not going to be processed by the system.
I want to mount to the data directory.
It's an xfs filesystem. I can put xfs, or I could put
auto. Auto detect is the default anyway,
but I have to put an option in here. But obviously, we know that it's
xfs, so we might as well put xfs in. Then we have our mount options.
We can just use the defaults. Unless there's anything particular that
you need, we will leave it at the defaults, but you might want to
start enabling things like quota management, so you might add extra
options in.
The first value we're putting in is for an old backup system.
It's not really used with xfs. I's not really used at all, so
we just turn that off. And the filesystem check on boot is only
for our ext filesystems,
not for xfs, so that always should be 0 for xfs. Now with that done,
we want to make sure that the filesystem is not mounted, so mount ‑t,
and then xfs. So we can see we only have the one xfs filesystem mounted,
and then I can go through and mount /data.
We're not saying what to mount to data, so we're having to go
through and read it from the fstab file, so it's proving our
entry is going to be correct.
Now when I look at mount ‑t xfs, we can see I've got the
correct device mounted. But if you recall,
we created these loop devices. These loop devices won't be
available on boot unless I go through and create a script to put
them in during the boot phase. So for ease,
I'm just going to go through and comment this out.
So if I go through now,
back to our previous entry, and then I can just go through and insert a
comment in front of it, so it's not going to be read.
Otherwise, when trying to boot,
we're going to fail to find our unique identifier, so we're going
to search through every file in our filesystem.
It can only look for devices, so it would fail
because the loop device doesn't exist.
So let me go through, then and save this, and then we
know we're safe to reboot our system.
We're going to return now to the slides, so we might just
summarize a little of what we've looked at.
I know it's been a long section,
but let's make sure we're certain of some of those things that we've taken a look at.