Disk Alignment

While deploying storage for my clients, I frequently have to mount storage assigned to hosts and have to follow best practices for aligning the partitions. If you don't know what partition alignment is, it is the process of including an offset when creating a partition so that writes to disk do not cross a stripe unit boundary. All of this begs for some definitions.

 
 

Stripe:

A stripe is an allocation on disks in a RAID array of equal size that spans across all disks in the array. The following image illustrates this idea. So all of the A units (A1, A2, A3, Ap) collectively create the stripe.

 
 

Stripe Size:

The stripe size, element size, block size, or stripe length (and in some places stripe width) is the size of the individual allocation unit on each disk. A common stripe width is 64K or 128 disk sectors for example. This is invisible to the OS that the storage is presented to.

 
 

Allocation Unit:

This is the size of each cluster that makes up a partition. This value is NOT the same as the stripe width and is configured at the time the partition is formatted.

 
 

 
 

So now that we know what a stripe is, what difference does it make and how does alignment affect that? When you write data to the disk, each bit is placed across the stripe. This is done across the underlying physical disks in the system. Aligning the partitions is the process of ensuring that each write doesn't cross a disk boundary. This prevents a write transaction from spinning up two spindles to record the data to the disk, therefore improving performance. This happens because of the way the Windows OS handles the creation of partitions.

Windows creates a table on the disk that holds configuration information on the disk. This space can cause a misalignment between the partition and the stripe boundaries. In order to mitigate this, we can align the partitions at the time they are created (Note that this only applies to Windows 2000 and Windows 2003. Windows 2008 handles partition creation properly natively) Microsoft recently update their KB on suggested alignment strategies and values. You should also review this Technet article including SQL best practices to get a better perspective.

 
 

Creating some storage on Windows 2003:

I work with EMC hardware, and so these examples and suggestions are taken in that context.

 
 

  • Create the file systems on your SAN (or local RAID controller) and note the stripe size
  • Assign this new file system to your server
  • Open a command prompt and run diskpart (For windows 2000, see below)
  • Select the disk that you want to create a properly aligned partition on (Use Disk Management gui to determine this, or use Diskpart to list all disks)
  • Create a primary partition with an alignment of 1024k (2048 sectors)
  • Format and assign a drive letter to the disk

     
     

    Code summary:

    Diskpart

    Select Disk 2

    Create partition primary align = 1024

     
     

    Creating some storage on Windows 2000:

  • Create the file systems on your SAN (or local RAID controller) and note the stripe size
  • Assign this new file system to your server
  • Open a command prompt and run diskpar (This is included on the Windows 2000 resource kit)
  • Select the disk that you want to create a properly aligned partition on (Use Disk Management gui to determine this, or use Diskpart to list all disks)
  • an alignment of 64k (128 sectors)
  • Format and assign a drive letter

     
     

    Code summary:

    Diskpar -s 2

    Answer Yes - the disk is raw

    Answer Yes again - you are deleting data

    Enter 128 - sectors to offset

     
     

    Now that you have properly aligned your disks, formatted them, and assigned them a drive letter, you will not have instances where writing data to your RAID array crosses stripe boundaries which in turn can reduce your performance (some say as much as 25%)

Some reference content:
EMC Knowledgebase article emc56324
EMC Knowledgebase article emc104675
Microsoft KB929491
SQL Best Practices Technet Article

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may use [inline:xx] tags to display uploaded files or images inline.

More information about formatting options