Virtual Machine Disk Alignment

Some of this information is taken from the excellent work that Ricky El-Qasem (http://read.virtualizeplanet.com/) has done.

 
I have gone through and tested this procedure on a few machines with good results but please note that I do not take any responsibility for any damage that occurs to a virtual machine through performing these tasks.  My advice is to always take a backup of the virtual machine before beginning any tasks like this.

 
Within the virtualized environment, especially when using Windows Server 2003 or Windows XP as the guest operating system, the performance of a virtual machine can be affected by how the disks are aligned.  Here is a brief explanation of what Disk Alignment means within VMware:

 
In a SAN environment, the smallest hardware unit used by a SAN storage array to build a LUN out of multiple physical disks is a called a chunk or a stripe. To optimize I/O, chunks are usually much larger than sectors. Thus a SCSI I/O request that intends to read a sector in reality reads one chunk.

 
On top of this, in a Windows environment NTFS is formatted in blocks ranging from 1MB to 8MB. The file system used by the guest operating system optimizes I/O by grouping sectors into so-called clusters (allocation units).

 
Figure 1 shows that an unaligned structure may cause many additional I/O operations when only one cluster is ready by the guest operating system.

 

The best course of action is therefore to align the NTFS volumes in line with the VMFS volumes to reduce the number of read operations required to read information.  The chunks used within VMware are 64K chunks.  Windows 2008 and Windows 7 already align themselves to 64K chunks but Windows Server 2003 and Windows XP align themselves usually to around 32K chunks and therefore the following technique can be used to align these operating systems to 64K chunks instead.

 
As an example, before writing this document, I performed a test with a Windows Server 2003 server which was not aligned to 64K chunks.  The test involved powering up the virtual machine from being powered off and timing it to the point the ‘CTRL+ALT+DEL’ screen appeared.  The virtual machine was then cloned, the modifications to the server were performed and then the test was repeated again.  The result was as follows:

 
Server A                    –           Boot Time Before:         58.27 seconds

 
Server A                    –           Boot Time After:            35.34 seconds

 
As you can see there was a saving of approximately 23 seconds just during the boot process and therefore I’m sure that you can imagine the performance improvement that could be seen in normal operation.


 
Please note that this method may not work correctly on some machines and therefore a full backup should be performed on the virtual machine before attempting to perform this work.

Please note that you will need to download the gparted iso to perform this work, this is available from the following location:
http://gparted.sourceforge.net/

 

 

Stage 1 – Reboot Virtual Machine into gparted iso.

The first stage of the alignment method is to power down the virtual machine.  You should then connect up the gparted-live-0.9.0-7.iso which you should have downloaded previously.  You should then power up the virtual machine again.

 
Select the GParted Live (Default Settings) option.

Keep the selected option ‘Don’t touch keymap’ and click OK.

Type in ‘02’ to select ‘British English’ and then press enter.

Next type in ‘0’ and then press Enter.

Gparted will now finish loading up.

 
Stage 2 – Checking the current alignment of the disks

 
In the GParted program, right mouse click on the disk and then click information:

As you can see from this screen, the first sector is not a multiple of 64.  This one is 63 and therefore it is not aligned.  Change the disk at the top of the program and perform the same task again.

 
Stage 3 – Align Disks

Select the first disk and highlight the partition by clicking on it.

 
Click the ‘Resize/Move’ button.

 
You can now see the amount of space that is assigned to the disk.  To align the disk correctly, the ‘Free space preceding’ should be set to ‘8’ Mib.

Click the ‘Resize/Move’ button once the figures have been inserted.

 
Repeat the process for the additional disks that are unaligned.

 
Please note that the tasks will not be performed until you click the ‘Apply’ button. 

 
The resizing and moving operations may take some time to complete, depending on the amount of data on the disk.

 
Stage 4 – Check the alignment of the disks

 
Once the operations have been completed but before rebooting the server, check the alignment of the disks following the method in Stage 2.

 
The first sector should now read a value that can be divided by 64 and produce a whole number.  If it does not, then the operation has not been performed correctly.

 
Stage 5 – Confirm the operation of the server

 
The final stage is now to shut down the server, unmount the gparted iso file and then power up the virtual machine from its own disks.

 
Confirm that the virtual machine boots correctly and that the applications function as expected.  You should notice that the boot time of the server is reduced.

Leave a Reply

Your email address will not be published. Required fields are marked *