When you log into a server, what do you look at first?
CPU? Memory?
Or the disk configuration?
Right after taking over an environment or adding a disk,
you often start by asking,
"What is the structure of this machine again?"
In such cases,
typing this command gives you an overview.
That is the role of lsblk.
What is the lsblk command?
lsblk is a command that lists block devices.
It displays the relationships between disks, partitions, LVMs, and even mount points
in a tree structure.
The point is,
rather than just having a lot of information,
the structure is visible as it is.
It is most effective when you want to grasp the hierarchy
rather than just individual pieces of information.
By the way, what is a block device?
A block device is a physical disk like an HDD or SSD that the OS recognizes in a form it can handle as a disk.
Now, let's try running it as is.
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 99G 0 part └─vg-root 253:0 0 99G 0 lvm /
If you look at this output
as just a list, it might be a bit hard to understand.
So, let's organize how to read it.
Think of disk / part / lvm as buildings
The TYPE that appears in lsblk
is easier to understand if you compare it to an apartment complex.
disk
= The entire apartment complex
The physical disk itself
A matter of how many buildings there are
sda, sdb, nvme0n1, etc.
First,
"How many apartment buildings are on this machine?"
That is what disk indicates.
part
= Floor (level)
1st floor, 2nd floor, 3rd floor...
Large partitions
Sizes are generally difficult to change later
sda1, sda2, etc.
This is positioned as
a large-scale partition decided at the beginning
.
lvm
= Rooms created within a floor
The number and size of rooms can be adjusted
Walls can be moved
/ or /var can be flexibly carved out
LVM is a mechanism for providing "room for later changes."
It can be called a way of partitioning with operations in mind.
If you read the structure as it is
The output from earlier has this meaning.
マンション(sda) ├─ フロア1(sda1) → /boot └─ フロア2(sda2) └─ 部屋(vg-root) → /
lsblk simply outputs a cross-sectional view of this building in text format.
When you think of it that way, the tree structure suddenly becomes easier to read.
Why is it a two-tier structure?
Some people might feel, "Is it necessary to separate floors and rooms?"
The reason is simple:
(1) You want to separate important areas by floor
(2) You want to adjust capacity by room
You want to have both safety and flexibility at the same time
The result of that is the part + lvm structure.
What can you tell from lsblk?
By looking at lsblk, you can tell:
(1) Which disk
(2) how it is partitioned, and
(3) where it is being used
You can grasp this all at once.
df -h and mount provide
information from different perspectives.
For getting an overview of everything first, lsblk is the best tool.
lsblk is a command for
understanding the disk configurationalong with its structure.
disk = apartment building
part = floor
lvm = room (variable)
Just by keeping this image in mind while looking at it,
the meaning of the output will naturally start to make sense.
If you get lost with disks,
start with lsblk.
Try starting by looking at the building from the outside first.