Disk Partition alignment (Windows)
Disk partition alignment involves setting the partition offset of the first partition on a logical or physical hard-drive whilst taking into account the intended cluster size and any RAID striping of the volume. Aligning a partition correctly can have significant performance gains.
Rules for aligning
Both of following calculations must produce integers in order for the first partition on a disk (and therefore all subsequent partitions) to be correctly aligned:
- Partition_offset divided by Stripe_size
- Stripe_size divided by Cluster_size
For example a partition with offset of 64k, cluster size 64k and RAID stripe size of 64k (if applicable) will be correctly aligned. These settings will work best with disks that will contain databases. - The performance degradation of unaligned partition occurs during intensive I/O workloads rather than on those with low to moderate I/O activity.
How to ascertain these values
1. Partition offset: Save the following as GetPartitionOffsets.vbs and run it:
'GetPartitionOffsets.vbs
'By Joe Chang
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\\\" & strComputer & "\\root\\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_DiskPartition",,48)
'Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_DiskPartition instance"
For Each objItem in colItems
Wscript.Echo "DiskIndex: " & objItem.DiskIndex & " -- Name: " & objItem.Name & " -- StartingOffset: " & objItem.StartingOffset
Next
Look for the offset of the first partition 'partition #0' of the volume that needs to be aligned.
2. Cluster size:
Intall the Windows Server 2003 resource
kit
Type the following and look for the bytes per cluster value:
fsutil fsinfo ntfsinfo driveletter:
For the RAID stripe size, refer to your controller's documentation. For HP, install the Array Configuration Utility, part of the Proliant Support Pack.
How to create partitions that are aligned
Do not create partitions using Disk
Management.
From the Windows Server 2003 resource
kit
use the DiskPart tool:
diskpart
list disk
select disk <DiskNumber>
create partition primary align=<Offset_in_KB> size=<Size_in_MB>
assign letter=<DriveLetter>
format fs=<file-system> label=<"label"> unit=<FileAllocationUnitSize> nowait