Hello, and a big, warm welcome to this Pluralsight
module, Managing Linux Filesystems.
My name is Andrew Mallett, and do you know what? I'm here as your instructor
to help guide you through the module, a module where we're going to be taking
a look at investigating our Linux filesystems.
This follows on directly from the module where we took a look
at managing disks and partitions, and that needs to be
completed before you start this one.
We're reliant on those disks and partitions that we previously created.
Of course,
we'll be looking at filesystems, so creating and managing
filesystems. That's going to be ext4 filesystems, xfs
filesystems, as well as btrfs filesystems.
And we'll also be learning how to both mount and unmount those
filesystems and add entries into our fstab file.
So when you're ready, sat comfortably, we shall begin. Now as you know,
within our last demonstration, we added the ext4
filesystem to our encrypted partition.
We can go through,
gain our root privileges, and then using luksOpen, we can go
through and open up that encrypted device.
Remember, we assign a dev mapper name to it here. Again, we're
keeping to my‑data. We can gain information on an ext4
filesystem using different commands.
We can get most of the metadata from our filesystem using the
dumpe2fs command. Here, we're looking not just at the output, but
searching for specific information.
We're looking at a case insensitive search for mount count.
We'll find that we've got a couple of keys being returned, and we're
able to see the mount count where we're looking at how many times
we're allowed to mount our filesystem before we need to perform a
check. Now on modern ext4 filesystems,
this is usually disabled, but it's worth checking. Otherwise, you
might find that you turn on a system, and it's forced to do a check
of a filesystem, which can take many hours, depending on the size of
the filesystem and the speed of your disk, so it's always worth
taking a look at this.
We can also see the properties, but not so much of the metadata
relating to the blocks, using the tune2fs command, ‑l will list
those properties. We can go through and change some of these
properties, including the disk label.
The disk label, then allows me to reference that system by
its name rather than its device name. In some respects, so
where we're using dev mapper names,
we don't have to worry about the uniqueness of the name because
the filesystem ensures the uniqueness in any case. But we're not
limited just to ext4 filesystems.
Ext4 and xfs filesystems are very common in most Linux distributions.
Again,
working on our Alma Linux system and gaining root privileges, we can now go
through and format our loop1p2 partition with xfs. It will print some
information once it's been formatted, but we can always reprint that
information by using the xfs_info command.
One of the big advantages is defragging the filesystem.
We can defrag a filesystem whilst it's online. Here, we're actually working with
our root filesystem, which in my Alma Linux system is xfs.
So of course, the root filesystem is online, and
we're going to be able to defrag it.
If we needed to change the label, then we use the same option as before, the
uppercase L, which allows us to set a label on our device.
Other filesystems are available, not just xfs and ext4. The btrfs filesystem,
the B‑tree filesystem, is newer and based around the ReiserFS, which was very
big in SUSE, as well as ZFS, which was developed by Solaris.
The btrfs is not available in Red Hat Enterprise Linux 8, but it is
available in openSUSE and Ubuntu, and this then shows the strength
of the CompTIA certification where they cover all operating systems,
so we can see all elements that you are going to need. Working on
our openSUSE system,
we can install btrfs using zypper in btrfsprogs. We can create a couple
of disk files, and then go through and link them to devices. Working
with our first device, loop0, we can go through and format our
filesystem. So it will appear very much like any of our other
filesystems, but there's a lot more to come.
We're going to create a directory so we can mount this.
We're just calling it /data/sales.
We might have to use mkdir ‑p if you don't have an existing
data directory. We can then go through and mount our device
into the sales directory.
Once it's mounted, then of course, it's online and can be
used. Whilst it's online and in use, we can go through and
check some of its properties.
But more importantly,
we want to then go through and add in the second device to the sales
directory, so we can dynamically assign new space as we go along.
So our filesystem is used.
We then go through and add in another device. As we check the available free
space within the data/sales directory, it will have doubled,
going from 1 GB to 2 GB whilst the data was online and in use.
So why don't we move out to our command line so we can see some of this and how it goes together?