2010-09-22

Correct Disk Alignment?

Correct alignment of the sectors on a disk is somewhat important. This is described in several places.
The PowerShell script below checks the alignment of all disks on a given computer.
$wql = "SELECT DiskIndex,Index,StartingOffset FROM Win32_DiskPartition"
Get-WmiObject -Query $wql -ComputerName '.' | Select-Object DiskIndex,Index,@{Name='Offset (KB)';Expression={$_.StartingOffset / 1024}} | Format-Table -AutoSize


The output could be something like
DiskIndex Index Offset (KB)
--------- ----- -----------
        0     0        31,5
        1     0        31,5
        2     0        31,5
        3     0        31,5
        4     0        31,5
        5     0        31,5
        6     0        31,5

If the Offset is fractional, like above, the disk is not aligned correct.

Reference
Microsoft KB929491
Jimmy May, Denny Lee (SQLCAT): „Disk Partition Alignment Best Practices for SQL Server

No comments: