AIX/VIO: Tracing Virtual SCSI / Shared Storage Pool Disks on AIX to VIO resources (and a script to automate this)
brian_s 270002K5X3 Comments (32) Visits (23424)
This article covers how to look at an existing AIX server and trace back Virtual SCSI disks back to VIO and find out what the VIO backing device is for any given AIX Virtual SCSI disk. This works for both traditional Virtual SCSI disks and also Virtual SCSI disks that are presented through a Shared Storage Pool. This article includes both information on how to do this manually as well as a script that can automate this task and trace all of your Virtual SCSI disks back to the VIO resources in an automated report.
About the author: Brian Smith is a System Administrator at Intermountain Healthcare.
Overview of Virtual SCSI mappings it AIX and VIOIn an environment that uses Virtual IO servers (VIO) to provide Virtual SCSI disks to AIX LPAR's, it can be difficult to determine which physical disk or LUN on the VIO server represents the Virtual SCSI disk on the VIO client. This information can be important when investigating performance problems, migrating LUN’s/disks to new servers, documenting your systems, and in disaster recovery situations.
Virtual SCSI disks are presented to AIX through virtual host (vhost) adapters. More than one virtual disk can be presented through a single vhost adapter, and it is common to have the same SAN LUN presented through dual VIO servers. In this setup, each LPAR would have one or more vhost adapters connecting to each VIO server. On the AIX partition, the vhost adapter will be listed as a "vscsi" device and on the VIO partition, it will be listed as a "vhost" device.
Vhost/vscsi adapters can be thought of as a virtual connection between the AIX client and the VIO server that is managed by the POWER hypervisor. On each end of this vhost connection there is a slot number that identifies the vhost adapter. So, for each vhost adapter there will be a slot number for the AIX client and for the VIO server. For any given vhost adapter the slot number could be the same for the AIX side and the VIO side, however many times the slot numbers will be different on each end.
Example EnvironmentIn this example, we will use a POWER server that is configured with dual VIO servers. There are 2 LUN's on the SAN that are mapped to each VIO server. Through Virtual SCSI each VIO server maps these 2 disks to the AIX LPAR, which will see two disks. Refer to figure 1 for a diagram of the example environment
Figure 1. Diagram of Example Environment
Steps to manually map a disk from AIX to VIO
Step 1, Gather information from AIX
We must now determine which vscsi device(s) provide this disk. The command lscfg -l hdisk0 will show the client side slot number, however, in a dual VIO server environment this will only show the client side slot number to one of the VIO servers. Instead, run the lspath -F "nam
Listing 1. lspath output
$ lspath -F "nam
In this example we are in a dual VIO environment, so there are paths to each VIO server and you can see that hdisk0 has 2 paths: one through vscsi0 and one through vscsi1.
Because each vhost/vscsi adapter can serve multiple Virtual SCSI disks, there is a LUN number associated to each virtual SCSI disk on the vhost/vscsi adapter. This information is shown as the 4th column in the lspath output in listing 1. In this case, hdisk0 is LUN 810000000000 on both VIO servers. In some cases same hdisk might have a different LUN number on the second path.
If there were multiple disks on this same vhost/scsi adapter, the next disk would be LUN number "820
The next step is to determine the client slot number for each vscsi device. We can use the "lscfg" command to find this information:
Listing 2. lscfg –l vscsiX output
$ lscfg -l vscsi0
The output of this command has some very useful information. The "U9111.520.0001234" is the model and serial number of the machine. The "V11" represents the LPAR ID, and the "C37" and "C38" are the client slot numbers of the vhost adapters.
Step 2, Gather information from the HMC Server:
The easiest way to determine this is by logging in to the HMC and using the lshwres command:
Listing 4. lshwres output
> lshwres -r virtualio --rsubtype scsi -m U9111-520-0001234 --filter lpar_ids=11 -F "slo
Replace "-m 9111-520-0001234" with the name of your managed system (use HMC command lssyscfg -r sys -F "name" to see a list of managed system names). Replace "--filter lpar_ids=11" with the LPAR ID obtained earlier.
The output shows the client slot number, server slot number, and VIO server name. Based on this output we can see that client slot 38 has a server slot with the same number (38) on the "vio_server1" host, and client slot 37 has a server slot with the same number (37) on the "vio_server2" host.
Step 3, Gather information from the VIO Servers
Listing 5. lsmap -all output
The output above is abbreviated. You will see a listing of all vhost adapters on the VIO server. Look for the server slot number you identified in step 5 (the slot number is the "C38" part of the U911
Once you have found the server slot number in the output, you will see a list of each virtual SCSI device that is mapped through this vhost adapter. We now use the LUN number identified in step 4 to determine which virtual SCSI device is the one we are mapping out. You can see that VTD test1_rvg has a LUN listed as "0x8
If you have dual VIO servers, run the lsmap –all command on the other VIO server and repeat the directions in step 3 to find the backing device on that VIO server.
Automating the processThe steps above took time to complete, and we only mapped out a single virtual SCSI disk. If your environment has dozens of LPAR's and each LPAR has dozens of virtual SCSI disks, it becomes very obvious that manually mapping out this information for all virtual SCSI disks not practical.
I have written a Perl script that automates this process and produces HTML output that displays all of the information.
The requirements to run the script are:
When running the script, you specify the name of the HMC server, and then redirect the output to the file where you would like to save the HTML output:
Listing 6. Example vscsimap.pl command line
./vscsimap.pl hmcserver1 > output.html
If you need to connect to the HMC with a different userID you can use the syntax listed in Listing 7:
Listing 7. Example vscsimap.pl command line when specifying a different userID to connect to the HMC with
./vscsimap.pl hmcuser@hmcserver1 > output.html
The script connects to the HMC and gets a list of all managed systems and collects information from the lshwres command. For each managed system on the HMC, the script gets a list of all VIO and AIX servers. It uses the HMC viosvrcmd command to run the lsmap command on each VIO server, and then connects to each AIX machine and gathers information on all of the virtual SCSI disks. All of this information is then output in a formatted HTML page that you can put on a web server or view on your local machine. Depending on the number of managed systems and LPAR’s in your environment, the script might take anywhere from 30 seconds to several minutes to complete.
Figure 2. Example vscsimap.pl output
The script can be downloaded from: http