Linux下更換HBA卡重新掃盤

迷倪小魏發表於2017-10-23


Linux 主機上外接FC 儲存時,一般都會在主機上加裝HBA 卡,HBA卡透過WWN號連線光纖交換機或直接儲存。如果HBA卡出問題需要更換時,WWN號相應的也會改變,中間的這個紐帶相當於斷了,就無法正常識別儲存磁碟分割槽。當然有些HBA上面貼的有WWN號,可以在更換HBA卡之前在光交或儲存上更換相應的配置。不過很多沒有標這個,需要到系統下透過命令檢視新識別的WWN號。

檢視HBAWWN號的操作方法如下:

[root@seaing host4]# cat /sys/class/fc_host/host4/node_name

0x200000e08b86fd5c

 

也可以參考文章:)。

 

更改完成WWN號後,系統無法直接更新掛載的後端儲存盤。需要重新掃下盤,可以使用如下方法進行掃盤操作:

[root@seaing ~ ]# cd /sys/class/scsi_host/host4/

[root@seaing host4]# echo '- - - ' > scan

[root@seaing host4]# echo "1" > /sys/class/fc_host/host4/issue_lip  

//某些儲存或系統沒有scan檔案,可以通issue_lip檔案識別

 

掃描前的磁碟狀態:

[root@seaing host4]# fdisk -l

 

Disk /dev/sda: 500.1 GB, 500107862016 bytes

255 heads, 63 sectors/track, 60801 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14       60801   488279610   8e  Linux LVM

 

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1   *           1        3916    31455238+  8e  Linux LVM

 

Disk /dev/sdc: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1   *           1        3916    31455238+  8e  Linux LVM

 

掃描後的磁碟狀態:

[root@seaing host4]# fdisk -l

 

Disk /dev/sda: 500.1 GB, 500107862016 bytes

255 heads, 63 sectors/track, 60801 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14       60801   488279610   8e  Linux LVM

 

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1   *           1        3916    31455238+  8e  Linux LVM

 

Disk /dev/sdc: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1   *           1        3916    31455238+  8e  Linux LVM

 

Disk /dev/sdd: 21.4 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

 

Disk /dev/sdd doesn't contain a valid partition table

 

Disk /dev/sde: 21.4 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

 

Disk /dev/sde doesn't contain a valid partition table

 

注意:

1、可以在掃描之前先執行fdisk -l 與掃描之後fdisk -l 的結果進行比對。更換成功的話會發現後者檢視到的結果比前者多。所以此類操作前,最好將df fdisk mountfstab 等和磁碟相關的資訊做個備份,掃描完成後,和原始資料做一個比對是最為保險的。

2、記不住上面的掃描指令也沒關係 ,透過重啟主機,可以達到同樣的效果。

3、掃盤前後,可以透過檢視/proc/scsi/scsi 確認儲存掛載資訊

 

[root@seaing host4]# cat /proc/scsi/scsi

Attached devices:

Host: scsi0 Channel: 00 Id: 00 Lun: 00

  Vendor: ATA      Model: WDC WD5003ABYX-1 Rev: 01.0

  Type:   Direct-Access                    ANSI SCSI revision: 05

Host: scsi2 Channel: 00 Id: 00 Lun: 00

  Vendor: PLDS     Model: DVD-ROM DH-16D6S Rev: BD11

  Type:   CD-ROM                           ANSI SCSI revision: 05

Host: scsi4 Channel: 00 Id: 00 Lun: 00

  Vendor: HP       Model: HSV300           Rev: 0005

  Type:   RAID                             ANSI SCSI revision: 05

Host: scsi4 Channel: 00 Id: 00 Lun: 01

  Vendor: HP       Model: HSV300           Rev: 0005

  Type:   Direct-Access                    ANSI SCSI revision: 05

Host: scsi4 Channel: 00 Id: 01 Lun: 00

  Vendor: HP       Model: HSV300           Rev: 0005

  Type:   RAID                             ANSI SCSI revision: 05

Host: scsi4 Channel: 00 Id: 01 Lun: 01

  Vendor: HP       Model: HSV300           Rev: 0005

  Type:   Direct-Access                    ANSI SCSI revision: 05

Host: scsi4 Channel: 00 Id: 00 Lun: 02

  Vendor: HP       Model: HSV300           Rev: 0005

  Type:   Direct-Access                    ANSI SCSI revision: 05

Host: scsi4 Channel: 00 Id: 01 Lun: 02

  Vendor: HP       Model: HSV300           Rev: 0005

  Type:   Direct-Access                    ANSI SCSI revision: 05

 

 

下面是redhat官網給出的儲存掃盤說明:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Online_Storage_Reconfiguration_Guide/scanning-storage-interconnects.html

***********************************************************************************************************

 9 Scanning Storage Interconnects

There are several commands available that allow you to reset and/or scan one or more interconnects, potentially adding and removing multiple devices in one operation. This type of scan can be disruptive, as it can cause delays while I/O operations timeout, and remove devices unexpectedly. As such, Red Hat recommends that this type of scan be used only when necessary. In addition, the following restrictions must be observed when scanning storage interconnects:

 

1、All I/O on the effected interconnects must be paused and flushed before executing the procedure, and the results of the scan checked before I/O is resumed.

 

2、As with removing a device, interconnect scanning is not recommended when the system is under memory pressure. To determine the level of memory pressure, run the command vmstat 1 100; interconnect scanning is not recommended if free memory is less than 5% of the total memory in more than 10 samples per 100. It is also not recommended if swapping is active (non-zero si and so columns in the vmstat output). The command free can also display the total memory.

 

The following commands can be used to scan storage interconnects.

 

echo "1" > /sys/class/fc_host/host/issue_lip

 

This operation performs a Loop Initialization Protocol (LIP) and then scans the interconnect and causes the SCSI layer to be updated to reflect the devices currently on the bus. A LIP is, essentially, a bus reset, and will cause device addition and removal. This procedure is necessary to configure a new SCSI target on a Fibre Channel interconnect.

 

Bear in mind that issue_lip is an asynchronous operation. The command may complete before the entire scan has completed. You must monitor /var/log/messages to determine when it is done.

The lpfc and qla2xxx drivers support issue_lip. For more information about the API capabilities supported by each driver in Red Hat Enterprise Linux, refer to Table 1, “Fibre-Channel API Capabilities”.

 

/usr/bin/rescan-scsi-bus.sh

 

This script is included in Red Hat Enterprise Linux 5.4 and all future updates. By default, this script scans all the SCSI buses on the system, updating the SCSI layer to reflect new devices on the bus. The script provides additional options to allow device removal and the issuing of LIPs. For more information about this script (including known issues), refer to Section 16, “Adding/Removing a Logical Unit Through rescan-scsi-bus.sh”.

 

echo "- - -" > /sys/class/scsi_host/hosth/scan

 

This is the same command described in Section 7, “Adding a Storage Device or Path” to add a storage device or path. In this case, however, the channel number, SCSI target ID, and LUN values are replaced by wildcards. Any combination of identifiers and wildcards is allowed, allowing you to make the command as specific or broad as needed. This procedure will add LUNs, but not remove them.

 

rmmod driver-name or modprobe driver-name

 

These commands completely re-initialize the state of all interconnects controlled by the driver. Although this is extreme, it may be appropriate in some situations. This may be used, for example, to re-start the driver with a different module parameter value.

 

 

作者:SEian.G(苦練七十二變,笑對八十一難)


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31015730/viewspace-2146280/,如需轉載,請註明出處,否則將追究法律責任。

相關文章