Troy_Clavell
Immortal
Immortal

Virtual Disk Types

Jump to solution

Question:

Is there a way to find out disk type through the API or SDK? I've searched the .vmx and .vmdk and can't find out how to easily determine if my guest is Eager-zeroed thick or Lazy-zeroed thick.

Any help for the PowerCLI guys would be greatly appreciated.

vCenter 4.0.0U1

ESX 4.0.0U1

Thanks!

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager

I just tried this on a dummy VM running on ESX 4.0u1 and created 3 VMDK(s) usingn vmkfstools - (thin, zeroedthick and eagerzeroedthick) and if you look at the MOB for the new VM object and at it's backing, you'll see that eagerlyScrub is unset in all 3 cases.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
7 Replies
lamw
Community Manager
Community Manager

Unfortunately this is not something that is differentiable via the vSphere API, I've looked several times and haven't found an easy way. The only method that I've been able to come up with was the following - , it's vSphere SDK for Perl solution but I'm sure the Master LucD or Alan probably has a similar solution in PowerCLI as well.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Zsoldier
Expert
Expert

I think you could look @ a VM's config hardware device info in the API to find that info.


$vm = get-vm vmname | get-view 

$vm.config.Hardware.device

Look for the objects w/ "CapacityInKB" in my case:

$vm.config.Hardware.device[9].backing 

Returns something like this:

DiskMode        : persistent
Split           : False
WriteThrough    : False
ThinProvisioned : False
EagerlyScrub    : False
Uuid            : 6000C29f-00ca-5858-1c4d-52d4ffdc5881
ContentId       : ba0a92074503d4c37319bd6a7f18efca
ChangeId        :
Parent          :
FileName        : [datastorefriendlyname] vmname/vmname.vmdk
Datastore       : Datastore-datastore-21
DynamicType     :
DynamicProperty :

The properties "ThinProvisioned" and "EagerlyScrub" should return the information you are looking for. I don't have any eagerzeroed disks to see if these properties will return the information you're looking for. I'm trying to figure out a better way to write this out so it checks multiple systems.

Chris Nakagaki (Zsoldier)

http://tech.zsoldier.com

Message was edited by: Zsoldier

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
lamw
Community Manager
Community Manager

afaik, that value does not represent what you think it means.

Per the vSphere API documents - http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.device.VirtualDisk...

eagerlyScrub -

Flag to indicate to the underlying filesystem whether the virtual disk backing file should be scrubbed completely at this time.

Virtual disks on some filesystems like VMFS3 are zeroed-out lazily so that disk creation time doesn't take too long. However, clustering applications and features like Fault Tolerance require that the virtual disk be completely scrubbed. This setting allows controlling the scrubbing policy on a per-disk basis.

If this flag is unset or set to false, the disk scrubbing policy will be decided by the filesystem.

It just indicates whether or not it should be scrubbed at the time, I've looked at this property in the past and was not able to map it back to eagerzerothick vs zeroedthick

Correct me if I'm wrong, though there's nothing in the API that explicitly differentiate these two specific format. It's trivial for thin provisioning.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
Troy_Clavell
Immortal
Immortal

Thank you sir! This is a great start. , although a great script, I believe it doesn't exactly give me what I am looking for.

Let's see if we can get any other attempts at this.

0 Kudos
Zsoldier
Expert
Expert

Posted before I saw your post, William.

Troy - William's perl script is probably the best way to go. This has definately gotten me curious into digging in the API though.

Chris Nakagaki (Zsoldier)

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos
lamw
Community Manager
Community Manager

I just tried this on a dummy VM running on ESX 4.0u1 and created 3 VMDK(s) usingn vmkfstools - (thin, zeroedthick and eagerzeroedthick) and if you look at the MOB for the new VM object and at it's backing, you'll see that eagerlyScrub is unset in all 3 cases.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
Zsoldier
Expert
Expert

@William - Thanks for digging further.

Chris Nakagaki (Zsoldier)

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos