Use the Linux lsblk command to list block device information

Source: Internet
Author: User

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:

  1. $ 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:

  1. $ 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:

  1. $ 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:

  1. $ 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:

  1. $ Lsblk-B/dev/sda

Alternatively, the following command is equivalent:

  1. $ 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:

  1. $ Lsblk-nl

Alternatively, you can use the following long options to give the same output.

  1. $ 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.

  1. $ 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:

  1. $ Lsblk-s

Or

  1. $ 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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.