correcting a bad partition offset requires formatting your disk. you’ve been warned!

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:

 microsoft diskpart version 6.0.6001
 copyright (c) 1999-2007 microsoft corporation.
 on computer: visualblind

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.

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

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

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:

dmddiag.exe -v
remember: fixing the partition offset issue means formatting the disk to have the correct partition offset or moving the data to a disk that already has the correct partition offset. although windows server 2008 onward creates disks with the correct offset, taking a disk that was created on windows server 2003 and attaching it to windows server 2008 will have no effect on the existing partition offset.



Disqus Comments Loading...

Recent Posts

FreeNAS Error Creating Pool

command '('gpart', 'create', '-s', 'gpt', '/dev/da8')' returned non-zero exit status 1. If you get this error while trying to create… Read More

May 14, 2019 8:22 am 08:22

Change Grub Default Boot Entry on Linux Mint

i'm dual booting windows and linux mint on my laptop. the grub default is to boot into linux mint, however… Read More

April 23, 2019 7:45 pm 19:45

How to Reset Secure Channel On Active Directory Domain Controller

when you're a little too careless about virtualizing your domain controllers, cloning, migrating, backing up and restoring, returning from vacation… Read More

April 21, 2019 8:14 am 08:14

Run SystemD Script Before System Shutdown

for the sheer hell of it, a few weeks ago i wanted to see if i could properly and successfully… Read More

April 20, 2019 10:14 am 10:14

Learn Systemctl Usage to Manage Systemd Service in Linux

systemd is new service manager for linux. it's a replacement for all previous init systems (sysv/sysvinit & ubuntu's upstart) and… Read More

April 20, 2019 7:55 am 07:55

Force Delete Windows Server DHCP Failover Relationship

if you've found yourself here then chances are you messed up one of your domain controllers or at least one… Read More

April 20, 2019 5:54 am 05:54