In this video, you'll learn how to create partitions.
There are different utilities that can be used.
Fdisk is the recommended utility that I'm going to use here.
It has been around since the earliest Linux versions.
And the nice things about it, well, it offers easy access to advanced features.
It also has completely been reworked to support MBR as well as GPT partitions.
There's only one thing to be aware of.
On a completely new disk, you need to specifically create a GPT partition table using the G option
in Fdisk because it creates MBR by default.
In past RHEL versions, there was Gdisk.
So Fdisk was for MBR, Gdisk was for GPT, but as the Gdisk functionality has now been merged
in Fdisk, it's no longer needed.
Some people like Partit.
Partit was introduced to make partitioning easier.
I don't like Partit.
And that is because advanced features are a little bit hidden, but it can be scripted
easily.
When creating partitions, you need to know about partition types.
A partition type is a low-level identifier of the operating system, the file system,
and the boot manager that they're using a specific partition.
Partition types were very important in the past.
Currently, partitions will work if the wrong partition type is set, but it is rumored that
on the RHCSA exam, it might cost you points.
So be mindful of it.
In the Fdisk utility, you use T to change the partition type.
And in older Fdisk, you needed to use hexadecimal codes.
Nowadays, it's a lot easier because you can use an alias to set the partition type.
Linux is the standard.
Other options are swap for swap space or UEFI for the UEFI boot partition or LVM for partitions
that are meant to be a part of the logical volume manager.
And if you want to get a complete overview, you can use L in Fdisk to print a list.
Now, let me show you how to create a partition using Fdisk.
So in order to prepare for this demo, I've resized my primary hard disk, and I've created
the secondary hard disk.
So originally, my NVMe 0 and 2 was 20 gigabytes.
Now it is 30.
And I added a new disk with a 20G size that is completely unused.
If you look at the current layout, you can see that there's 20 gigabyte use on this NVMe 0 and 2.
And I'm going to add more partitions on that.
So Fdisk on dev NVMe 0 and 2.
And oh boy, message in red.
Is that serious?
No, this is not serious at all.
This is showing us that there's a PMBR size mismatch.
PMBR is the Protective Master Boot Record.
And this Protective Master Boot Record was still referring to the old size of 20 gigabytes.
Well, that has now changed.
And it's telling us that this will be corrected by right.
Also, it's telling that this disk is currently in use and repartitioning is probably a bad idea.
Well, that is not true.
It's a good idea because I know what we are doing.
And do not unmount all file systems.
That is really not necessary.
We are not going to change anything in the current configuration.
We are just going to add new stuff.
Then it's coming with an annoying thing.
Command M for help.
I really don't get it.
M for help?
Come on.
This is M for menu.
And why wouldn't you use H for help?
Look at that.
The H option isn't even used.
But this has been like this forever since the beginning.
So let me not complain about it and start by using P to print the partition table.
So here we have P.
And this is showing that we have three partitions at the moment.
So for every partition, we have a start sector and we have an end sector.
Sectors are entities with a size of 512 bytes, as we can see here.
And to make it easier to read, we can see the size in the human-readable format as well.
So if I want to create a new partition, I'm using N for new.
And then it's prompting, which partition do you want?
Well, I want partition number four.
And first sector, well, let's just start at the first available sector.
And last sector, I'm using plus one, uppercase G.
Remember, Linux is case-sensitive to create a one-gigabyte partition.
Using P to verify, and a new partition has been added.
If you're happy with that, use W to write,
and the change should immediately be visible if you use LSBLK.
As you can see, the new partition is here.
I'm not doing anything with it yet.
We still need to create a file system, but we'll talk about that later.
Before doing so, I also want to create a new partition on my brand-new disk
so that you can see what is going on.
So AppDisk on dev NVMe 0N1 is telling me
that it created a new DOS partition disk label.
Well, that's something that I don't like.
The DOS partition label, that's an MBR partition type.
I don't want a DOS partition label.
I want a GPT partition label, so I need G.
And there we can see that it created a new GPT partition label.
And now when I use N, we can see that the partition number,
well, it's the same as what we have done before.
Start is always 2048 because the first one, maybebyte, is reserved for metadata.
And then you enter what you want to do.
Let's create another gibibyte partition.
P to verify if this looks like what you wanted, and W if you are okay.
And always use LSBLK for lost list block devices
to verify that the new partition indeed has been created successfully.