lsblk is a command in Linux used to list information about block devices (such as hard drives, partitions, and optical drives). It displays device details and their dependencies in a tree structure by default, making it convenient for viewing the system’s storage layout.
Default Output Columns
The default output of lsblk typically includes the following key columns:
- NAME: Device name (e.g.,
sda,sda1). - MAJ:MIN: Major and minor device numbers.
- RM: Whether the device is removable (
1for yes,0for no). - SIZE: Device capacity.
- RO: Whether the device is read-only (
1for yes,0for no). - TYPE: Device type (e.g.,
diskfor disk,partfor partition). - MOUNTPOINT: The mount point of the device.
Common Options
-for--fs: Displays file system information, including file system type, UUID, and mount point.-lor--list: Outputs in list format rather than tree structure, facilitating script processing.-oor--output: Customizes the columns to display, for examplelsblk -o NAME,SIZE,UUID.-por--paths: Displays the complete device path (e.g.,/dev/sda).-Jor--json: Outputs in JSON format for programmatic parsing.
Important Notes
If you need to parse the output in scripts, it is recommended to explicitly specify the required columns using the -o option, as the default output columns may change across different versions.
