topleft
topright

 


 

Disk Alignment PDF Print E-mail
Saturday, 31 January 2009 11:36

 

Yesterday a guy asked me about disk alignment. We do this by default for RAW LUNs without thinking what more we can improve on this issue. VMware has published a whitepaper which you can find over here:

 

Recommendations for Aligning VMFS Partitions

 

 

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.

 

 

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. 

 

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:

 

copy c:\winpe\winpe.wim

c:\winpe-2_0\iso\sources\boot.wim /y

 

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:

 

diskpart

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.

 

source Harley Stagner

 

Trackback(0)
Comments (6)Add Comment
...
written by Lisa R, February 18, 2009
Careful here. As documented in the VMware paper, VMware and some storage providers recommend against aligning the boot disk, because customers have encountered MSFT VSS problems when doing so. As the paper says, the data disks are the ones that should be aligned.
...
written by Roy, February 18, 2009
Thanks for your comment. In a certain direction you are absolutely right.
Ok I am very curious about the problems of vss. can you tell something more about this in a few words. I know a few words is difficult, but it would greatly help
...
written by Lisa R, February 19, 2009
I'm sorry I don't have details. I know that at least two sites (quite large ones) on two different storage vendors's platforms have encountered BSODs when trying to do a backup using VSS. It's a complicated problem because MSFT provides VSS interface and the storage and/or software vendor provides the backup application. I'll try to get more info and post it here.
...
written by Roy, February 19, 2009
Thanks in advance, That would be great Completion for this issue and this website.
...
written by Eric van der Meer, March 23, 2009
Lisa, can you please share the details about disk alignment?
Thanks in advance!
...
written by Lisa R, March 24, 2009
Sorry - still working on it.

Write comment

security code
Write the displayed characters


busy
Last Updated on Tuesday, 25 August 2009 09:15
 
2008 - All Rights Reserved - Mikes.eu - Design by R. Mikes
Joomla Templates by JoomlaShack Joomla Templates