VMware Cloud Community
ericr999
Enthusiast
Enthusiast
Jump to solution

Create new disk and lvm scripts

Hello,

I'm currently looking for a way to automate the add disk + scripts withint the OS. I'm having a hard time to find the correlation between my test machine and VMware.

In vmware when I browse into vm.config.hardware.device, I can find the info, the scsi controller id and the disks associated with it, and normally it will show up as 0:0:0:0 for the first disk on the controller 0. No suprise there!

But I've seen on some newer machines that the controllers might show up on the scsi id: 34:0:0:0, or 35:0:0:0, I even had a case where I had controller 0 and controller 2, one on 30 and the other on 34. I've added a new controller as controller 1, and in the OS it shows up on 35. But it seems that this logic was working before for others, I've found several posts about it: Match Linux SCSI Devices (sdX) to Virtual Disks in VMware – Life in the network

And this is working on some of my machine but not all, can't find the reason about it. Any idea ?

Tags (1)
1 Solution

Accepted Solutions
filosmith
Enthusiast
Enthusiast
Jump to solution

If you're trying to find a way to map disks in vsphere to disks in the guest, you'll have to set disk.EnableUUID on the vm. Then virtualDiskManager.queryVirtualDiskUuid will match `ls -l /dev/disk/by-id| grep wwn | grep " + sd + "|awk '{print $9}'` in the guest. Is that what you're looking for?

View solution in original post

Reply
0 Kudos
6 Replies
ericr999
Enthusiast
Enthusiast
Jump to solution

Oh and I already tried ls -alrt /dev/disk/by-path/

This almost works in all cases, but then again, I have a case where I see this:

pci-0000:0b:00.0-sas-phy0-0x5000c2916de3093c-lun-0 -> ../../sdc

The others all all in the format:

pci-0000:00:10:0-scsi-0:0:0:0 -> ../../sda

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

This number is the PCI slot number of the given virtual device. Here is a sample script showing how to enumerate all virtual devices and print their PCI slot number (if available):

var dev = vm.config.hardware.device;

for each (var d in dev) {

  if (d.slotInfo != null) {

    System.log(d.deviceInfo.label + " -> " + d.slotInfo.pciSlotNumber);

  }

}

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

Hi Ilian,

But even that doesn't match in the OS.

SCSI Controller 0 show in pcislot 16, and in the OS its located at the SCSI ID 30:0:0:0

SCSI Controller 1 show in pcislot 34, and in the OS its located at the SCSI ID 33:0:0:0

SCSI Controller 2 show in pcislot 192, and in the OS its located at the SCSI ID 34:0:0:0

Unless there's an equation that solves all this, but before a reboot, my Controller 1, was in pcislot ?(can,t remember), and in the OS it was located at 35:0:0:0. After the reboot the OS changed the SCSI ID. That's fine with me but if I hot add a device I need to find a way to add the device rescan the controlllers and then work with the discovered devices in the OS.

And from what I saw, in SLES the target id is always starting at 30.

But in RHEL its starting at 32.

I just hope I can find something that is fool proof and that I don't have to hardcode anything.

Reply
0 Kudos
filosmith
Enthusiast
Enthusiast
Jump to solution

If you're trying to find a way to map disks in vsphere to disks in the guest, you'll have to set disk.EnableUUID on the vm. Then virtualDiskManager.queryVirtualDiskUuid will match `ls -l /dev/disk/by-id| grep wwn | grep " + sd + "|awk '{print $9}'` in the guest. Is that what you're looking for?

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

Ahhh you are right. That does the trick!

Seems also that I can retrieve the UUID in vm.config.hardware.device[X].backing.uuid

Thanks!!

ericr999
Enthusiast
Enthusiast
Jump to solution

Out of curiosity, I can't seem to find the reason why (EnableUUID) is not enabled by default. It seems a good idea to have it enabled by default. All I saw is some random cases that there was specific issues with backup software.

Backup software is pretty important I know, but why not have that option enabled by default, and people with backup issues change this value ?

Or is there any other scenario that might need that option to be off ?

There must be another reason why its off.

Reply
0 Kudos