Why Disk Alignment is important (and how to fix a misaligned VM)

Your disk system and your Windows VMs may be running slower than necessary.  Some simple steps can help to improve disk performance by 9 – 13% in your virtual infrastructure.

By now many are familiar with the disk alignment issue but a quick recap.  DBA’s and Exchange admins are very familiar with this concept as they need to drive disk performance for their databases.  The same principle applies to virtualization.  Here we go…

UPDATE:  11/3/11 — Take a look at Nick Weaver’s free UBERAlign tool which can diagnose and correct alignment issues.

The graphic above shows the three layers at issue.  There are the SAN blocks at the bottom, then the VMFS blocks in the middle, and then the NTFS blocks used by the Windows VM.  If these three layers are not aligned, your SAN may be working harder than it needs to.  For example, a call to read a single NTFS block may require the SAN to read three blocks as shown below:

That’s not very efficient.  What would be ideal is for these layers to be aligned so that a single NTFS block requires only one SAN block to be read as illustrated below:

These graphics were taken from the ESX 3 whitepaper, Recommendations for Aligning VMFS Partitions

Let’s talk about how to fix this at both the VMFS and NTFS levels.

VMFS Alignment

When VMFS volumes are created by the vSphere client, they are aligned on a 64K boundary.  Check your SAN vendor’s documentation but in most cases the default 64K boundary will work.  For more details, consult the Performance Best Practices for vSphere 4.0 whitepaper.

NTFS Alignment

By default Windows 2003 and older will align on 32K which will not be aligned with the 64K VMFS layer.  Windows 2008 solves this problem by aligning on a 1024K boundary – this works because 1024K is divisible by 64K.   For example:

  • 32K (NTFS) / 64K (VMFS) = 0.5 = not aligned.
  • 1024K (NTFS) / 64K (VMFS) = 16.0 = aligned.

As long as there is no fractional remainder in this exercise, the two layers are aligned.

Now that we understand the problem and how it impacts performance, let’s focus on determining what VM’s have the problem and ways to fix it.

IDENTIFYING THE PROBLEM

VM’s running Windows 2008 or later should already be aligned as noted above.  If a VM is running Windows 2003 you can check for alignment by one of three ways:

1)      Use the list partition command within Microsoft’s DISKPART utility.

2)      Create a WMI query for the desired attributes by running the following command:

wmic partition get BlockSize, StartingOffset, Name

The output will be in bytes so just divide by 1024.  A 64K aligned partition will have a starting offset of 65536.

3)      Use Vizioncore’s free vOptimizer Wastefinder utility which can scan and identify all your VM’s for misalignment.

#1 or #2 will work fine if you just want to check a specific VM, but Vizioncore’s free utility may be the quickest way to scan your entire environment.

CORRECTING ALIGNMENT PROBLEMS

Once you create a Windows partition you can’t easily change the alignment.  If you are deploying a new Windows 2003 VM, you can use the DISKPART utility to force alignment on a 64K boundary (align = 64).

But what about existing Windows 2003 servers which are not aligned?  One way would be to create new aligned partitions in a new VM and restore/rebuild everything to the new VM, but that’s time consuming and risky.

Vizioncore offers two products which can solve this problem for non-aligned Windows 2003 VM’s:

1)       Vizioncore vOptimizer Pro

This is the full version of the free Wastefinder utility mentioned above.  This product can automatically re-align VM’s on a 64K boundary.  In addition it can resize VMDK’s on a reoccurring schedule in order to significantly reduce storage capacity.

2)      Vizioncore vConverter 5.0

This updated version of vConverter will now automatically align on a 64K boundary while performing either a P2V or a V2V migration.  You can use this tool to perform V2V migrations, which will result in aligned disks.  As far as I am aware this is the only P2V/V2V tool that will automatically realign the target VM on a 64K boundary.

And there you have it in a nutshell.  Two other issues I’d like to quickly point out.

First, you may have a number of Windows 2008 VMs, but if a misaligned VM of any OS is on the same VMFS volume, it could potentially be impacting disk performance for all the VM’s on that volume.

Second, just because a VM is running Windows 2008 it may still be unaligned.  If you did an in-place upgrade of Windows 2003 to Windows 2008 the disk partitions were never modified.  You’ll need to either rebuild the VM or use one of the methods above to correct it.

25 Responses to Why Disk Alignment is important (and how to fix a misaligned VM)

  1. Pingback: Good reasons to upgrade to Windows 2008 R2 | Blue Shift

  2. Pingback: Blog Notes | Blue Shift

  3. asley simp says:

    Great post!!!, thanks

  4. Vision Solutions Double-Take Availability Virtual Recovery Assistant and Double-Take Move all have this functionality. Virtual recoveries made from images backed up using the Double-Take RecoverNow disk-to-disk backup are also realigned during recovery.

  5. Hussain says:

    Hello,
    Great Post. But I have a question, just to understand the requirement of the VMFS/VMDK alignment.

    By default, if VMFS created using vCenter, it will give you an options to change the block size. Default block size is 1 MB. Does it mean that in any VMFS formatted with 1 MB block size, maximum vmdk can hold is 256 GB?

    What if an admin created all the VMFS with the default block size which is 1 MB and on that VMFS he stored 400 and 800 GB of VMDK. Does those VMDKs needs to be moved to another vmfs datastor formatted with higher block size, such is 4 MB block size?

    Thanks,

  6. mvoss18 says:

    If a VMFS is formatted with a 1MB block size, the max size of a single VMDK file is 256GB. If you wanted to have anything bigger, you’d need to move the VMDK to a VMFS with a bigger block size to expand the VMDK beyond 256GB.

    1MB: max 256GB
    2MB: max 512gb
    4MB: max 1024gb
    8MB: max 2TB-512b

    Although, this has nothing to do with alignment.

  7. Pingback: Seminar: Storage for Virtual Environments, Cleveland OH – Stephen Foskett, Pack Rat

  8. Pingback: My Bookmarks » Tintri’s Spiffy and Pricey Storage Array

  9. Pingback: Tintri’s Spiffy and Pricey Storage Array | Kaiusee.com

  10. Pingback: Tintri’s Spiffy and Pricey Storage Array | مطالب جالب|موتور جستجوگر|بهترین ها

  11. Pingback: Tintri’s Spiffy and Pricey Storage Array | TechDiem.com

  12. Pingback: eXactBot Hosting Solutions » Tintri’s Spiffy and Pricey Storage Array

  13. Pingback: Tintri’s Spiffy and Pricey Storage Array | All about Android And

  14. Pingback: Tintri’s Spiffy and Pricey Storage Array | Scripting4U Blog

  15. sina88 says:

    This is a smart blog. I mean it. You’ve so much understanding about this issue, and so much passion. You also know how you can make individuals rally behind it, clearly from the responses. Youve got a style here thats not too flashy, but makes a statement as big as what youre saying. Fantastic job, indeed.

  16. cwjking says:

    Is there anyway to do change this offset with diskpart without having to blow away the system drive?

    I got alot of windows 2003 templates I will have to do this on – after I was told everything was fine…..

    I would like a good workaround even if I have to boot into PE and run disk part that is still better then starting from groundzero… anyways here is a to a way out of this mess…

  17. Pingback: Free UBERAlign Tool for Identifying and Correcting VM Disk Alignment Issues | Blue Shift

  18. Pingback: Align Virtual Machines with VMware Converter 5.0 » Another Day In IT

  19. Ritesh Parab says:

    Great Article  :)
     
    I have created a basic script to find dirty unaligned disk from list of server.
     
    # Writer = Ritesh Parab# Aim = To find dirty disk alignments from list of servers# Version = 1.0 cls$comps = gc “D:WintechDisk Alignmentserverlist.txt” foreach ($comp in $comps){ $rtn = Test-Connection -ComputerName $comp -Count 1 -Quiet     IF($rtn -match ‘True’){ $partitions = Get-WmiObject -Class Win32_DiskPartition -ComputerName $comp foreach ($partition in $partitions){  $Detail = New-Object PSObject                                                   $Detail | add-member Noteproperty SystemName $partition.SystemName -Force                             $Detail | add-member Noteproperty DiskName $partition.Name  -Force                 $Detail | add-member Noteproperty DiskOffset $partition.StartingOffset -Force    $result = $partition.StartingOffset / 4096 if ($result -eq “0″){    $resultOK = “OK” $Detail | add-member Noteproperty Align $resultOK -Force   $Detail  $resultOK = $null   }  else{  $resultKO = “KO” $Detail | add-member Noteproperty Align $resultKO -Force   $Detail  $resultKO = $null }  } } Else { Write-host “$comp Offline” -ForegroundColor Red }}
     
    -Ritesh
     

  20. Pingback: Dynamic Disk Offset Does Not Favor Alignment « Wahl Network

  21. Pingback: Windows Server 2012 Native 4K Disk Sector Support | vm360degree

  22. Pingback: Why Disk Alignment is important (and how to fix a misaligned VM) « Rui Abel Blog

  23. We enter detail to spell out each an individual and a lot of the benefits that all offers.

  24. Pingback: Aplicaciones útiles para entornos VMware

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>