Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
The lsblk
command is an essential utility in Linux for listing information about all available or specified block devices. It provides a tree-like representation of the storage devices, making it easier to understand the relationship between different storage components. This command is particularly useful for system administrators and engineers who need to manage disk partitions and storage configurations.
lsblk
CommandThe lsblk
command displays information about block devices, which are storage devices that support random access to fixed-size blocks of data. These include hard drives, SSDs, CD-ROMs, and other storage devices. The command outputs details such as device names, major and minor device numbers, sizes, types, and mount points.
The simplest form of the lsblk
command is executed without any arguments:
lsblk
This command will list all block devices in a tree format, showing their hierarchy and mount points.
To include empty devices in the list, use the -a
option:
lsblk -a
For more detailed information about each block device, use the -o
option to specify the columns you want to display. For example, to display the device name, size, type, and mount point, use:
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
To get the output in JSON format, which is useful for scripting and automation, use the -J
option:
lsblk -J
If you want to list only specific types of devices, such as disks or partitions, use the -t
option. For example, to list only disk devices:
lsblk -d
List All Block Devices with Detailed Information:
lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,TYPE,MOUNTPOINT
This command will provide a comprehensive view of all block devices, including removable status (RM), read-only status (RO), and their mount points.
List All Partitions:
lsblk -l -o NAME,SIZE,TYPE | grep part
This command lists all partitions by filtering the output for lines containing "part".
Display Block Devices in a Script-Friendly Format:
lsblk -P
The -P
option outputs the information in key-value pairs, making it easier to parse in scripts.
The lsblk
command is a powerful tool for managing and understanding the block devices on a Linux system. Whether you're setting up new storage, troubleshooting existing configurations, or simply exploring the system, lsblk
provides the necessary insights into your storage devices.