Thursday, July 7, 2011

How to align disk partitions

I own you guys this topic, It has been more than 7 months since I made this promises.
So it’s time to make it right!!!

You remember about unaligned partitions, and how to identify if your partition is mis-aligned, right ? If you dont get back and read these posts before we proceed.

First thing we need to remember is Windows 2008, Vista, Windows 7, they all align their partitions correctly (64KB) by default, so you don’t need to worry about them.

But what about your Windows 2000/2003/XP ? They align it with 63KB making then unaligned with your datastore and in some cases causing performance issues. But you already know that.

Without further ado, let’s see how to align those partitions.

Manual alignment of your partition is a destructive task, it re-creates your partition and no data can be kept while performing that.
So, it’s perfect for your new data drivers.
You just attach a new VMDK file to your guest, create partition, align it, format it and your are ready to go.
But, what if your data driver already has data?
Take a backup of the data, destroy the volume, re-create the partition , align it, format it and restore the data.

What about the system disk ?
It’s a little bit harder
If it’s a new guest and the O.S. has not being installed yet, attach the system VMDK file to another guest system (the disk will show as a secondary disk), create partition, align it, format it.
Then disconnect the disk from the guest and attach it back to your original guest, now it’s just start it up and install the O.S as you would normally do.

If your O.S. is already installed, you will need to take a backup of your system state , perform the same step above as if not O.S. has been installed and then restore the system state.

Manual alignment procedure
- Open a command prompt, run diskpart;
- list disk – then select disk #;
- create partition primary align=64
- Format the disk as you would do normally

Thanks God there are a few tools that can help us with this job without all this manual effort.

If you have some extra bucks to spare you can use vOptimizer Pro from Quest. I have never used it but I’m sure it gets the job done.

if you are a Netapp customer you can use the free tools MBRSCAN / MBRALING tools. Since it’s my case, I’ll show you how it works.

First your need to download it from the NOW Support WebPage (you will have to have an account to access it).
Mbrscan and mbralign are part of the Netapp Host utilities.

Before run the tools make sure your guest is powered off and has no snapshots.

mbrscan checks your VMDK files to see if they are aligned or not. You will need to run it against each disk of your guest.

- Copy the mbrscan file to the /tmp directory of the ESX server (I use /tmp, you can use the one that fits better for you)
- In the /tmp directory run the command ‘sudo chmod 555 mbrscan’ to set the execution
- Run /tmp/mbrscan -flat.vmdk
(NOTE: you are checking the –flat.vmdk file)

mbralign will aligned your VMDK file to 64KB without destroying the data. You will need to run it against each disk of your guest.

- Copy the mbralign file to the /tmp directory of the ESX server (I use /tmp, you can use the one that fits better for you)
- In the /tmp directory run the command ‘sudo chmod 555 mbralign’ to set the execution
- run /tmp/mbralign .vmdk
(NOTE: you are aligning the .vmdk file).
*Also, make sure you have enough space on the SAN lun to have backup files that will be aligned

Run mbrscan again to make sure it’s aligned.

Mbralign will make a copy of your VMDK files with an extenstion called -mbralign-backup before it aligns them.
So it would be easier to restore your old VMDKs in case of corruption (just delete the new vmdk and renames the files back to the original name)
In case everything went fine, delete the backup file to do not waste space on your datastore

But how to avoid new unaligned disks ?
Make sure all your templates are aligned, that way all new guest will be aligned as well ; )

Good Luck.

No comments:

Post a Comment

Who am I

My photo
I’m and IT specialist with over 15 years of experience, working from IT infraestructure to management products, troubleshooting and project management skills from medium to large environments. Nowadays I'm working for VMware as a Senior Consultant, helping customers to embrace the Cloud Era and make them succefully on this journay. Despite the fact I'm a VMware employee these postings reflect my own opnion and do not represents VMware's position, strategies or opinios.

Most Viewed Posts

Blog Archive