Mapping VMware Virtual Device Nodes to Disks in RedHat Enterprise Linux

How do you map the Virtual Device Node of a Virtual Disk on a VMware Guest Virtual Machine to a Disk within the RedHat Enterprise Linux Operating System?

This is a question that has come up a few times at my client recently.  I decided to spend this Saturday in my lab to see if I could find out.

The Results:

  • From the VMware Host where the guest VM is running, issue the following command, where the section in italics is the path to the vmx file of the guest virtual machine
    • grep scsi /home/bmiller/vmware/labsrv3/labsrv3.vmx | grep pciSlotNumbervmx-grep-scsi-pciSlotNumber
  • Take note of the numerical order of the pciSlotNumbers assigned to the scsi adapters
    1. scsi0.pciSlotNumber = “16
    2. scsi1.pciSlotNumber = “38
    3. scsi2.pciSlotNumber = “39
    4. scsi3.pciSlotNumber = “40
  • Within the RedHat Guest issue the following command
    • lsscsi -s

lsscsi-s

  • RedHat uses the format [host:channel:id:lun]
  • VMware uses the format of adapter:id
    • for example, Hard Disk 4 on my lab server is on scsi2:3

HardDisk4

Now, lets match them up. Compare the numerical order of the scsi adapters pciSlotNumbers in VMware to the numerical order of the scsi host numbers in RedHat.  Then use the id numbers to identify the disk. The id number will be consistent between VMware and RedHat.

  • We can see that Hard Disk 4 in VMware is on scsi2:3
  • We can see scsi2 is the third adapter based on the pciSlotNumber
  • We can see that 34 is the third scsi host from the lsscsi command (ignore the cd/dvd drive)
    • [21:0:0:0]
    • [21:0:1:0]
    • [33:0:1:0]
    • [34:0:3:0]
    • [35:0:4:0]
  • Now match up the id number in scsi2:3 with the id number in [34:0:3:0]
  • We can see that it matches.  Hard Disk 4 on this Virtual Machine corresponds to /dev/sdd in RedHat

Now, lets match up the remaining disks.

HardDisk

  • We can see that Hard Disk in VMware is on scsi0:0
  • We can see scsi0 is the first adapter based on the pciSlotNumber
  • We can see that 21 is the first scsi host from the lsscsi command (ignore the cd/dvd drive)
    • [21:0:0:0]
    • [21:0:1:0]
    • [33:0:1:0]
    • [34:0:3:0]
    • [35:0:4:0]
  • Now match up the id number in scsi0:0 with the id number in [21:0:0:0]
  • We can see that it matches.  Hard Disk on this Virtual Machine corresponds to /dev/sda in RedHat

HardDisk2

  • We can see that Hard Disk 2 in VMware is on scsi0:1
  • We can see scsi0 is the first adapter based on the pciSlotNumber
  • We can see that 21 is the first scsi host from the lsscsi command (ignore the cd/dvd drive)
    • [21:0:0:0]
    • [21:0:1:0]
    • [33:0:1:0]
    • [34:0:3:0]
    • [35:0:4:0]
  • Now match up the id number in scsi0:1 with the id number in [21:0:1:0]
  • We can see that it matches.  Hard Disk 2 on this Virtual Machine corresponds to /dev/sdb in RedHat

HardDisk3

  • We can see that Hard Disk 3 in VMware is on scsi1:1
  • We can see scsi1 is the second adapter based on the pciSlotNumber
  • We can see that 33 is the second scsi host from the lsscsi command (ignore the cd/dvd drive)
    • [21:0:0:0]
    • [21:0:1:0]
    • [33:0:1:0]
    • [34:0:3:0]
    • [35:0:4:0]
  • Now match up the id number in scsi1:1 with the id number in [33:0:1:0]
  • We can see that it matches.  Hard Disk 3 on this Virtual Machine corresponds to /dev/sdc in RedHat

HardDisk5

  • We can see that Hard Disk 5 in VMware is on scsi3:4
  • We can see scsi3 is the fourth adapter based on the pciSlotNumber
  • We can see that 35 is the fourth scsi host from the lsscsi command (ignore the cd/dvd drive)
    • [21:0:0:0]
    • [21:0:1:0]
    • [33:0:1:0]
    • [34:0:3:0]
    • [35:0:4:0]
  • Now match up the id number in scsi3:4 with the id number in [35:0:4:0]
  • We can see that it matches.  Hard Disk 5 on this Virtual Machine corresponds to /dev/sde in RedHat

An Explanation:

Linux assigns scsi host numbers at boot time based on the order in which it sees the devices.  Linux does not know about the number that VMware assigns to the scsi adapter.  Therefore we have to check the order in which linux will see the devices at boot time.

Notes:

I’m running VMware Workstation 11 in my lab environment.  I used RedHat Enterprise Linux 7 as the Guest OS.  I used a base install with the latest updates.  lsscsi was not installed by default.  I had to install it by issuing the command yum install lsscsi. 

lsscsi-installed

Would it be possible to match things up without lsscsi?  Yes, but it would involve more command line work.  This post has the potential to be confusing as it is.

For reference, I did try changing the pciSlotNumber of one of the scsi adapters as a test.  I shutdown the Virtual Machine.  I edited the vmx file with vi.  (I do not recommend doing this except in a lab environment for testing purposes).  I changed scsi1.pciSlotNumber = “38” to scsi1.pciSlotNumber = “50”.  After making the change, I powered on the VM.  Sure enough it did change the order of the disks displayed by lsscsi.  The last 2 screenshots reflect the change that I made.

scsi1isNow50

  • scsi1 is now the fourth adapter based on the pciSlotNumber
  1. scsi0.pciSlotNumber = “16
  2. scsi2.pciSlotNumber = “39
  3. scsi3.pciSlotNumber = “40
  4. scsi1.pciSlotNumber = “50

lsscsi-s-Post-scsi1-50

  • scsi1:1 Hard Disk 3 in VMware is now [35:0:1:0] /dev/sde
    • 35 being the fourth scsi host
    • note the id of 1 is still consistent between scsi1:1 and [35:0:1:0]

Well, Saturday is almost over.  It looks like I accomplished my goal of one post per week, published on Saturdays.  Have a nice weekend.

Bret Miller – Owner and Principal Consultant, LMR Computer Services Inc

3 thoughts on “Mapping VMware Virtual Device Nodes to Disks in RedHat Enterprise Linux

  1. This gets much more difficult on VMs with LOTS of disks. I have to reverse map 30 disks attached to a VM. Many of these disks were added piece meal over an 18 month period. VMware re-orders the disks when you add new ones, so any mapping you have made will change on reboot when you add more disks to a VM. This is documented in a VMware KB article.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s