Use the Linux lsblk command to list block device information
The lsblk command is used to list information about all available Block devices. However, it does not list information about ramdisks. Block devices have hard disks, flash drives, CD-ROM and so on.
How to install lsblk
The lsblk command is included in the util-linux-ng package. Now the package is named util-linux. This package includes several other tools, such as dmesg. To install lsblk, download the util-linux package here.
Install lsblk in Fedora
You can install the package using the following methods:
- $ Sudo yum install util-linux-ng
This command has the following options:
Default options
By default, the lsblk command lists all Block devices in a tree. Open the terminal and enter the following command:
- $ Lsblk
The output is as follows:
The seven topic names are as follows:
NAME: the NAME of the block device.
MAJ: MIN: The primary and secondary device numbers are displayed in this column.
RM: This column shows whether the device is removable. Note: In this example, the RM values of the device sdb and sr0 are equal to 1, which means they are mobile devices.
SIZE: This column lists the device capacity information. For example, 298.1G indicates that the device size is 298.1 GB, and 1 kb indicates that the device size is 1 kb.
RO: indicates whether the device is read-only. In this case, the RO value of all devices is 0, indicating that they are not read-only.
TYPE: this column shows whether the block device is a disk or a partition on the disk. In this example, sda and sdb are disks, while sr0 is read-only storage (rom ). (LCTT, here the RO item of sr0 is not marked as 1, and there may be some errors ?)
MOUNTPOINT: This column specifies the mount point mounted to the device.
List all devices
All empty devices are not listed by default. To view these empty devices, run the following command:
- $ Lsblk-
This option lists all devices, including empty devices.
List Device Permissions and owners
The lsblk command can also be used to list the ownership of a specific device, as well as groups and modes. You can use the following command to obtain the information:
- $ Lsblk-m
List specified Devices
This command can only obtain the information of the specified device. This can be done by specifying the device name after the options provided to the lsblk command. For example, if you are interested in learning how to display the size of your disk drive in bytes, run the following command:
- $ Lsblk-B/dev/sda
Alternatively, the following command is equivalent:
- $ Lsblk -- bytes/dev/sda
List unused Devices
You can also combine several options to obtain the specified output. For example, you may want to list devices in the List format instead of the default tree format. You may also be interested in removing titles of different topic names. You can combine two different options to obtain the expected output. The command is as follows:
- $ Lsblk-nl
Alternatively, you can use the following long options to give the same output.
- $ Lsblk -- noheadings -- list
List SCSI devices
To obtain the list of SCSI devices, you can only use the-S option. This option is an uppercase letter S and cannot be confused with the-s option. This option is used to print dependencies in reverse order.
- $ Lsblk-S
Lsblk lists SCSI devices, and-s is a reverse-order option (LCTT: display the relationship between devices and partitions), which provides the following output. Enter the following command:
- $ Lsblk-s
Or
- $ Lsblk -- inverse
You can use lsblk to obtain more information about your block device. Try to display it by yourself!
Via: http://linoxide.com/linux-command/linux-lsblk-command/
Translator: GOLinux Proofreader: wxy
This article was originally translated by LCTT and launched with the Linux honor in China
This article permanently updates the link address: