VMware Explore happening NOW!

Quick VM Disk Alignment Check with PowerCLI

Hey Everyone! vNoob back for another post. Hope you aren’t tired of me yet!

Although I have seen many tools out there that will check disk alignment, most of them require you to install or run some sort of program for it to do the checks.

For this reason, I wanted to write a script that would do the check for us.  I am pulling you leg, I just like doing stuff with PowerCLI!

Anyway disk alignment is important. I could even dedicate an entire post to disk alignment, and although I am not covering that this time there are some other posts that do cover it.

Aligning your VMs virtual hard disks
Why Disk Alignment is Important

Alright! So now you are thinking about alignment, and are concerned about latency, iops, flipflops, and unicorns among other things.  But let’s say you don’t want to download and install a program just to check alignment, or you just like using PowerCLI, what do you do??

Well if you are the former, become the latter, and if you are the latter, then I have just the script for you!!

So the basics of my script are this:

  • Does a wmi query against the VM/Computer to see its starting offset
  • Checks this starting offset against our desired offset (1024 by default)

That’s it..mainly it. Although it should be noted if you cannot do remote wmi/powershell queries, you aren’t going to have much luck with this script.

From those 2 things it can determine if a VM is misaligned. Why 1024 you ask? It is “in general” the target alignment most VMs should have as far as I am aware, but I am not a storage guru so don’t quote me 😛

But how do you know that is the target alignment for you? Well, you can talk to your storage vendor. Or you can run my script. If it isn’t the target alignment for you, I imagine everyone of your results will come back as misaligned.

Alright so let’s see it in action!

 

Sorry, I blocked out the names. Anywho, I ran the function against 3 vms. 1 came back as couldn’t be reached, 1 as DiskAligned, and 1 as NotAligned. Isn’t that nice, 3 boxes covering all three cases….

If no vms/computernames are listed for the parameter “computernames”, it will by default do the test against all the VMs of a currently connected vCenter.

If you want to change the target alignment to something other than 1024, just use the “Offset” parameter.

I am really hoping this is helpful. Let me know what you think!

Check out the file HERE!!