How to List all Linux Disk Devices

29/12/2020

How to list disk devices in Linux with lsblk

The proper way to list block devices such as hard disks is using the command lsblk.

# lsblk -a

Note: the -a flag forces lsblk to list also empty devices.

In the first column you can see all the connected devices, in the image above you can see 3 devices: sda, sdc and sdd. Lets see some information on each.

Lsblk, The column NAME:

The NAME column shows the name of each disk device and partition. As you can see in the extract of the column below the disk SDA contains 4 partitions: sda1, sda2, sda3 and sda4. You can ignore the “_crypt_” for now.

The second listed disk device is sdc with only one partition, sdc1.

The second listed disk device is sdd with only one partition, sdd1.

The last listed device is the DVD or CDROM:

Lsblk, The column MAJ:MIN:

Following the column NAME there is the column MAJ:MIN is the internal identificator for each device the kernel uses according to the device type.

Lsblk, The column RM:

The column RM shows if the device is removable (where 1 yes and 0 no), in this case last 2 disk are external and the last device is the DVD.

Lsblk, The column SIZE:

The column SIZE displays the size of each of the disk devices listed.

Lsblk, The column RO:

The column RO means Read Only, being 1 positive and 0 negative, if 0 then devices are not read only, if 1, they are read-only.

Lsblk, The column TYPE:

The column TYPE displays the type of device such as devices, partitions, optical devices,  encrypted partitions and more.

Lsblk, The column MOUNTPOINT:

The column MOUNTPOINT shows the mount point of each device or partition, the next image shows the partitions of the device sda.

The screenshot below shows an efi partition belonging to sda1, the encrypted sda2 root partition, the sda3 for boot and an encrypted sda4 SWAP.

The flag -l will show the devices and partition as a list rather than as tree:

# lsblk -l

The flag -f instructs lsblk to inform the filesystem of each partition:

# lsblk -f

Additional flags for the command lsblk are available and explained in the man page which you can also access at https://linux.die.net/man/8/lsblk.

Listing disk devices in Linux with alternative methods: fdisk and fstab

While the correct way to list disk devices in Linux is using the command lsblk, other options are available.
The first one to try is fdisk, to list all block devices with fdisk run:

# sudo fdisk -l

How to show free and used space in Linux disk devices

Additionally to listing your storage devices you may need to show the free and used space, this can be achieved using the command df.

As you see in the screenshot below, the availability of space of all disks formerly listed is now displayed.

The command df allows you to easily check each partition identified both by its device name or its mountpoint, yet, the -h option makes it easier to be readed by humans.

# df -h

For example the image above shows the partition /dev/sda2_crypt which is the root mount point / has 150 GB available and 64 GB used.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Install 7Zip Compression Tool on Ubuntu

How to Install 7-zip on Ubuntu and use it to compress and decompress any file or folder When you want to transfer large...
28/12/2020

Chính sách hoàn tiền ONET IDC

CHÍNH SÁCH HOÀN TIỀN TẠI ONET IDC 1. NỘI DUNG Chính sách hoàn tiền dịch vụ có nghĩa là ONET IDC sẽ...
14/10/2012

Các lỗi thường gặp khi sử dụng proxy và cách khắc phục chúng.

Trong thế giới của công nghệ thông tin hiện đại, Proxy đã trở thành một công cụ không thể thiếu...
27/02/2023
Bài Viết

Bài Viết Mới Cập Nhật

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024