the default alignment of 31.5kb on windows server 2003 can lead to enormous i/o performance problems with sql server (see are your disk partition offsets, raid stripe sizes, and ntfs allocation units set correctly?). i thought it would be useful to do a quick blog post showing how to use the diskpart and wmic tools. google them for lots of info from the microsoft site – but be careful not to play around with any of the destructive options on productions systems. the options i’m using below will not alter the disks in any way.
note: this stuff applies to mbr disks, not gpt or dynamic disks. although these require correct alignment too, i don’t have any information on how to do it for those disks. the sqlcat team will be publishing some guidelines but has not yet done so, afaik. check out the sqlcat team whitepaper disk partition alignment best practices for sql server for full details on this topic.
bring up a command prompt and type
diskpart. you’ll see something like:
c:\users\administrator>diskpart microsoft diskpart version 6.0.6001 copyright (c) 1999-2007 microsoft corporation. on computer: visualblind diskpart>
next you need to list the logical disks that windows knows about. type
list disk. you’ll see something like:
diskpart> list disk disk ### status size free dyn gpt ——– ———- ——- ——- — — disk 0 online 136 gb 1434 mb disk 1 online 1116 gb 0 b disk 2 online 2036 gb 0 b
disks 1 and 2 are two raid arrays i’m using right now for the performance benchmarking series. notice that the numbers in the free column aren’t correct – not sure why not.
to see the partitions on a disk, you need to set the
diskpart focus to be that disk. type
select disk x, where x is the disk you want to focus on. you’ll see something like:
diskpart> select disk 1 disk 1 is now the selected disk. diskpart>
and now you can list the partitions on the disk using list partition. you’ll see something like:
diskpart> list partition partition ### type size offset ————- —————- ——- ——- partition 1 primary 1116 gb 1024 kb diskpart>
this is the output from one of my windows servr 2008 servers, where the default partition offset is 1mb – which doesn’t lead to perf issues.
on another windows xp system, i get the following output:
diskpart> select disk 0 disk 0 is now the selected disk. diskpart> list partition partition ### type size offset ————- —————- ——- ——- partition 1 primary 119 gb 32 kb diskpart>
this disk isn’t aligned correctly. if this was a raid array, i’d pay a perf penalty every time a read or write straddled a raid stripe offset. see the blog post link at the top of this post for more details.
unfortunately, diskpart isn’t always the best tool to use to get partition offsets, as it rounds up the values, and when there are multiple partitions, it can be hard to tell exactly what’s what, especially whtih lots of disks where you need to select each one and then list the partitions.
in this case, use wmic to get the exact numbers. the command is as follows:
wmic partition get blocksize, startingoffset, name, index
for my server, i get the following output:
blocksize index name startingoffset 512 0 disk #1, partition #0 1048576 512 0 disk #2, partition #0 1048576 512 0 disk #0, partition #0 1505755136
for dynamic disks, use:
when you're a little too careless about virtualizing your domain controllers, cloning, migrating, backing up and restoring, returning from vacation… Read More
systemd is new service manager for linux. it's a replacement for all previous init systems (sysv/sysvinit & ubuntu's upstart) and… Read More