HPE EVA Storage
1753481 Members
4929 Online
108794 Solutions
New Discussion юеВ

Re: Automating SAN docs: WMI, Win32_DiskPartition, Win32_Volume

 
Adam Garsha
Valued Contributor

Automating SAN docs: WMI, Win32_DiskPartition, Win32_Volume

RE: WMI, Win32_Volume, Win32_DiskPartition and finding which goes with which

With Windows2003 Server, how can I determine which Win32_DiskPartition(s) a Win32_Volume is made from/contains?

Motivation: Automating SAN documenation:

=> Win32_DiskDrive,Win32_DiskPartition give me WWID and Basic disk capacity

=> Win32_Volume gives me mount point and freespace/capacity of a filesystem

... How can I link these together? I just need the link/key... not really needing the code.

I want to be able to say "volume{...}" lives on "disk #__, partition #__"

Assume:

(1) My volumes-of-interest are not found as Win32_LogicalDisk(s) instances!; i.e. the volumes are mounted at non-root locations like M:\some\path\here vs. just being "M:\".

(2) We only use basic disks (no dynamic disks), so 1 partition => 1 volume. (But this shouldn't matter if you can find somewhere in WMI that allows linking volumes to their partitions... I can figure out the rest).

#--------------------------------

Before you answer "use Win32_LogicalDisks, Win32_LogicalDiskToParition, please see #1", here is more information to prevent this incorrect answer:

If I query all the Win32_LogicalDisk(s), I only see an instance when a partition is associated with the root drive (e.g. M:)... but not when I have volumes mounted on sub-trees (i.e. UNIX style); e.g.

M:\ <= one volume is mounted here (this partition has a Win32_LogicalDisk)
M:\foo\bar <= another volume mounted to this point in the tree (this partition does not have a Win32_LogicalDisk)
M:\foo\dar <= another volume (living on a disk partition, e.g. )
....

Each volume wraps around one basic disk partition. In otherwords, it is true that I can get everything I need when all my partitions are mapped to drives (D:,E:,...,etc) via Win32_LogicalDisk, however, __IF__ my volumes are __NOT__ mapped to drives and instead are mounted to subtrees then Win32_LogicalDisk instances do not seem to exist (for the volumes in question).

#--------------------------------

I am talking about local basic disks this discussion has nothing to do with network mapped drives.

#--------------------------------

Win32_MountPoint doesn't add anything that I don't already know from Win32_Volume. i.e. I am trying to link the volume to the physical partition (disk #X, paritition #Y), I already know the mount location (Z:\some\path).
3 REPLIES 3
Andrew Kipfer
New Member

Re: Automating SAN docs: WMI, Win32_DiskPartition, Win32_Volume

Adam,

Did you ever figure out the answer to your issue here? The reason I ask is that it looks like I am attempting to do the exact same thing and I'm currently stumped on the exact same issue.

I thought about grabbing the list of GUIDs from Win32_Volume, creating a new partition on an iSCSI mounted drive, and then grabbing the list of GUIDs again to determine the new one and associate it to the disk via code. Did you ever come up with a better solution? I'm not sure if there's a way to lock the machine down to prevent another process from creating a drive and partitioning, thus breaking this rather clunky algorithm, but if not, that would be a potentially problematic fail point.

Thanks,
~Drew
Andrew Kipfer
New Member

Re: Automating SAN docs: WMI, Win32_DiskPartition, Win32_Volume

Actually, I should correct myself. I'm trying to do something very similar.

I'm attaching SAN volumes to Windows Server 2003 machines. I want the mount path folder to have the same name as the SAN volume name. I can query MSiSCSIInitiator_SessionClass and grab the MSiSCSIInitiator_DeviceOnSession object from the Devices array property. That has the information that maps the SAN volume to the physical disk. As you know though, the MSDN says, "No direct relationship exists between Win32_Volume and Win32_DiskDrive." I need this association though so I know which mount point to mount the volume to based on which physical disk it is associated with.

I understand why this cross-reference isn't easy to make. The relationship between physical disks and volumes is M:N so there's no way to directly link them, but I'm not quite sure why there isn't an association class between the two.
Andrew Kipfer
New Member

Re: Automating SAN docs: WMI, Win32_DiskPartition, Win32_Volume

One more thing to add:

I noticed that within ISCSI Initiator, if you go to the Bound Volumes/Devices tab and hit "Bind All", it will bring up a list of the Volume DeviceIDs (GUIDs) of only the iSCSI attached volumes (it ignores internal drives). So the Initiator has some way of knowing which volumes belong to it. The drive type on the ones it ignores match the iSCSI drives (type 3), and I've bound one of the iSCSI volumes to a drive path so it's not looking for ones that haven't been bound. I've combed through the remaining iSCSI WMI objects in the WMI Object Browser and can't seem to find anything that would provide this.

If I can just find some way to reliably map volume to drive, then I can use SetVolumeMountPath, determine which volume to mount to which path, and be done.