Mapping Large Numbers of Disks to Virtual SCSI Hosts in a IBM VIO Server Environment

It appears that FOR loops with number ranges defined, using the format {1..10} do not work in an IBM VIO server environment even from the oem_setup_env shell which IBM prefers you stay away from in the first place. However, when you are dealing with mapping large numbers of disks to virtual SCSI hosts, you need a bit of a helping hand. For example, IBM i V6R1 and higher allow you to use non-520 Byte storage devices for disk allocation as long as the disks are presented as VSCSI through a VIO server which then formats the disks as 520 Byte disks. This allowance opens the door to loads of disk options previously unavailable. There are certain guidelines surrounding VSCSI mappings and queue_depth settings for the disks that for performance purposes limit the number of disks that should be mapped per vhost. For example with a queue_depth setting of 32 IBM i ATS recommends that you map no more than 16 drives per vhost. If you have 120 disks/LUN's that you are mapping to your LPAR that requires a great amount of manual effort to map each of these disks. A small script with a while loop can be very helpful here.

Here is an example of a script that simply creates a list of numbers from a starting number to an ending number. You can then use that output for your mapping commands or to set the attributes on your disks or such.

Login as padmin and type oem_setup_env to get to your root shell.

From /home/padmin create a file called count.ksh and paste this into your newly created file

#!/bin/ksh
# This script will allow you to create a list of numbers that begin at the START number
# and continue to increment until they reach the END number.
# SYNTAX ./count.ksh 1 10 with 1 being the starting number and 10 the ending number
#
START=$1
END=$2
while [[ $START -le $END ]]
do
echo $START
let START=START+1
done

As an example, if you wanted to set the queue_depth to 32 for a group of hdisks40-90, you could then issue the following command.

/home/padmin/count.ksh 40 90 | xargs -I {} chdev -l hdisk{} -a queue_depth=32

This command will increment beginning at 40 and ending at 90 and for each increment will set the queue_depth on each hdisk. The xargs -I (capital letter i) allows for the output of the count.ksh script to be substituted for the {} in the command. It may not be the most sophisticated solution, but it is easily implemented and is a nice tool to have.