如何查找块设备信息列表

lsblk命令用于显示有关所有可用块设备的信息列表。但是,它没有提供有关RAM磁盘的信息列表。块设备的示例包括硬盘,闪存驱动器,CD-ROM。本文介绍了如何在Linux Machine中查找块设备列表。

要为Fedora和CentOS安装lsblk ,请使用以下命令–

$ sudo yum install util-linux-ng

要为Ubuntu和Linux Mint安装lsblk ,请使用以下命令–

$ sudo apt-get install util-linux -y

要查找所有块的默认列表,请使用以下命令–

$ lsblk

样本输出应如下所示–

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1                               8:1 0 500M 0 part /boot/efi
├─sda2                               8:2 0 40M 0 part
├─sda3                               8:3 0 128M 0 part
├─sda4                               8:4 0 750M 0 part
├─sda5                               8:5 0 462.1G 0 part
├─sda6                               8:6 0 452.1G 0 part /
├─sda7                               8:7 0 8G 0 part
│ └─vol_grp1-logical_vol1 (dm-0)     252:0 0 100M 0 lvm
└─sda8                               8:8 0 7.9G 0 part [SWAP]
sr0

有关上述结果的明确信息如下所示–

  • 名称-指示设备名称。

  • MAJ:MIN-它提供主要和次要设备号信息。

  • RM-此列显示设备是否可移动。

  • 大小-这提供有关设备大小的信息。

  • RO-指示设备是否为只读。

  • TYPE-此列显示块设备是磁盘还是磁盘中的分区(部分)的信息。

  • MOUNTPOINT-此列指示在其上安装设备的安装点。

要显示所有设备(包括空设备)的列表,请使用以下命令–

$ lsblk -a

样本输出应如下所示–

sda 8:0 0 931.5G 0 disk
├─sda1                              8:1   0  500M    0 part /boot/efi
├─sda2                              8:2   0  40M     0 part
├─sda3                              8:3   0  128M    0 part
├─sda4                              8:4   0  750M    0 part
├─sda5                              8:5   0  462.1G  0 part
├─sda6                              8:6   0  452.1G  0 part /
├─sda7                              8:7   0  8G      0 part
│ └─vol_grp1-logical_vol1 (dm-0)   252:0  0  100M    0 lvm
└─sda8                              8:8   0  7.9G    0 part [SWAP]
sr0                                 11:0  1  1024M   0 rom
ram0                                1:0   0  64M     0 disk
ram1                                1:1   0  64M     0 disk
ram2                                1:2   0  64M     0 disk
ram3                                1:3   0  64M     0 disk
ram4                                1:4   0  64M     0 disk
ram5                                1:5   0  64M     0 disk
ram6                                1:6   0  64M     0 disk
ram7                                1:7   0  64M     0 disk
ram8                                1:8   0  64M     0 disk
ram9                                1:9   0  64M     0 disk
loop0                               7:0   0          0 loop
loop1                               7:1   0          0 loop
loop2                               7:2   0          0 loop
loop3                               7:3   0          0 loop
loop4                               7:4   0          0 loop
loop5                               7:5   0          0 loop
loop6                               7:6   0          0 loop
loop7                               7:7   0          0 loop
ram10                               1:10  0  64M     0 disk
ram11                               1:11  0  64M     0 disk
ram12                               1:12  0  64M     0 disk
ram13                               1:13  0  64M     0 disk
ram14                               1:14  0  64M     0 disk
ram15                               1:15  0  64M     0 disk

要显示与块设备的所有者,组和模式有关的信息,请使用以下命令–

$ lsblk -m

样本输出应如下所示–

NAME                              SIZE     OWNER   GROUP    MODE
sda                               931.5G   root    disk     brw-rw----
├─sda1                            500M     root    disk     brw-rw----
├─sda2                            40M      root    disk     brw-rw----
├─sda3                            128M     root    disk     brw-rw----
├─sda4                            750M     root    disk     brw-rw----
├─sda5                            462.1G   root    disk     brw-rw----
├─sda6                            452.1G   root    disk     brw-rw----
├─sda7                            8G       root    disk     brw-rw----
│ └─vol_grp1-logical_vol1 (dm-0) 100M      root    disk     brw-rw----
└─sda8                           7.9G      root    disk     brw-rw----
sr0

要找到以字节为单位的列大小,请使用以下命令–

$ lsblk -b

样本输出应如下所示–

NAME                            MAJ:MIN   RM        SIZE       RO   TYPE MOUNTPOINT
sda                               8:0     0      1000204886016 0    disk
├─sda1                            8:1     0      524288000     0    part /boot/efi
├─sda2                            8:2     0      41943040      0    part
├─sda3                            8:3     0      134217728     0    part
├─sda4                            8:4     0      786432000     0    part
├─sda5                            8:5     0      496196648960  0    part
├─sda6                            8:6     0      485453987840  0    part /
├─sda7                            8:7     0      8576000000    0    part
│ └─vol_grp1-logical_vol1 (dm-0)  252:0   0      104857600     0    lvm
└─sda8                            8:8     0      8489271296    0    part [SWAP]
sr0

如果您不想显示与从站相关的信息,请使用以下命令–

$ lsblk -d

样本输出应如下所示–

NAME   MAJ:MIN   RM   SIZE     RO  TYPE MOUNTPOINT
sda    8:0       0     931.5G   0  disk
sr0    11:0      1     1024M    0  rom

恭喜你!现在,您知道“如何查找块设备信息列表”。在下一篇Linux文章中,我们将学习有关这些命令类型的更多信息。继续阅读!