How to use the Linux lsblk command to list block device information

Source: Internet
Author: User

Translate to: http://linoxide.com/linux-command/linux-lsblk-command/

The LSBLK command (which lists block devices) is used to list information about all available block devices, but it does not list information about the RAM disk. Examples of block devices are hard drives, flash drives, CD-ROMs, and so on.


How to install Lsblk
The command lsblk in Util-linux-ng's bag and is now renamed Util-linux. There are other tools in the package, such as DMESG. In order to install LSBLK, download util-linux here.


How to install lsblk in Fedora
The Fedora user can install the package as follows:
$ sudo yum install Util-linux-ng


The command has the following options:
Default options

By default, this command LSBLK all block devices in a tree-like format. Open the terminal and enter the following command:


$ lsblk

The output is as follows:


Lsblk default is seven columns:


Name: Device names.

Maj:min: This column displays the main device number and the secondary device number.

RM: This column shows whether the device is removable. Note that in this example, the RM values of the device SDB and sr0 are equal to 1, indicating that they are movable.

Size: This column is a device's sizing information. For example 298.1G indicates that the device is 298.1GB and 1 K indicates the size of the device is 1KB.

RO: This indicates whether a device is read-only. In this case, all the devices are ro = 0, indicating that they are not read-only.

TYPE: This column shows whether the block device information is a disk or a partition (partial) on disk. In this example, the ADA and SDB are disks and sr0 is a read-only memory (ROM).

Mountpoint: This column displays the mount points that are mounted on the device.

List all the devices

The default option does not list all empty devices. To view these you need to use the following command:


$ lsblk-a

This option will list all the devices, including the empty.


List device permissions and owners
The LSBLK command can also be used to list ownership of specific devices, as well as group mode. This can be achieved as follows:

$ lsblk-m



List specific Devices

You may also just get information about a particular device. This can be achieved by specifying the device name after the LSBLK option. For example, you might want to know the size of the hard drive's bytes. You can do this by running the following command:

$ lsblk-b/DEV/SDA

Or is:
$ lsblk--BYTES/DEV/SDA



List devices in untitled format


You can also combine several options to get a specific output. For example, you might want to list devices in the form of lists, rather than the default tree format. You may also want to remove header names for different columns. Two different options can be combined to achieve the desired output, as follows:

$ lsblk-nl

Or you can use the outgoing option to output the same.

$ lsblk--noheadings--list


List SCSI Devices
In order to get only the SCSI device list, you can use option-S. This option is uppercase S, do not confuse it with the-s option, which is used in reverse print trust relationship.

$ lsblk-s



Reverse print the trust relationship will give the output as follows, enter the command:

$ lsblk-s

Or

$ lsblk--inverse



You can use LSBLK to get more information about your block device, now try it!

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.