please keep the original source at the beginning of the text: EMC Chinese Support Forum
Introduced
How many ways do Linux systems scan SCSI disks? Can I recognize a device without restarting the host after I have added a new LUN to Linux? What are the commands for dynamically adding/removing LUNs If PowerPath is installed? This article summarizes the way that Linux hosts reconfigure disk devices and attaches command instances.
More information
The Linux system provides multiple mechanisms to rescan the SCSI bus and to recognize the SCSI devices that are added to the system. In the 2.4 kernel scenario, interrupt I/O is often required because the dynamic LUN scanning mechanism is not consistent.
In the 2.6 kernel, LUN scanning has been significantly improved and dynamic LUN scanning mechanisms have been added. Linux currently lacks commands that allow dynamic SCSI channels to be re-provisioned like drvconfig or Ioscan.
The ways in which the Linux hosts reconfigure disk devices include:
# Reboot System
# unload and reload the HBA driver module
# SCSI Device list under Echo/proc
# Run a SCSI scan with the properties set under/sys
# Run SCSI scan with HBA vendor script
System restart
Restarting a host is a reliable way to detect a newly added disk device. After all I/O is stopped, the host can be restarted while the disk drive is connected statically or in a modular manner. The PCI bus is scanned when the system is initialized, so the SCSI host adapter on which it is mounted is scanned and a PCI device is generated. The scan software then loads the appropriate driver for the PCI device. When the SCSI host driver is loaded, its probe function initializes the SCSI host, registers the interrupt handler function, and finally calls the Scsi_scan_host function to scan all SCSI buses managed by the SCSI host adapter.
Reload HBA Drive
Typically, the HBA driver is loaded as a module in the system. This allows the module to be unloaded and reloaded, during which the SCSI scan function is called. Typically, before uninstalling the HBA driver, all I/O to the SCSI device should stop, unmount the file system, and the Multipath service application must stop. If there is an agent or HBA Application Help module, it should also be aborted.
command example:
For example, a server on a RAC node that executes the FDISK–L command does not see the shared disk, and attempts to execute the following command:
# modprobe-r LPFC (Unload drive) # modprobe LPFC (load driver)
/proc under SCSI Scan
In the 2.4 kernel, the/proc file system provides a list of available SCSI devices. If the SCSI device is reconfigured in the system, all of these changes are reflected in the SCSI device via the Echo/proc interface. Adding a device, host, Channel,target ID, and LUN number of the disk device will be added to the/proc/scsi/, specifying the SCSI number.
command example:
# echo "scsi Add-single-device 0 1 2 3" >/proc/scsi/scsi0: Host Id1:channel id2:target Id3:lun number
This command adds a new disk device to the/proc/scsi/scsi file. If you do not find the file, you need to create a device file name for the new disk device under the/dev path.
If you want to remove a disk device, use the appropriate host, Channel,target ID, and LUN number to run the following format command:
# echo "scsi Remove-single-device 0 1 2 3" >/proc/scsi/scsi0: Host Id1:channel id2:target Id3:lun number
/sys under SCSI Scan
In the 2.6 kernel, the HBA driver exports the scan feature to the/sys directory, which can be used to rescan SCSI disk devices under the interface. The command is as follows:
# cd/sys/class/scsi_host/host4/# Ls-al scan# Echo '---' > Scan '--' represents channel,target and LUN number. The above command causes all channel,target and visible LUNs under HBA4 to be scanned.
RHEL5 or SUSE10 :
Echo '---' >/sys/class/scsi_host/host0/scan/sys/class/scsi_host/several hosts scanned several times.
RHEL4 or SUSE9 :
Echo 1 >>/sys/class/scsi_host/host0/issue_lip is also a few hosts below/sys/class/scsi_host/perform several echoes '---' >> /sys/class/scsi_host/host0/scan
in the existing PowerPath increased in the environment LUNs:
1. Ensure the LUNs are configured on the storage side and output to the Linux host
2. Get the list of HBA cards with the POWERMT command and scan all HBAs in the list
Echo '---' >/sys/class/scsi_host/host#/scan for example, if the POWERMT display lists HBAs 4 and 5, start the scan with the following command: Echo '---' >/sys/class/scsi_ Host/host4/scanecho '----' >/sys/class/scsi_host/host5/scan
3. Run POWERMT config To configure the newly recognized disk to generate the virtual appliance
4. Use POWERMT display to check for newly recognized LUNs and device paths
in the existing PowerPath dynamic Deletion in the environment LUNs
Note that the sequence of operations must be strictly adhered to and may cause host OS panic if the order is incorrect.
1. Stop all I/O on the device that will be removed.
2. Determine the original SCSI device that corresponds to the virtual device by using the following command:
POWERMT Display Dev=emcpower<ID>
3. Deleting a virtual device
POWERMT Remove Dev=emcpower<ID>
4. Reclaim the virtual device number for later use
POWERMT Release
If this command fails, the deleted virtual device still exists under/dev and/sys/block, and may cause problems when new LUNs are added dynamically at a later time.
5. Execute the following command for each original SCSI device:
echo 1 >/sys/block/sd<ID>/device/delete
This command causes PowerPath to stop I/O on these raw SD devices and remove them from/dev and/sys/block. This command execution is unsuccessful and may cause problems when new LUNs are added dynamically at a later time.
6. Delete the corresponding LUN in the storage array and perform POWERMT display to verify that the device has been deleted.
through HBA the vendor Script SCSI Scan
QLogic
The QLogic FC HBA LUN Scan Utility script allows you to identify newly added LUNs without rebooting the system. There is no need to reload the QLogic FC driver.
command example:
Rescan all HBAs with the following command:
#./ql-dynamic-tgt-lun-disc.sh#./ql-dynamic-tgt-lun-disc.sh-s#./ql-dynamic-tgt-lun-disc.sh–scan
Rescan and delete the missing LUNs, using either of the following two commands:
#./ql-dynamic-tgt-lun-disc.sh-s-r#./ql-dynamic-tgt-lun-disc.sh--scan–refresh
Emulex
The newly added LUN can be dynamically scanned using the Emulex LUN scan Utility script.
command example:
# gunzip lun_scan.sh.gz# chmod a+x Lun_scan
Scan all LPFC HBAs:
# Lun_scan All
Scan the LPFC HBA for SCSI host number 2:
# Lun_scan 2
Then confirm that the OS recognizes the new device:
# fdisk-l
If you have powerpath in your system, you will need to run:
# POWERMT Config
Reference
EMC Host Connectivity Guide for Linux
Applied to
Linux host kernel version 2.4, 2.6
RHEL, SUSE
Linux system SCSI disk scanning mechanism analysis and command instance (GO)