In a series of blog posts, I'm going to be covering some of the basics that people just happen to overlook. Let's forget about cloud and look back to the real reason why we started virtualizing in the first place, the virtual machine. The virtual machine is key component to cloud, but having machines that are lean and clean allow greater density and better performance.
Last week I touched on P2V Clean-up and aligning your storage is very much a part of the P2V clean-up process.
There are plenty of great blog post articles out there about storage alignment, so I'm not going to dive much into that because we don't need to beat that horse to death much longer. One of the best easy to read and beginner articles I've come across is Best Practice for File System Alignment in Virtual Environments by NetApp and My #1 Issue with VMware ESXi Today by Aaron Delp. Why all the fuss? Misaligned VMs negatively impact performance resulting in increased IO and search time. Everyone is aware of the alignment issues, but we're not 100% sure on how to fix these issues.
There are 3 layers when dealing in a virtual alignment. The Array, VMFS, and the VM.
VMware presents the additional layer to the alignment process. Luckily, VMFS3 is correctly aligned by default to 128 blocks when provisioned by the vSphere Client, making that layer a non-issue. If you are still using VMFS2 as your datastore, then you are not aligned and performing a Storage vMotion of a VM to a VMFS3 partition will remove that layer of complexity. In case you are wondering about NFS exports, the NFS export from a VMware and Array stand-point is not applicable. The VM itself still needs to be aligned and we will touch on that next. Note that alignment issues do not effect Windows 2008 virtual machines because they are properly aligned by default.
This is what you are usually looking at in most Windows 2003 and XP environments that are uninformed about alignment that use VMFS3 or NFS exports.
So how do we know if our virtual machine is aligned or not? If you're ambitious, you can go to every windows virtual machine and run msinfo32.exe and see if the partition offer is evenly divisible by 4096. In the case below, since 32,256/4096 = 7.875, we are not properly aligned.
A much easier method is to download the VM Check Alignment Tool and you can run it against any windows machine in your network. This tool will output a summary at the bottom basically saying if your VM is properly aligned or not. This tool is packaged in VM Advanced ISO.
After identifying which VMs are not properly aligned, the next logical step would be to fix them. There are multiple routes.
- Every NetApp customer should have access to the NOW site. Look for the NetApp vSphere Plugins and install against your vCenter instance. Once install, the mbrscan and mbralign tools will be available to you for download. Download the VM Advanced ISO for multiple How-To documents on realigning your VMDKs. NetApp would not allow me to re-distrubute the mbrscan and mbralign tools within the ISO.
- Paragon Alignment Tool. A GUI based tool that you run inside a VM to align the disk without destroying the data. Keep your eye out on this page because every once in a while this tool will become free of charge.
- Quest vOptimizer Pro. An all-in-one virtual machine optimization suite with options to correctly align your VMs to 64K partitions.
- Using PlateSpin Migrate or Quest vConverter to do a V2V and correctly align the partitions. I would strongly suggest using one of these two tools if you are planning a massive P2V project of Windows 2003 servers as well. VMware's vCenter Converter does not correctly align the partition during a P2V like these tools.
- UPDATE 8/19/2011 - VMware Converter 5 now supports block alignment for converting P2V and V2V!
- UPDATE 2/23/2012 - UBERAlign is the best product out there. USE IT NOW!
- Create a Golden Image Template for all new VMs. I would suggest creating a golden image for new Windows 2003 and Windows XP templates. One of the biggest problems I've seen so far are XP VDI environments that were unaware of alignment. The vSphere administrators created a misaligned XP VM as a template then deployed hundreds of unaligned VMs resulting in substantial performance hits.
- To correctly align the Windows guest operating system to the storage blocks, use the following steps.
1. Create a Windows XP or 2003 Virtual Machine using vSphere Client.
2. After the Virtual Machine is created, add a second hard drive. Add a second hard drive using the following commands:
a. Right-click the Virtual Machine and select "Edit Settings"
b. Click "Add"
c. Select "Hard Drive" and click "Next"
d. Select "Create a new virtual disk" and click "Next"
e. Use the disk capacity you would like your secondary drive to be, then click "Next"
f. Click "Next", then click "Finish" and then click "OK"
This creates a second hard drive named {Virtual_Machine_Name}_1-flat.vmdk. This vmdk may be removed from this Virtual Machine and presented to another virtual machine to perform the next section. Or Windows can be installed on the first drive of this Virtual Machine with the next section performed on the second drive just created.
From within Windows in the Virtual Machine, if you run "System Information" (msinfo32.exe in Start-> Run) and select Components >> Storage >> Disks. Scroll to the bottom and you will see the Partition Starting Offset information. This number needs to be perfectly divisible by 4096. The default .vmdk, you will see the Partition Starting Offset set to 32,256 which is not correctly aligned.
To correctly set the Partition Starting Offset, use the following steps:
- Open a command prompt
- C:\>diskpart
- DISKPART> list disk (now all of your drives should be listed)
- DISKPART> select disk # (Exchange # for the disk we want to align. Never choose the OS disk)
- DISKPART> list partitions (should get a message stating "There are no partitions on this disk to show")
- DISKPART> create partition primary align=64
Viewing the second disk using "System Information", the Partition Starting Offset is now 65,536. 65,536 / 4096 = 16, and this file system is properly aligned to the storage blocks.
This second drive can now be removed from this Virtual Machine. Create a new Windows XP or Windows 2003 VM and present this properly aligned VMDK to a to another Virtual Machine as Drive 0 for Windows to be installed. Install Windows on this correctly aligned .vmdk, then select the "Clone to Template" or "Convert to Template" option in the vSphere Client. The Virtual Machines deployed from this correctly aligned .vmdk template will also be correctly aligned.
- To correctly align the Windows guest operating system to the storage blocks, use the following steps.
The set of Golden Image instructions can also be found on the VM Advanced ISO.
The end result of a correctly aligned VM partition will look like this.
Do you have more methods of properly aligning VMDKs? tell me in the comments.