Skip to content
Snippets Groups Projects
diskPosition2 851 B
Newer Older
  • Learn to ignore specific revisions
  • #!/bin/sh
    
    # Display drive bay for disks connected to SAS expander backplane
    
    for name in /sys/block/* ; do
    
      lbl_d=$(basename $name)
    
      npath=$(readlink -f $name)
    
      while [ $npath != "/" ] ; do
    
        npath=$(dirname $npath)
    
        ep=$(basename $npath)
    
        if [ -e $npath/sas_device/$ep/bay_identifier ] ; then
    
          if cat $npath/sas_device/$ep/bay_identifier > /dev/null 2>&1; then
    
            bay=$(cat $npath/sas_device/$ep/bay_identifier)
            encl=$(cat $npath/sas_device/$ep/enclosure_identifier)
            sn=$(smartctl -i /dev/$lbl_d | grep "Serial")
    
            vendor=$(smartctl -i /dev/$lbl_d | grep "Vendor")
            product=$(smartctl -i /dev/$lbl_d | grep "Product")
    
            echo "$name Enclosure: $encl BayID: $bay - $sn - $vendor $product"
            echo "$npath/sas_device/$ep"
            echo ""
    
            break
          fi
        fi
      done
    done