Partitioning: Part 1 (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 to
00:00
the Linux plus course here at Cybrary.
00:00
I'm your instructor Rob Goelz, and in today's lesson,
00:00
we'll be covering the first part of
00:00
our two parter on partitioning.
00:00
Upon completion of today's lesson,
00:00
you are going to understand MBR and GPT partitioning.
00:00
We're also going to cover fdisk and gdisk commands
00:00
to create partitions.
00:00
What is the MBR? Well, MBR partitioning;
00:00
the master boot record partitioning,
00:00
was designed to hold
00:00
four primary partition table entries.
00:00
Please, keep this in mind and remember
00:00
these four primary partitions,
00:00
this will come up in other exams
00:00
>> that you might get into,
00:00
>> and it probably will come up on the Linux plus exam.
00:00
This limitation was bypassed down
00:00
the road by allowing extended partitions,
00:00
but you can still only have four primary partitions.
00:00
Another limitation, a disk using MBR partitions
00:00
is only allowed to be 2.2 terabytes in size,
00:00
and that's due to a 32-bit
00:00
>> memory addressing limitation.
00:00
>> Now, MBR partitions are closely
00:00
related with BIOS and legacy boot,
00:00
so when you think BIOS and legacy boot,
00:00
you're going to think MBR.
00:00
Now GPT; the GUID partition table was created
00:00
to overcome some of
00:00
these limitations that we found in the BIOS.
00:00
A GPT partition is one partition
00:00
that extends across an entire disk and
00:00
the portions that are
00:00
partitioned are logical block addresses, LBAs.
00:00
GPT uses 64-bit LBA addressing,
00:00
which means that this can go up to
00:00
eight zettabytes in size.
00:00
I don't know about any of you,
00:00
but I've never seen a zettabyte in my entire life,
00:00
so I think we're probably pretty good for the future,
00:00
future proofing there with eight zettabytes.
00:00
GPT partitions are closely related with UEFI, EFI boot.
00:00
The EFI system partition we talked about in
00:00
Module 1 is actually a GPT partition.
00:00
Let's go ahead and get on to
00:00
some demo time and take a look at this.
00:00
We're over here in our CentOS environment again today.
00:00
The first thing we'll look at is the fdisk command.
00:00
When we think about fdisk,
00:00
think about MBR and legacy and BIOS.
00:00
What we can do is first take a
00:00
>> look at our disk devices,
00:00
>> and we can do this by doing an ls on
00:00
the device, the dev partition.
00:00
We're just going to look for things that start with
00:00
sd, so sd star.
00:00
What we can see is dev sda and then sda 1,
00:00
2, 3, 4, 5 and dev sdb.
00:00
Well, this is a disk,
00:00
dev sda and the partitions are 1,
00:00
2, 3, 4, 5.
00:00
We can see that dev sdb is
00:00
just a disk with no partitions.
00:00
That's what we're going to use.
00:00
What we're going to do to run the fdisk command is
00:00
we need to elevate our privileges first of all.
00:00
We're going to do dev, let's see,
00:00
sudo fdisk and let's
00:00
go ahead and print out some information.
00:00
Let's list with the l option.
00:00
Let's list some information on the sdb partition.
00:00
We're going to type in the password here to elevate
00:00
the privileges and we can
00:00
see the information about this disk.
00:00
This disk, dev sdb is eight gigs in size.
00:00
Now, if we want to add
00:00
a partition to this disk using fdisk,
00:00
we can just take off the l and what will happen
00:00
is we'll get into an interactive shell,
00:00
an fdisk command shell where we can do things.
00:00
The first thing that we're going to want to do
00:00
is type m right here for help.
00:00
What we can see is that in order to
00:00
>> add a new partition,
00:00
>> we actually have to use the character n,
00:00
n for new partition.
00:00
We're going to hit "N" and that's going
00:00
to prompt us for what we want the
00:00
>> partition number to be.
00:00
>> I don't particularly care,
00:00
so we'll accept the default as one and we'll also
00:00
accept the default for the first available sector,
00:00
there's 2048 and just hit "Enter."
00:00
Now the last sector we can actually
00:00
>> just specify a size.
00:00
>> Instead of having to do the math
00:00
and determine what sector it would be,
00:00
we can just say, "Hey, we want the scene
00:00
to be one gig in size."
00:00
We can use plus size number and then the type.
00:00
We're going to create a plus 1
00:00
gig partition and we hit "Enter."
00:00
We're off to the races, we created
00:00
a new partition of type
00:00
Linux file system and size one gig.
00:00
Now if we hit P, because remember right up
00:00
here it says P for print the partition table,
00:00
we can print the partition table.
00:00
That's what we need to do.
00:00
Now if we wanted to commit
00:00
this change and create the partition,
00:00
we could type the W command to write this out and exit.
00:00
But because this isn't the only
00:00
command we're going to be playing with today,
00:00
we're just going to hit, "Q" for quit
00:00
and now nothing is done.
00:00
No changes have been committed.
00:00
We haven't created a partition and in fact,
00:00
we can do an ls on dev sdbs,
00:00
dev sd star again.
00:00
We can see that we have
00:00
dev sda with all these partitions,
00:00
but dev sdb has been left alone.
00:00
There's no sdb1 and we're good to go.
00:00
Let's go ahead and clear our screen.
00:00
I'm going to hit, "Control L" to do that.
00:00
Now what we'll do is move over.
00:00
We'll look at the gdisk command.
00:00
Gdisk works pretty similar to fdisk.
00:00
Just keep in mind when you see gdisk,
00:00
think about UEFI and large drives
00:00
that are bigger than 2.2 terabytes.
00:00
Remember, MBR partitioning using
00:00
fdisk only allows you to go up to
00:00
2.2 terabytes in size on disk,
00:00
but you can go up to eight zettabytes
00:00
using GPT partitioning.
00:00
Just like we saw with fdisk,
00:00
we can do the same thing with gdisk to
00:00
display the information about our disk.
00:00
We can do sudo gdisk dash l,
00:00
and then do that on dev sdb.
00:00
We can see all sorts of good
00:00
>> information about our disk.
00:00
>> But pretty much the only thing we
00:00
really care about here is
00:00
that we have an eight gig disk, size eight gig.
00:00
What we can do in order to create
00:00
a partition is go into this
00:00
using sudo gdisk and get
00:00
into an interactive prompt just like we saw before.
00:00
Now, by comparison to
00:00
fdisk with gdisk in order to get help,
00:00
we need to type the question mark instead of
00:00
m. But just like with fdisk,
00:00
in gdisk, we can see that in
00:00
order to add a new partition,
00:00
we hit the n character on our keyboard.
00:00
Now, we're going to get prompted and it's going
00:00
to look probably pretty similar.
00:00
We're going to accept the partition number default.
00:00
We'll also accept the first sector here.
00:00
Then to determine the last sector,
00:00
why should I just give it a size?
00:00
We're going to say one gig again and then hit "Enter."
00:00
Now a little different wrinkle here.
00:00
It'll actually say that we're going to get this
00:00
as the Linux file system but if we wanted
00:00
to change the type of partition, we could do that.
00:00
We can hit, "L" and hit
00:00
Enter and we'll see all of the different codes.
00:00
We can hit, "Enter" and see more codes.
00:00
But for our purposes, we just want this to be
00:00
a Linux file system 8300 so we can just hit,
00:00
"Enter" to accept 8300.
00:00
Now if we wanted to see
00:00
the contents of this that has been printed out,
00:00
we should be able to choose P
00:00
>> and we see the same thing.
00:00
>> We see that we have
00:00
a single partition that
00:00
is one gig in size and it has code 8300,
00:00
which is the Linux file system type.
00:00
For our purposes, let's go ahead and write
00:00
this out so we can see this being changed.
00:00
We're going to write GPT data.
00:00
This will overwrite existing partitions.
00:00
That's okay because we're working in dev sdb.
00:00
It's a disk that I assigned to
00:00
this virtual machine specifically
00:00
for this exercise so no harm, no foul.
00:00
I'm going to hit, "Y" and hit, "Enter"
00:00
and now we'll see that that's been created.
00:00
Now if we go ls dev sdb,
00:00
or ls dev sd star,
00:00
we can see not only do we have
00:00
sda with all of its partitions,
00:00
but we have sdb in a single partition.
00:00
We've reached the end of the lesson today.
00:00
In today's lesson, we covered
00:00
the MBR and GPT partition types.
00:00
We talked about the fdisk and gdisk commands.
00:00
Thanks so much for being here and I
00:00
hope to see you in the next lesson.
Up Next