Below is the HP ssacli command to see configured hardware RAID details:

ssacli ctrl slot=0 show config

and its output is as below:

HPE Smart Array P408i-a SR Gen10 in Slot 0 (Embedded)

   Internal Drive Cage at Port 1I, Box 1, OK

   Internal Drive Cage at Port 2I, Box 0, OK

   Port Name: 1I (Mixed)

   Port Name: 2I (Mixed)

   Array A (Solid State SAS, Unused Space: 0  MB)

      logicaldrive 1 (447.10 GB, RAID 1, OK)

      physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS SSD, 480 GB, OK)
      physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS SSD, 480 GB, OK)

   SEP (Vendor ID HPE, Model Smart Adapter) 379  (Port: Unknown)

I have to figure out the Array name in order to delete it by searching for the matching disk info which I get as input from the user. For example, if the disk input is 1I:1:1 then I have to search for this string in the output of the above command. Since this disk is available and matching, I have to extract the Array name (here it is 'A') and once I get this Array parameter then I can go ahead delete this existing RAID configuration.

ssacli ctrl slot=0 show config | grep -B 4 '1I:1:1' | grep Array | awk '{print $2}'

The problem with the above command is,

  • value 4 in the grep -B cannot be always constant as the matching disk may come first, second or third or so on under an Array in the output.

  • there may be multiple RAID array configurations available in the output, so there may be Array A, B, C etc., I have to find and retrieve the nearest "Array" string that matches my input disk


The following perl oneliner reads the file line by line, recording the last array until it meets the line with the physical drive '1I:1:1':

ssacli ctrl slot=0 show config | perl -ne 'if ($_ =~ /Array (.)/) { $array = $1; } elsif ($_ =~ /physicaldrive 1I:1:1/) { print $array; exit; }'
  • Got from other forum as: awk -v disk='1I:1:1' '/^[[:space:]]*Array/ {array=$2} $0 ~ disk {print array; exit}' – Ibrahim Quraish Jun 28 '18 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.