方法如何在Linux中检查LUN或SAN磁盘

在存储环境中工作时,通常需要添加,删除或调整存储设备的大小。分配存储后,您需要“扫描”分配的存储SAN磁盘以进行确认。

本文提供命令以检查/识别Linux系统上的附加LUN信息。

什么是LUN

LUN是逻辑单元号。可用于指代整个物理磁盘或较大物理磁盘或磁盘卷的子集。物理磁盘或磁盘卷可以是整个单个磁盘驱动器,单个磁盘驱动器的分区(子集)或RAID控制器磁盘卷,该RAID控制器磁盘卷包含为高容量和冗余而分组的多个磁盘驱动器。

1)检查Linux中连接的LUN或SAN磁盘

要检查从Linux存储设备连接的“ LUN”, /proc/scsi/scsi 尽管该文件包含内容,但它提供了一些信息,并且无法区分连接到LUN的物理驱动器。显示内容如下

# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0 
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0 
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi0 Channel: 00 Id: 02 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0 
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: LIO-ORG  Model: block            Rev: 4.0 
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 01
  Vendor: LIO-ORG  Model: block2           Rev: 4.0 
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 02
  Vendor: LIO-ORG  Model: rhelblock        Rev: 4.0 
  Type:   Direct-Access                    ANSI  SCSI revision: 05

通常,伦氏显示为 Host: scsi3 Channel: 00 Id: 00 Lun: 00

下面是使用不同存储供应商的同一文件的另一个示例。

#猫/ proc / scsi / scsi

已连接设备:主机:scsi0通道:00 Id:00轮数:00供应商:HP 36.4G型号:MAN3367MC版本:HP05类型:Direct-Access ANSI SCSI修订版:02主机:scsi2通道:00 Id:00轮数:00供应商: COMPAQ模型:HSV110(C)COMPAQ版本:2003类型:未知ANSI SCSI版本:02主机:scsi2通道:00 Id:00伦:02供应商:COMPAQ模型:HSV110(C)COMPAQ Rev:2003类型:Direct-Access ANSI SCSI修订版:02主机:scsi2通道:00 Id:00伦:03供应商:COMPAQ型号:HSV110(C)COMPAQ修订:2003类型:Direct-Access ANSI SCSI修订版:02主机:scsi2通道:00 Id:01伦: 00供应商:COMPAQ型号:HSV110(C)COMPAQ修订版:2003类型:未知的ANSI SCSI修订版:02主机:scsi2频道:00 ID:01编号:02供应商:COMPAQ型号:HSV110(C)COMPAQ修订版:2003类型:访问直接-ANSI SCSI修订版:02行使价:scsi2频道:00 ID:01 Lun:03供应商:COMPAQ型号:HSV110(C)COMPAQ Rev:2003

您可以使用iscsiadm(仅用于与iscsi target一起存储)命令来获取有关已连接lun的信息。

# iscsiadm -m session -P 3
iSCSI Transport Class version 2.0-870
version 6.2.0.873-35
Target: iqn.2017-06.com.linoxide:target1 (non-flash)
	Current Portal: 172.16.20.139:3260,1
	Persistent Portal: 172.16.20.139:3260,1
		**********
		Interface:
		**********
............
............
************************
		Attached SCSI devices:
		************************
		Host Number: 3	State: running
		scsi3 Channel 00 Id 0 Lun: 0
			Attached scsi disk sdd		State: running
		scsi3 Channel 00 Id 0 Lun: 1
			Attached scsi disk sde		State: running
		scsi3 Channel 00 Id 0 Lun: 2
			Attached scsi disk sdf		State: running

您也可以使用以下路径检查lun信息。

# ls /dev/disk/by-path/
ip-172.16.20.139:3260-iscsi-iqn.2017-06.com.linoxide:target1-lun-0
ip-172.16.20.139:3260-iscsi-iqn.2017-06.com.linoxide:target1-lun-1
ip-172.16.20.139:3260-iscsi-iqn.2017-06.com.linoxide:target1-lun-2
pci-0000:00:07.1-ata-2.0
pci-0000:00:10.0-scsi-0:0:0:0
pci-0000:00:10.0-scsi-0:0:0:0-part1
pci-0000:00:10.0-scsi-0:0:0:0-part2
pci-0000:00:10.0-scsi-0:0:1:0
pci-0000:00:10.0-scsi-0:0:2:0

也尝试使用dmesg命令

#dmesg | grep -i“已附加” scsi0,scsi磁盘sda scsi2连接到通道0,id 0,lun 0,scsi磁盘sdb scsi2连接到通道0,id 0,lun 2,sdb scsi2,通道0,id 0 Scsi磁盘sdc 3连接到lun,scsi磁盘sdd连接到通道0,id 1,lun 2

2)使用多路径命令

Redhat的默认多路径服务是multipathd守护程序。以下命令来自使用multipathd守护程序启用了多路径的服务器,您可以在输出中看到OS标识的Lun信息。

# multipath -v4 -ll
Jun 21 04:58:40 | loading /lib64/multipath/libcheckdirectio.so checker
Jun 21 04:58:40 | loading /lib64/multipath/libprioconst.so prioritizer
Jun 21 04:58:40 | Discover device /sys/devices/pci0000:00/0000:00:07.1/ata2/host2/target2:0:0/2:0:0:0/block/sr0
Jun 21 04:58:40 | sr0: device node name blacklisted
Jun 21 04:58:40 | Discover device /sys/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0/block/sda
................................
................................
===== paths list =====
uuid hcil    dev dev_t pri dm_st chk_st vend/prod/rev             dev_st 
     0:0:0:0 sda 8:0   -1  undef ready  VMware, ,VMware Virtual S running
     0:0:1:0 sdb 8:16  -1  undef ready  VMware, ,VMware Virtual S running
     0:0:2:0 sdc 8:32  -1  undef ready  VMware, ,VMware Virtual S running
     3:0:0:0 sdd 8:48  -1  undef ready  LIO-ORG ,block            running
     3:0:0:1 sde 8:64  -1  undef ready  LIO-ORG ,block2           running
     3:0:0:2 sdf 8:80  -1  undef ready  LIO-ORG ,rhelblock        running
Jun 21 04:58:40 | directio checker refcount 6
Jun 21 04:58:40 | directio checker refcount 5
Jun 21 04:58:40 | directio checker refcount 4
Jun 21 04:58:40 | directio checker refcount 3
Jun 21 04:58:40 | directio checker refcount 2
Jun 21 04:58:40 | directio checker refcount 1
Jun 21 04:58:40 | unloading const prioritizer
Jun 21 04:58:40 | unloading directio checker

我希望本文能帮助您收集Linux操作系统上的lun信息。请在以下各节中提供评论和建议。

Sidebar