Quantcast
Viewing all articles
Browse latest Browse all 1001

Determining drive slot location on Linux for LSI-9207 SAS controllers

Posted on behalf of Jordan Hargrave, Linux Software Engineer

The LSI 9207 controller is a SAS HBA controller that is supported in several Dell PowerEdge servers. Due to Linux and SAS supporting hotplug, on this controller the drive ordering is nondeterministic. After rebooting, the ordering of sda, sda, sdc etc may not match the drive slots on the backplane. On most Linux distros the actual drive name does not matter as the installer will use UUIDs to correctly determine the root partition and mounted filesystems. However if a drive fails and needs replacing, determining the physical slot number of a drive is required.

On PowerEdge systems which use a SAS expander backplane (usually any system with > 8 drives) it is possible to determine the drive slot mapping using sysfs. On systems using a backplane without a SAS expander (systems with <= 8 drives), it gets a bit more difficult. The information can either be obtained from dmesg output, or requires using a utility from LSI. Using the sas2ircu utility will also work on systems without an expander, so using it is the best way to get drive mappings on any system. 

The following script uses the sas2ircu utility to get disk mappings on any system.

#!/usr/bin/perl

# sasscan script

# Determine the drive bay slot numbering of disks connected to LSI 92xx controllers

#

# Requires sas2ircu utility obtained from LSI website

open(BAR,"sas2ircu 0 DISPLAY |");

while()

{

    chomp;

    if (/^Device .*unknown/) {

        $ishdd = 0;

    }

    if (/^Device is a Hard disk/) {

        $ishdd = 1;

        $encl = $slot = -1;

    }

    if (/Enclosure #.*: (\d+)/ && $ishdd) {

        $encl = $1;

    }

    if (/Slot #.*: (\d+)/ && $ishdd) {

        $slot = $1;

    }

    if (/GUID.*: (.*)/ && $ishdd) {

        $guid = $1;

        $guid =~ s#^ ##g;

        $guid =~ s# $##g;

        $file = "/dev/disk/by-id/wwn-0x$guid";

        $disk = readlink($file);

        $disk =~ s#.*/##g;

        print "$encl:$slot $file $disk\n";

    }

}

The following script will display bay ID mapping of disks connected to SAS Expander backplane only. This script does not require the sas2ircu utility. 

#!/bin/sh

# Display drive bay for disks connected to SAS expander backplane

for name in /sys/block/* ; do

    npath=$(readlink -f $name)

    while [ $npath != "/" ] ; do

        npath=$(dirname $npath)

        ep=$(basename $npath)

        if [ -e $npath/sas_device/$ep/bay_identifier ] ; then

            bay=$(cat $npath/sas_device/$ep/bay_identifier)

            encl=$(cat $npath/sas_device/$ep/enclosure_identifier)

            echo "$name has BayID: $bay"

            break

        fi

    done

done

Resources:

LSI sas2ircu utility

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 1001

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>