ESXi

 View Only
  • 1.  How to manage multiple VMDKs per VM

    Posted Aug 01, 2012 08:54 PM

    We have a few VM's that have 15+ VMDK's mapped to them.  Unfortunately we can't make a note on the properties of each VMDK as to what that drive is for and have been forced making 'notes' in the settings box to match up SCSI ID with VMDK.  This is not the best long term plan obviously.

    How do you all handle VMs that have tons of VMDK's attached?  When we need to delete/resize a VMDK on one of these boxes, we just know that we are going to pick the wrong volume one day.



  • 2.  RE: How to manage multiple VMDKs per VM

    Posted Aug 01, 2012 09:04 PM

    The easiest way is to create all the virtual disks with a slightly different size.

    André



  • 3.  RE: How to manage multiple VMDKs per VM

    Posted Aug 01, 2012 09:23 PM

    you can always right click the drive in disk maanger and match the scsi id to the vmdk scsi id.

    But A.p.'s way is simpler.



  • 4.  RE: How to manage multiple VMDKs per VM

    Posted Aug 01, 2012 09:59 PM

    Good day!

    Sounds like you need a script!  You'll have to modify this slightly for your uses, but this is *very* doable.  For reference, I used this these resources

    http://www.networksydney.com.au/?p=122

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394132(v=vs.85).aspx.

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394173(v=vs.85).aspx

    It's a simple one-line PowerShell script to list the attached SCSI devices and sizes.  What you may want to do is somehow run this script and output to a managable log of some sort; I'm thinking something a little cleaner than a text file.  I've attached a screen shot of the output versus the configured .vmdks as pic1.  Note you'll want to pay attention to the *scsibus* and *scsitargetid* fields, as these match up one-to-one with the assigned virtual hard disks.

    Get this into a managable document, and you'll know exactly which disk to remove.

    (after more research)

    To actually match it up, you may want to include the Win32_LogicalDisk class to pull the Volume Name.  Pull the Size property, as well, because you'll have to match it up with the output from the Win32_DiskDrive class.

    Overall, use the following two PowerShell lines to get your information:

    Get-WmiObject Win32_DiskDrive | select-object DeviceID,{$_.size/1024/1024/1024},scsiport,scsibus,scsitargetid,scsilogicalunit | out-file -FilePath c:\output.txt

    Get-WmiObject Win32_LogicalDisk | select-object {$_.size/1024/1024/1024},VolumeName | out-file -FilePath c:\output.txt

    I'm sure there's also a function to round up the numbers that are returned from the size calculation, {$_.size/1024/1024/1024}, which gives you something like 29.90003868103027 GB.  This should get you started!

    Cheers,

    Mike

    http://VirtuallyMikeBrown.com

    https://twitter.com/#!/VirtuallyMikeB

    http://LinkedIn.com/in/michaelbbrown



  • 5.  RE: How to manage multiple VMDKs per VM

    Posted Aug 02, 2012 12:37 PM

    Those scripts seem to work out pretty well except for one small snag.  The second script only returns the drives with drive letters properly.  Given that we have 15+ luns on a given server, we're not about to use drive letters.  Instead, we have a anchor folder and the 15 luns are mounted volumes within that folder as subfolders.

    Is there a way to make the scripts list ?

    Here's an example of what the second script returned:


                     $_.size/1024/1024/1024 VolumeName                            
                     ---------------------- ----------                            
                                          0                                       
                           99.9003868103027 Boot Volume (SCSI 0:1)                
                                          0                                       
                           499.997066497803 Data  (SCSI 1:0)                      
                           7167.87491989136 Compellent  <---- That should actually be a list of about 15 different mounted volumes and their names                         

    Thanks,

    CB



  • 6.  RE: How to manage multiple VMDKs per VM

    Posted Aug 02, 2012 01:01 PM

    Good morning!

    Well, a quick google turned up something I think you can work with.  It's also a one liner and does exactly what you'd like - list disks that use mount points.  I've included an example I ran this morning.  I added a 5 GB disk to a mount point on D: in a folder called "test."

    (see attachment image.png)

    The script looks like this, run from the local machine:

    Get-Wmiobject -query“select name,driveletter,freespace from win32_volume where drivetype=3 AND driveletter=NULL” | Format-Table Name, @{ Label =“FreeSpace (GB)”; Expression={($_.freespace / 1GB).tostring(“F0″)}}

    I found it on this blog:

    http://daniellange.wordpress.com/2010/04/27/powershell-using-wmi-to-query-ntfs-mount-points/

    Which is kind of weird because I used to work with a fella named Daniel Lange, but I doubt this is the same dude.

    Instead of "FreeSpace", though, you may want to use something more useful that shows the full size of the .vmdk.  You probably get this information from the "Capacity" property.  Just replace "freespace" in the above script with "capacity" and see what you get.  See this MSDN page about it:

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394515(v=vs.85).aspx

    Well, between all these scripts, you can probably put them together and run them remotely against all your VMs and output them to a list of some sort.  I hope it works out.

    Cheers,

    Mike

    Message was edited by: VirtuallyMikeB



  • 7.  RE: How to manage multiple VMDKs per VM

    Posted Aug 03, 2012 04:02 PM

    It's looking like what I want to do may simply not be possible because of the mounted volumes requirement.

    This gives me the disk info fine:

    Get-WmiObject Win32_DiskDrive | select-object DeviceID,{$_.size/1024/1024/1024},scsiport,scsibus,scsitargetid,scsilogicalunit

    This gives me the volume info fine:

    gwmi win32_volume | select name,label

    I spent nearly all day yesterday on this, but I just can't tie them together.  I ran across this on a website which pretty much sums everything up:

    "Unfortunately  WMI does not provide a way to map a disk partition that does not have a drive  letter associated with it.  There is no WMI class  to associate a disk volume to  disk partition directly.  However, one can use the low level DeviceIoControl API  to request disk partition information directly from the disk device  driver. "
    I've found no example of anyone tying Volume names to disk ID/SCSI IDs using the DeviceIoControl API.


  • 8.  RE: How to manage multiple VMDKs per VM

    Posted Aug 01, 2012 10:19 PM

    what about giving reasonable meaningful names for the vmdks instead of using the defaultnames  like mysql_1.vmdk - just use mysql-data-customerXY-420gb.vmdk



  • 9.  RE: How to manage multiple VMDKs per VM

    Posted Aug 01, 2012 10:31 PM

    Absolutely. Nice catch Ulli. You could also start a process whereby each disk you add is recorded in a spreadsheet with all the appropriate stats, size, name, purpose, SCSI ID, etc. Then this becomes less a technical issue and more administrative.

    Thumbed from my Android

    --

    Mike Brown

    573-433-0872 (Cell)

    michael.b.brown3@gmail.com<mailto:michael.b.brown3@gmail.com>

    Blog: http://VirtuallyMikeBrown.com

    Twitter: http://twitter.com/#!/VirtuallyMikeB

    LinkedIn: http://linkedin.com/in/michaelbbrown