Checking Disk alignment with Powershell
Disk alignment has been well discussed on the web and the methods to check this always seem to use wmic or DISKPART. I've always loathed wmi so here's a few lines of Powershell that achieves the same thing;
$sqlserver = "sqlinstance";
# Get disk partitions
$partitions = Get-WmiObject -ComputerName $sqlserver -Class Win32_DiskPartition;
$partitions | Select-Object -Property DeviceId, Name, Description, BootPartition, PrimaryPartition, Index, Size, BlockSize, StartingOffset | Format-Table -AutoSize;
This will display something looking like below;
DeviceId Name Description BootPartition PrimaryPartition Index Size BlockSize StartingOffset -------- ---- ----------- ------------- ---------------- ----- ---- --------- -------------- Disk #2, Partition #0 Disk #2, Partition #0 Installable File System False True 0 1099523162112 512 1048576 Disk #3, Partition #0 Disk #3, Partition #0 Installable File System False True 0 536878252032 512 1048576 Disk #4, Partition #0 Disk #4, Partition #0 Installable File System False True 0 1082130432 512 65536 Disk #5, Partition #0 Disk #5, Partition #0 Installable File System False True 0 1082130432 512 65536 Disk #1, Partition #0 Disk #1, Partition #0 Installable File System False True 0 107376279552 512 1048576 Disk #0, Partition #0 Disk #0, Partition #0 Installable File System True True 0 104857600 512 1048576 Disk #0, Partition #1 Disk #0, Partition #1 Installable File System False True 1 81684070400 512 105906176 Disk #0, Partition #2 Disk #0, Partition #2 Installable File System False True 2 104857600000 512 81789976576 Disk #0, Partition #3 Disk #0, Partition #3 Installable File System False True 3 104857600000 512 186647576576 A [64K cluster size](http://msdn.microsoft.com/en-us/library/dd758814(v=sql.100).aspx) is good for SQL Server. But what about the offset? The simple calculation below can be used to check this... **StartingOffset / BlockSize / 128** (a 64K cluster has 128 sectors assuming a 512 block size). If this calculation spits out a number with any decimal places then you have some disk aligning to do. ****