As you know there is not one correct way to organize disks. Devices, partitions, LVMs, and filesystems may be configured in many ways. Managing plenty of Linux servers requires the ability to fast identify their configuration by an administrator. Of course - the basic command is
df -h
which gives information about mounted filesystems.
The best way to quickly get a big-picture look at our storage configuration on the system is to use the lsblk
command. It displays information about block devices such as disks, partitions, and their relationships. It provides a tree-like view of storage devices and their attributes, making it easy to understand the storage configuration of a Linux system.
Without any arguments, you get mentioned big picture look at storage configuration.
lsblk
This command might produce the following:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 12G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 200M 0 part /boot/efi
├─sda3 8:3 0 1G 0 part /boot
└─sda4 8:4 0 10.8G 0 part /
sdb 8:16 0 2G 0 disk
└─vg1-lv1 253:0 0 2G 0 lvm /opt/app
sr0 11:0 1 4M 0 rom
This example is easy but as you see you can easily identify devices, partitions and view LVM configuration. Information about mountpoints may be easy connected with devices. Eg. if you need more capacity in /var you know, that you need to extend device /dev/sdb and next LVM (VG->LV) and at the end - to resize filesystem.
Using arguments you can focus on interesting area of storage.
lsblk -f (or --fs)
returns information about filesystems.
You can see information about mountpoints, free and used space and type of filesystem.
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1
├─sda2 vfat FAT16 04E2-0B8B 192.8M 4% /boot/efi
├─sda3 xfs b3701b00-6424-49dd-b991-67bce373fba4 830.6M 13% /boot
└─sda4 xfs 42cb85d6-ce3f-46ed-96c2-c30b06ba51ca 3.3G 69% /
sdb LVM2_member LVM2 001 NfpM8D-Qh3r-311w-nJrN-HcN1-TSc2-LxDWIQ
└─vg1-lv1 ext4 1.0 758d6f7f-5979-481a-965f-e7f145cc55e6 0 99% /opt/app
sr0 iso9660 cidata 2024-11-28-19-48-03-00
lsblk -S (or --scsi)
command returns detailed information about devices.
HCTL column gives information about to connect your device with disk in your infrastucture. HTCL means Host, Channel, Target, Lun in SCSI addresses. This information gives you reference which physical disk should be resized.
NAME HCTL TYPE VENDOR MODEL REV SERIAL TRAN
sda 0:0:0:0 disk QEMU QEMU HARDDISK 2.5+ drive-scsi0
sdb 0:0:0:1 disk QEMU QEMU HARDDISK 2.5+ drive-scsi1
sr0 2:0:0:0 rom QEMU QEMU DVD-ROM 2.5+ QM00003 ata
Use case
Maybe you catch in previous section that our /opt/app mountpoint is out of space. Using only lsblk command you can easily identify all information needed for extend this.
By lsblk
result:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
...
sdb 8:16 0 2G 0 disk
└─vg1-lv1 253:0 0 2G 0 lvm /opt/app
...
you know that:
- this is LVM not disk or partition (TYPE)
- size is 2G (SIZE)
- logical volume is lv1 (NAME vg1-lv1)
- volume group is vg1 (NAME vg1-lv1)
- hard drive is /dev/sdb
Using lsblk -f
:
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
...
sdb LVM2_member LVM2 001 NfpM8D-Qh3r-311w-nJrN-HcN1-TSc2-LxDWIQ
└─vg1-lv1 ext4 1.0 758d6f7f-5979-481a-965f-e7f145cc55e6 0 99% /opt/app
...
you can easy find information out used filesystem - EXT4 (column FSTYPE). It’s crucial because last step of extending disks is resizing FS.
Last but not least lsblk -S
:
NAME HCTL TYPE VENDOR MODEL REV SERIAL TRAN
...
sr0 2:0:0:0 rom QEMU QEMU DVD-ROM 2.5+ QM00003 ata
shows you that your SCSI address is 2:0:0:0. This information allows you to find your physical device to extend.