Tuesday, September 20, 2011

LUN detection procedures

This topic describes how to manually configure LUNs on your Linux host system.
If you have a Linux driver that does not automatically configure any LUNs other than LUN 0, you can manually configure the other LUNs, depending on the parameters and settings that are used for the SCSI mid-layer driver. Figure 1 shows an example of the /proc/scsi/scsi file for a Linux host that only configures the first LUN (LUN 0) on each host adapter port.
Figure 1. Example of a /proc/scsi/scsi file from a Linux host that only configures LUN 0
# cat proc/scsi/scsi
...
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM-PSG  Model: DPSS-318350M  F  Rev: S9HA
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 15 Lun: 00
  Vendor: IBM      Model: TP4.6 V41b3      Rev: 4.1b
  Type:   Processor                        ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi3 Channel: 00 Id: 01 Lun: 00
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
There are two ways to work around the issue of only having LUN 0 configured:
  • Create a script to manually add devices into /proc/scsi/scsi.
  • Detect LUNs automatically when the system is started by modifying the initial ram-disk (initrd).
Creating a script to manually add devices into /proc/scsi/scsi
Use the scsi add-single-device command to consecutively configure all of the LUNs that are assigned to your host system. Write a script that repeats the scsi add-single-device command for each LUN on each ID for each host adapter. The script must scan all host adapter ports and identify all of the LUNs that are assigned to each port.
After you run the script, you can view all of the assigned LUNs in the /proc/scsi/scsi file.
Figure 2 shows part of an example /proc/scsi/scsi file for a Linux host after a script has configured every LUN.
Figure 2. Example of a /proc/scsi/scsi file for a Linux host with configured LUNs
# cat proc/scsi/scsi
...
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi3 Channel: 00 Id: 01 Lun: 00
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi3 Channel: 00 Id: 00 Lun: 01
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi3 Channel: 00 Id: 00 Lun: 02
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi3 Channel: 00 Id: 00 Lun: 03
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi3 Channel: 00 Id: 00 Lun: 04
  Vendor: IBM      Model: 2105800          Rev: .294
  Type:   Direct-Access                    ANSI SCSI revision: 03
...
Detecting LUNs automatically when the system is started by modifying the initial ram-disk (initrd)
The second method of configuring LUNs for a Linux system with only LUN 0 configured involves setting the parameter for the SCSI mid-layer driver that controls how many LUNs are scanned during a SCSI bus scan. The following procedure works for both 2.4 and 2.6 kernels, but it assumes the SCSI mid-layer driver is compiled as a scsi_mod module that is loaded automatically when the system is started.
To set the maximum number of disk devices under Linux to properly detect all volumes in Linux 2.4 kernels, set the max_scsi_luns option for the SCSI mid-layer driver. For example, if max_scsi_luns is set to 1, this limits SCSI bus scans to only LUN 0. Set this value to the respective maximum number of disks the kernel can support, for example, 128 or 256. The same procedure applies to Linux 2.6 kernels except that the parameter is max_luns.
Perform the following steps to set the maximum number of disk devices:
  1. Open the /etc/modules.conf file.
  2. For Linux 2.4 kernels, add the following line:
    • options scsi_mod max_scsi_luns=n
    For Linux 2.6 kernels, add the following line:
    • options scsi_mod max_luns=n
    n is the total number of LUNs to probe.
  3. Save the file.
  4. To rebuild the ram-disk associated with the current kernel, issue the mkinitrd command for your operating system. In the following examples, kernel refers to the uname –r output that shows the currently running kernel level, for example, 2.4.21-292-smp.
    For SUSE distributions, issue the following command:
    cd /boot
    mkinitrd –k vmlinuz-kernel -i initrd-kernel
    For Red Hat distributions, issue the following command:
    cd /boot
    mkinitrd –v initrd-kernel.img kernel
  5. Restart the host.
  6. Verify that the boot files are correctly configured for the new initrd image in the /boot/grub/menu.lst file.

0 comments :

Post a Comment