Since VMware enables you to create new virtual machines (VMs) from a template, investing the time to make performance...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
tweaks on a single VM that will be used as a template for others can provide a noticeable system-wide performance boost. One way to gain performance is by aligning disk partitions, which enables faster disk reads.
In this tip, we'll cover how to boost overall performance from Windows-based virtual machines by aligning disk partitions for a template VM, which can then be used to create other, properly-aligned and performance-enhanced VMs. If after reading this tip you want more detail, VMware's white paper Recommendations for aligning VMware Virtual Machine File System (VMFS) partitions is a good place to start. (Note: This article applies only to Windows versions prior to Vista, because Vista and Windows Server 2008 both use a default 1,024 KB partition offset.)
Why align disk partitions?
An aligned disk partition enables a system to more efficiently read data. This translates to a faster system. But to understand the mechanics of why disk alignment is important, we'll have to go the architecture of a virtual machine's disk subsystem. A virtual machine disk system is made up of three layers. The topmost layer is the virtual machine disk file (VMDK), and is made up of clusters because it's formatted with the new technology file system (NTFS).
The second layer is the virtual machine file system (VMFS), and is made up of blocks.
The bottom-most layer is the logical unit number (LUN) and is made of stripes or chunks (in this case, the LUN is a redundant array of independent disks (RAID) 5, which combines three or more disks to protect data from the loss of a single disk, creating a larger capacity and redundancy). LUNs represent the virtualization layer between the physical disk device/volume and the applications.
In an NTFS, the smallest unit of data is an allocation unit, or cluster. For data disks, you can change the cluster size. But for the system volume, the default cluster size must be 4 KB for the system to boot properly. Also, x86 systems need 63 sectors for OSes on the master boot record (MBR), and ESX server is no different. So what is the problem? Take a look at the following diagram showing an unaligned partition versus an aligned partition.
Let's start with the VMFS layer on the unaligned partition. As you can see, an attempt to read a block of data on the VMFS partition may cause a read on two stripes at the LUN layer because the blocks cross the stripe boundaries. This would cause a slower read time than in an aligned disk. Fortunately, you can create automatically aligned VMFS partitions with the VMware Infrastructure Client (VI Client).
But there is another alignment concern. As you can see, an attempt to read a cluster at the NTFS level may cause a read on two blocks at the VMFS layer, which causes a read on three stripes at the LUN layer.
How to tell if your disks are aligned
How can you tell if a disk is unaligned at the Windows partition level? Remember the MBR statement -- that x86 systems use the first 63 sectors. Usually there are 512 bytes per sector. If you do the math, 63 x 512 = 32,256. To verify this, log into a machine (physical or virtual) as an administrator that has not had its system volume aligned. Go to Start, then Run, then type in "msinfo32.exe" and press enter. Navigate down to Components, then Storage, then Disks. Notice that the partition starting offset for Disk #0, Partition #0 (the system volume) is 32,256 bytes.
Since the system volume is 32,256 bytes, the partition has not been properly aligned. Remember, the Windows system volume is formatted with a 4 KB or 4,096 byte cluster size. That means you want a partition aligned with 4,096 byte boundaries. Divide 32,256 by 4,096. You get 7.875, which is not a whole number.
The partition is not aligned with 4,096 byte boundaries unless the offset is cleanly divisible by 4,096.
Aligning disk partitions
To align the partition, you will use an offset of 64 KB, or 65,536 bytes. Divide 65,536 by 4,096. You should get an answer of 16. This indicates that the partition is aligned at 4,096 byte boundaries.
Aligning a partition destroys the data on the partition; so you cannot align it after an OS has been installed. This leaves two choices: You can either align an empty virtual disk on another virtual machine or you can use a boot disk to align the partition before installing the OS.
The first choice is not ideal if your goal is to align all future VM system partitions because the first virtual machine will not be aligned. You will need to delete the virtual machine after a disk has been aligned on the attached virtual disk. If you are just going to delete the virtual machine after you align the disk, you probably don't want to waste time installing an operating system.
The second option works on a brand-new ESX environment in which no virtual machines currently exist. In this case, you use a WinPE 2.0 boot disk to boot your first virtual machine, align its disk, install and configure the operating system, and convert the virtual machine to a template. Let's create a basic WinPE 2.0 boot disk.
Creating the WinPE 2.0 boot disk
You will need the following:
- A copy of the Windows Automated Installation Kit (Windows AIK);
- A "technician PC" (Windows Server 2003 SP1, Windows XP SP2, or Windows Vista are supported)
- A PC that can burn a DVD (which can be the technician PC)
Once you have a technician PC on which to install WAIK, download Windows AIK and install it on the technician PC. To install Windows AIK, you need to download the image from Microsoft, burn it to a DVD and install it. Once WindowsAIK is installed, go to Start, then Programs, then Windows AIK, then Windows PE Tools command prompt. Note: If you use Windows Vista, you have to right-click on the Windows PE Tools command prompt entry and select RunAs Administrator.
With the command prompt open, you need to run a command that will set up the directory structure needed to create your WinPE 2.0 disk. Run the following at the command prompt:
copype <arch> <destination>
Where <arch> is your processor architecture (x86, amd64, or ia64) and <destination> is a path to a local directory. Below is an example of running this command:
copype x86 c:\winpe-2_0 <enter>
You will notice that this creates the following directory structure:
\winpe-2_0 - Contains the bootstrap loader (ETFSBoot.com) and a Windows image (winpe.wim) that has the basic files needed to create a WinPE 2.0 disk.
\winpe-2_0\ISO - Contains the files needed to create the WinPE 2.0 boot disk ISO disk image.
\winpe-2_0\mount - An empty folder used when you need to modify the winpe.wim image file. For this example, you will not use this folder.
Now that the directories are in place, you just need to copy the winpe.wim file to the "c:\winpe-2_0\ISO\sources" directory and name it boot.wim. You can do that with the following command:
Press Enter. Now all you have to do is create the ISO file that you will use to boot your virtual machine.
To do so, run the following command at the Windows PE Tools command prompt:
oscdimg -n -h -bc:\winpe-2_0\etfsboot.com c:\winpe-2_0\iso c:\winpe-2_0\winpe.iso
Press Enter. This will convert the boot.wim file into the winpe.iso file needed to boot a machine into WinPE 2.0.
Now all you need to do is copy the winpe.iso file to a location (NFS, VMFS, etc.) that your ESX host can use to attach the ISO to a VM. Once that is done, go ahead and create a virtual machine with a virtual disk to be used as the system volume (choose the size carefully because you cannot change it and maintain partition alignment). Attach the winpe.iso file to the virtual machine so that it can boot into the WinPE 2.0 environment. Power-on the virtual machine and boot into the WinPE 2.0 environment.
Creating the 64 KB aligned partition with Diskpart.exe
The virtual machine will boot to a WinPE 2.0 command prompt. Once you are at the command prompt, use Diskpart.exe to create an aligned partition. To do so, type in the following:
select disk 0
create partition primary align=64
You can now exit diskpart by typing 'exit'. Shut down your virtual machine. Detach the winpe.iso file and replace it with an ISO of your OS (Windows Server 2003, Windows XP, etc.).
Install the OS as usual. When you get to the part where you can create a new partition, opt to use an existing partition rather than creating a new one. Format the partition as NTFS.
Once you finish installing the OS and configuring the virtual machine, use vCenter to convert the virtual machine to a template and deploy each new virtual machine from this template. Alternatively, you can just copy the virtual disk to a new virtual machine each time you create a new one if you do not have vCenter.
Now each virtual machine contains aligned system volumes without additional work. As you begin to deploy virtual machines, doing the up-front work to ensure optimal performance system volumes for virtual machines is well worth the effort.
ABOUT THE AUTHOR: Harley Stagner has a wide range of knowledge in many areas of the IT field, including network design and administration, scripting and troubleshooting. Of particular interest to Harley is virtualization technology. He was the technical editor for Chris Wolf and Erick M. Halter's book, Virtualization: From Desktop to the Enterprise and currently writes his own blog at www.harleystagner.com.