Block Devices (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
>> Hey Cyberians.
00:00
Welcome back to the Linux plus course here at Cybrary.
00:00
I'm your instructor Rob Gils and in
00:00
today's lesson we're going to
00:00
be discussing block devices.
00:00
Upon completion of today's lesson,
00:00
>> you'll be able to explain block storage,
00:00
>> you're going to be able to use the lsblk
00:00
and blkid commands and we're also going to learn
00:00
how we can leverage that sys block directory to get
00:00
information of block storage and block devices.
00:00
What is a block device?
00:00
Well, if you recall a few lessons back,
00:00
we talked about logical block addressing,
00:00
how that's the foundation of GUID partition tables.
00:00
Block devices store data in fixed-size blocks.
00:00
For example, that could be a 512-byte,
00:00
1-kilobyte or a 2-kilobyte block,
00:00
but the main thing we got to
00:00
understand is that the block
00:00
is the smallest logical unit of addressing,
00:00
that's the smallest size data
00:00
that Linux kernel recognizes.
00:00
That begs the question,
00:00
>> how do we identify these devices?
00:00
>> That's a good question. Why don't we
00:00
answer it with some demo time?
00:00
We're over here in our demo environment.
00:00
We're back on CentOS today and the first command
00:00
we're going to look at is called lsblk.
00:00
The lsblk command is used to list
00:00
block devices and it
00:00
displays block devices in their partitions.
00:00
If you use it just by itself by typing lsblk,
00:00
what we're going to see here is it just prints or
00:00
lists block devices.
00:00
>> This is great,
00:00
>> we can see for example that devsda1 is hosting boot,
00:00
>> we can see that sda2 is
00:00
the root partition for the root file system,
00:00
and we see devsda5 is
00:00
holding home and then the sdb stuff that we set
00:00
up last time isn't really doing much of anything
00:00
right now because we haven't set it up to do anything.
00:00
Now, if we wanted to use some other commands
00:00
with lsblk, we can type let's say
00:00
lsblk-p and what this
00:00
will do is it'll print the full path,
00:00
the p option for path.
00:00
It tells us that it's not just sda but it's
00:00
devsda and it's not just sdb1, it's devsdb1.
00:00
That just helps us to identify where it actually
00:00
is on the Linux file system and then we
00:00
can also type in lsblk-fs
00:00
and it will display file system information.
00:00
It will tell us what the file system type
00:00
>> that is in use,
00:00
>> so on devsda1 which is actually
00:00
the boot partition that's using exd4,
00:00
the root partition is using xfs,
00:00
and then devsda5 which is
00:00
the home partition is using xfs as well.
00:00
Let's go ahead and move over to
00:00
the next command we're going to play with.
00:00
I just cleared my screen there by hitting
00:00
Control L. The next command we can
00:00
look at is called the blkid command, B-L-K-I-D.
00:00
The blkid command is used to
00:00
get more information about block devices.
00:00
It displays block devices in
00:00
their partitions but also UUIDs.
00:00
We type blkid here,
00:00
and then what we're going to see is all of
00:00
the partitions and we're going to see their UUIDs
00:00
identified as well as the block size that is being
00:00
used on these partitions and
00:00
the type of file system that they're using.
00:00
Now, normally on
00:00
CentOS you may have to run sudo to see this,
00:00
you have to be root to see this,
00:00
but I've already done that earlier and
00:00
now sudo is still cached
00:00
in my sessions so I didn't need to do that.
00:00
But if you ever try to run this and
00:00
you have issues with it,
00:00
you can run sudo blkid
00:00
and hit ''Enter'' and it'll display information.
00:00
In fact, you can see it displays
00:00
a little bit more information
00:00
>> than what we got last time.
00:00
>> It's always a generally good idea
00:00
to elevate your privileges
00:00
when you're using blkid to make sure
00:00
that you're getting the full story on everything.
00:00
Now, the other thing that we can do is we can display
00:00
dev disk by UUID, ls-l dev disk by uuid.
00:00
What we'll see is that these are pointers here
00:00
to the sda1, 2, 5,
00:00
and 3 and these
00:00
correspond to what we see up here in block ID.
00:00
Really that's just what blkid is reading it from,
00:00
is this file, devdisk by UUID.
00:00
Now, let's take a look at
00:00
another one of these directories.
00:00
Let's clear our screen, Control L
00:00
or we can actually just hit ''Clear'' by the way,
00:00
that's another way to clear your screen.
00:00
The sys block directories we're going to look at.
00:00
This contains symbolic links to physical devices.
00:00
Again, this is how the kernel
00:00
interacts with underlying storage.
00:00
Remember everything in Linux is a file.
00:00
The kernel uses these files to
00:00
interact with the actual underlying storage.
00:00
We can see this by typing ls al sys block,
00:00
and now we can see all the
00:00
block devices and these are just the devices.
00:00
We're not seeing the partitions,
00:00
we're just seeing the devices themselves.
00:00
But we see sda,
00:00
sdb, and sr0.
00:00
Sr0 is a CDROM drive by the way.
00:00
But sda and sdb are our block devices there.
00:00
They're pointing to an actual
00:00
>> underlying storage device,
00:00
>> device in the PCI bus because you see
00:00
devices PCI right here.
00:00
That is how Linux,
00:00
the kernel, interacts with that storage.
00:00
It's using really just the symlink.
00:00
If you see this, this is a pointer arrow here,
00:00
>> is the symlink.
Up Next