So friends, let's begin this subject by discussing the whole concept of
partitions.
What are they actually used for? Why do we even need them in the first place?
But really, when we're thinking about why we need a partition, primarily,
it's going to allow us to organize our data.
And the way this actually happens is via segmentation on the physical disk.
So let's maybe say we happen to have a disk right here.
This could just be a regular hard drive.
Now suppose this is just one large disk that happens to be completely unpart WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now suppose this is just one large disk that happens to be completely unpart
itioned.
So what do we actually have on this disk?
What we're going to have, let's maybe say our operating system, the OS.
And let's also say we happen to have some data on the disk.
So that could be just your regular files, perhaps maybe some pictures, maybe
some MP3s,
that type of thing.
Now as it transpires right here, because we have no separation between the
actual operating system
and the data, as we begin to write more and more data on the disk, things as
you can see here,
gradually become more and more cluttered. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
gradually become more and more cluttered.
And eventually as the disk gets filled up with more and more data,
eventually the disk becomes to become overrun and it effectively bogs it down.
Now the good news is, is that we do not actually have to contend with this in
the real world.
We don't really operate in such a way.
So what does it we do?
Well, you guessed it.
We make use of partitions.
Let's then reimagine the same type of scenario this time using the concept of
partitions.
So let's draw out our circle right here representing our hard disk.
And just like you would with a pizza, let's say we wanted to slice this up and WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And just like you would with a pizza, let's say we wanted to slice this up and
subdivide it.
In this case here, the way we are subdividing it is via the use of the
partitions themselves.
So let's just take this chunk right here.
Let's imagine we have a quarter of the disk and we say, hey, on that particular
partition,
all we want to have is the operating system itself.
It's going to have its own little segmentation.
And let's maybe say for the rest of the disk, we're just going to use it to
store data.
Now perhaps in the real world, maybe you would like to subdivide the disk into
many more slices. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
many more slices.
Maybe we've got a slice here and another slice here and perhaps another chunk
here and here, whatever it may be.
But just for the illustration, let's just say we just have these two partitions
,
a partition dedicated for the operating system and another for the data.
What the net effect is here is as we write more and more data onto the disk, as
we saw before,
you know, data here, data here, and it begins to fill all this partition up.
The difference here is that we actually have this type of physical boundary as
set out by the partition itself. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
set out by the partition itself.
So we're never, ever, ever going to be writing data into this particular
section of the disk
because it has been partitioned off and is used for something entirely
different.
This is the organization and segmentation that I was talking about.
Now, of course, once again, if you want to get a little bit more creative and
inventive with the partitions,
you could have maybe a book partition.
Maybe you want to have a partition that is designed for backups.
And hey, maybe you just want to utilize partitioning for the security aspects
of having that isolation WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
of having that isolation
so that sensitive data is kept separate from the rest of the system.
So these are just some of the reasons why we would maybe want to utilize
partitioning.
Let's briefly discuss what different types of partitioning tables we can
actually use.
So depending on the type of firmware on the system,
so if you happen to have an older system, which is utilizing the BIOS firmware,
the type of partitioning table that you would want to be using would be
something known as the MBR.
This is the master boot record.
Now, the master boot record style of partitioning is a lot more limited than WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now, the master boot record style of partitioning is a lot more limited than
the more modern version
in the sense that we only have support for four partitions.
Or more accurately, should I say, we have the option for four primary
partitions.
Now, when I'm talking about a primary partition, I'm talking about the type of
partition
that is capable of booting an operating system.
Now, if you happen to recall from your red hat, certified system admin studies,
you can kind of get around this limitation by creating three primary partitions
.
And then you can add in what is known as one logical extended partition. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And then you can add in what is known as one logical extended partition.
Now, this particular partition here can actually be further subdivided into
many more volumes,
which pretty much allows you to have many more little storage containers,
so to speak, whereas on modern systems, if you happen to be utilizing the UEFI
firmware,
which is much, much more common as we see nowadays,
we have the ability for the support of a GPT style partitioning,
which is much more advanced, much more expressive and has support for 128 WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
which is much more advanced, much more expressive and has support for 128
partitions,
much, much better than the four partitions offered by MBR.
So these are the types of partitioning tables we can actually create.
The question, therefore, is how do we actually create these particular
partitions?
Well, as is so often the case in Linux, we have many different utilities to do
similar jobs.
We can utilize something known as F-disc, which was originally developed just
to create MBR style partitions.
And then we had tools such as G-disc come out, which supported GPT style
partitioning,
as well as another utility known as Parted, which is the partition editor. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
as well as another utility known as Parted, which is the partition editor.
Now, in the case of Ansible, the partitioning tool that we're going to be
focusing on is Parted.
This one here is the one we're going to be using within our Playbooks.
So in order to help us work with our lab environment,
what we want to do is you want to add additional disks to our virtual machines.
Now, you can add as many new disks as you want to as many virtual machines,
but at least at a very minimum, add one disk to one of your machines.
So let me show you how I can do this here on VM, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So let me show you how I can do this here on VM,
where if I go to one of my devices that are going to be managed by Ansible,
which in my case here is my blue box, if I go to settings, and then I go down
to hard disk,
and I choose add device, and then I say new hard disk, and then select add.
What it's going to prompt me to do is to specify the size of the disk that I
want to create.
Now, by default, as we can see here, it's going to create a disk of 20 gig and
size that is way more than I need.
So I'm just going to move it down to let's maybe just say one gig. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So I'm just going to move it down to let's maybe just say one gig.
Okay. So with that now done, I'm going to choose apply.
All I'm going to do here is press X, and then I will just start up my machine.
So if I go to my terminal right here, and I just say the command man part it's,
we can see the manual page for the utility that we want to be using a partition
manipulation program.
Now it says if we do dash L, we can actually list the partition layouts on all
the block devices.
So let's try that.
Okay. So I will say pseudo parted dash L, and now I'll type in my super user
password right here. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
password right here.
Now look at this right here.
It tells us the summary of our disks right here.
We have one particular disk here, which is going to be our book partition.
This is the fat 32,000 system, and then we have this one here number three.
This is LVM, our logical volume management.
We'll talk about that in a little bit more detail within this very scale.
The one that I just added was this one right here, you see that 174 meg, which
is one gig.
Now also an output here, we can actually see the contents, which is a device is
in dev NVM E 0 N2. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
in dev NVM E 0 N2.
Now this is because I happen to be using a solid state drive,
whereas if you happen to use a traditional hard disk,
you might see the option as dev SDB.
The name itself doesn't actually matter just as long as you know to reference
the correct device,
whatever the name happens to be.
So now we have this unpartitioned physical disk.
What we want to do is to make use of the part of tool to actually write the
partition onto the disk itself.
Now the first thing we're going to do is to quickly see this manually, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now the first thing we're going to do is to quickly see this manually,
and then we'll be able to walk through the tasks or rather these steps
in order to complete this task via automation using Ansible.
So all I'm going to do here is copy the name of the disk that I want to target
and partition.
All I will do is I will say sudo part it and then paste in the name of the
device itself.
So let's hit enter.
We now go into this interactive menu.
If I say help, we can see all of the available options.
And the case here, what I want to do is to create a new disk label to generate
a partition table.
Okay, so I can say help MK label. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Okay, so I can say help MK label.
We can see all of the available labels that we have here.
If I want to choose GPT, this is one of the options I have available to me.
So I can say MK label GPT.
I can say help on MK parts.
We can see the types of partitions that I can create would be a primary
partition
or a logical or extended partition, just like we talked before.
So now I will say MK parts primary to make a primary partition.
It is suggesting the file system type to be EXT2, which is very, very outdated.
Much more likely you would choose EXT4 or in the case of my railbase system. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Much more likely you would choose EXT4 or in the case of my railbase system.
I'm going to choose XFS.
Now I'm going to specify where the partition should start.
So I will say 0%, which is at the very start of the partition.
And I want to use the entire partition.
So I will say the end will be 100% of the disk.
If with that now done, if I select prints, this here is going to be our
partition disk.
And now what I can do is press quit to write the changes.
And now if I say pseudo-parted dash L, type in my passwords.
And now this particular disk here is using the GPT partition style. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And now this particular disk here is using the GPT partition style.
It is a primary partition, meaning that it can support an operating system.
And we are using the entire disk.
If we so wish though, we could have subdivided this disk into small partitions
for different purposes.
This here though is ultimately the process that we want to automate.
So now if I use part of on the same disk, and I just say print, we can actually
see the partition number, which is number 1.
The very first partition makes sense.
We only have one.
Now what I can do here is just say RM to remove and then specify the number of
the partition. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the partition.
So if I say RM 1 and to enter, now what I can do is press quit.
And if I now re-list my part of information, now we have actually removed that
particular partition.
So now that we have the primer on partitions and the use of the part of utility
out the way,
let's now walk through the automation of this particular process next.