Greetings,
I need to match up Linux (RHEL 5) guest disks to the virtual disks at the hardware device level (outside the guest). In Windows, the SCSI port/host number and target ID are easy to get at using WMI and they consistently match up with the virtual hardware SCSI addresses. In Linux, it seems like there are problems either with the virtual SCSI controller drivers or the kernel itself that cause the SCSI port/host number and target ID be off. Has anyone found a way around this?
To elaborate a bit, if you do an "ls /dev/disk/by-path" you'll see some symlink files like this:
pci-0000:00:07.1-scsi-1:0:0:0
And if you do a "ls /sys/bus/scsi/devices/" you'll get more related details, such as this:
1:0:0:0
2:0:0:0
2:0:1:0
host0
host1
host2
target1:0:0
target2:0:0
target2:0:1
The most readable output comes from "cat /proc/scsi/scsi", which looks like this:
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
The problem is, none of this info consistently matches up with the two-part SCSI address (eg 1:5) notation vCenter/ESX use to identify virtual disks in the VM hardware device list. To illustrate this, I added a few disks to a 3 different controllers. I figured out the mapping using unique disk sizes (which may not be unique in production).
VM Device Info | Linux SCSI Info |
---|
lsi sas 0:0 | 0:0:0:0 |
lsi sas 0:5 | 0:0:1:0 |
lsi sas 0:8 | 0:0:2:0 |
paravirtual 1:3 | 2:0:3:0 |
paravirtual 1:7 | 2:0:7:0 |
lsi scsi 2:4 | 1:0:4:0 |
lsi scsi 2:9 | 1:0:9:0 |
Since the Linux SCSI address is made up of "Host:Channel:TargetId:LUN", I assume the VM device info is made up of "Host:TargetId". As you can see, the only row where the mapping is valid is the very first LSI SAS disk. I gave other LSI SAS disks non-sequential TargetId's, but somehow they got lost in Linux (perhaps due to the driver, or something specific to SAS). The TargetId's for the Paravirtual SCSI and LSI SCSI controllers actually do match up, but the Host (Port) numbers are swapped.
Any help would be appreciated.
Oh, and http://communities.vmware.com/thread/293192 is a similar question but the answers are not helpful. Using the SCSI ID is the right approach. It's not unreasonable to expect things to match up inside and outside the OS. MAC addresses, for example, are always consistent.
Thanks,
- Chris