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.
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.
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:
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.
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.