Friday, October 10, 2008

Keeping your Disks Aligned

Update: I just wanted to add that Andrew Bull helped me with this, so thank you Andrew for the help.

I think that VMs run well. They are speedy and responsive, but sometimes you just want to eek out the best in performance.

Everyone knows that when you create a VMFS Volume through VirtualCenter (or is it vCenter now), the VMFS partition is properly aligned.

But what about the actual Virtual Disk? If you create a VMDK on that properly aligned VMFS, it is created as aligned, but the partition inside the VM won't necessarily be aligned. With Windows OSs, if you simply run through the base install, you don't get aligned disks. So what you need to do is create the partition on the disk before you install the OS on that disk. Now because I can use templates, if I create a VM with properly aligned disks, I can then use this VM as a template and create many VMs off of this template knowing that all of these VMs will be properly aligned.

Here is what I have done when creating and setting up the alignment.

First of all, I created a VM with Windows 2003 and updated it to the latest service packs and hotfixes. I call this VM adminvm, why, why not?

Now, let's say I want to create a new VM called vmlab-dns01. First thing I would do is create the VM the same way I would any Virtual Machine. After the VM is created, I would edit the settings of my adminvm and Add the Virtual Disk of vmlab-dns01 to this Virtual Machine by performing the following steps:

1) Edit Settings of adminvm

adminvm_vm_properties

2) Add New Hard Disk

adminvm_add_hdd

3) Choose to use Existing Disk

adminvm_add_hdd_use_existing

4) Browse to the [VMFS] directory_of_vm and choose the Virtual Disk

adminvm_add_hdd_browse_to_folder

5) Click through taking the defaults and Press OK to exit when you get to this screen

adminvm_vm_properties_new

6) Boot the adminvm, login, and open a command prompt and run the following commands

diskpart_cmd

diskpart <- launches the disk partitioning environment

list disk <- shows which disks diskpart sees

select disk 1 <- disk 1 is the disk I added to mine, but yours could be different

create partition primary align=64 <- creates a primary partition aligned on the 64KB Offset

list disk

exit

7) Shutdown the Virtual Machine

8) Remove the Virtual Disk from the configuration of adminvm

adminvm_vm_properties_remove

Now I can boot vmlab-dns01 and start installing my operating environment knowing that I have a properly aligned Virtual Disk. Here is what that looks like when installing my Windows Server 2008 DCE Core VM:

vmlab-dns01_partition_info

Summary

To create the aligned partition, the diskpart commands I used were the following:

diskpart

list disk

select disk 1

create partition primary align=64

exit

I hope this helps you in your VM best practices

1 comment:

Unknown said...

You are aware that Windows 2008 is aligned by default right? This issue applies to 2003 and earier. The starting offset for Windows 2008 is 1024 Kb, which is aligned.