Use lsblk command to View Block devices

Source: Internet
Author: User

Use lsblk command to View Block devices
GuideThe 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, lsblk command is very useful, today let's take a look.

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.

Install lsblk in Linux

In Linux, the default base installation does not use the lsblk command. How can I use lsblk?

In the centos series, yum is used to install the Service Installation Software. Do you need yum-y install lsblk to install this command?

NO, it's not like this. It's just a sleep.
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.
Users of the Fedora series (such as centos and RHEL) can install the package using the following methods:

#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:

lsblk defaultlsblk default

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 -a

This option lists all devices, including empty devices.

Lsblk bytes sda

Lsblk bytes sda

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 -mlsblk permissionslsblk permissions
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 the devices that do not take the lead:

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 --listlsblk no header and listlsblk no header and 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!

Address: http://www.linuxprobe.com/use-lsblk-list-block.html

Edit: Tao wujie, reviewer: Yan zengbao


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.