Skip to content

            Lost ?  |  Need an account:
 
Home >> Knowledge Base >> Operating Systems >> Windows >> Windows Disk Alignment
Windows Disk Alignment PDF Print E-mail
(7 votes, average 4.57 out of 5)
Written by Tom Hirt   
Saturday, 11 April 2009 17:34
Article Index
Windows Disk Alignment
Checking Windows Disk Alignment
Creating new Aligned Volumes
All Pages

 

How to get better I/O performance with RAID


Would you like to know how to increase your servers I/O performance by up to 40%!?  Well if so, then read on my friend!  Disk alignment is one of Windows best kept secrets (or worse depending on how you see it.)  If you’re running Windows Server 2000, 2003 or Windows XP with RAID, you are probably not getting the throughput you could if you had correctly aligned disks.

We’ve discussed this topic at length in our VMware Disk Alignment KB, but I felt it necessary to extend the discussion specifically for Windows.  If you’re not familiar with the term disk alignment or sector alignment, in layman’s terms it goes like this.  Windows like to write data to disk in 64k chucks.  However Windows Server 2000, 2003 and Windows XP all incorrectly begin writing data at the 63rd sector.  This means the first 1k of the chuck is written into one sector, and the remaining 63k in the next, and so on.  The consequence of this behavior means that for every read and write, two sectors must be accessed from disk instead of one.  This basically doubles your disk I/O.

Disk without Alignment

Disk with Alignment

You might be wondering if your victim to sector alignment issues?  Unfortunately, for most, this answer is yes.  Microsoft Windows Server 2000, Windows Server 2003 and Windows XP are all plagued with this problem.  Any new volumes created on these operating systems (if not set correctly with diskpart - more on that in a minute) will be aligned incorrectly.  Microsoft has addressed this issue in Windows Server 2008 and Window Vista, but upgrading an existing installation will not correct a disk that was originally formatted on one of the affected platforms.

  • Note: Although a non-RAID disk can also be effected, this is usually only a problem for RAID and/or LUN volumes.

Linux and UNIX distributions can also suffer from disk alignment issues with RAID.  There are far too many flavors and distributions to discuss, but I will tell you that most of the major distributions if not installed through some sort of expert mode (allowing you to specify the sector alignment) will by default format your drives starting on the 63rd sector.


 

Checking Windows Disk Alignment


Unfortunately, Windows doesn’t offer an easy way to check disk alignment.  We have created a script to help you analyze your servers WMI partition data for any Windows platform (physical or virtual).  You can find this script in our downloads area labeled Disk Alignment Check Utility.  The script will check all your computer’s volumes and report back if they are aligned.

  1. Download the Disk Alignment check Utility from our Downloads Area

  2. Extract the contents to your hard drive

  3. Double click run.bat

    Run.bat

  4. The script will produce some diagnostic information on your disk.  Take note of the “Starting Offset” and “Disk Alignment” fields.

    Alignment Check Output

After running this utility, most will find a starting offset of 32256 (or 31.5 KB.)  This is the default offset for Windows Server 2000, 2003 and Windows XP.  But, it’s not the end of the world.  So long as the affected volume is not running RAID, although not ideal, you’ll be ok.  Having a boot volume that is not aligned is also not uncommon; just make sure that your data or I/O intensive volumes are.  But if you find your exchange or SQL volumes are not aligned, well, then you have some work ahead of you.



 

Creating new Aligned Volumes


Most RAID configurations will write data in 64KB chucks (64KB = 128 sectors).  However, per Microsoft KB 929491 you should consider using an offset of at least 2048 sectors (1024 KB) to cover SAN configurations.  You're actual RAID/LUN configuration might dictate something else altogether so additional research should be made to ensure your starting sector aligns with your RAID/LUN configuration.

For most though, the 2048 sector offset is a safe bet.  We’ll use the diskpart utility to create a new partition aligned at 2048 (1024 KB) but you should double check with your SAN administrator and/or server administrator to verify the offset of your configuration.

  • Note: You must be running Service Pack 1 or later (diskpart was not included in earlier distributions)
  1. Run diskpart from the command line (start -> run -> cmd)

    C:\>diskpart

    Microsoft DiskPart version 5.2.3790.3959
    Copyright (C) 1999-2001 Microsoft Corporation.
    On computer: Server01

    DISKPART>

  2. List the disks available on your system

    DISKPART> list disk
    Disk ### Status Size Free Dyn Gpt
    ------------- ---------- ------------ ------------ ------ ------
    Disk 0 Online 10 GB 8033 KB
    Disk 1 Online 2047 MB 2047 MB
    DISKPART>


  3. Select the number of the disk you wish aligned

    DISKPART> select disk 1

    Disk 1 is now the selected disk.

    DISKPART>

  4. Create a new partition aligned at 1024KB (sector 2048)

    DISKPART> create partition primary align=1024

    DiskPart succeeded in creating the specified partition.

    DISKPART>

  5. Assign the drive a letter

    DISKPART> assign letter=e

    DiskPart successfully assigned the drive letter or mount point.

    DISKPART>

  6. Exit diskpart and format the disk using disk management.  Run compmgmnt.msc

    Run Computer Management

  7. From Disk Management, right click the new volume and select format

    Computer Management

  8. Enter your desired formatting defaults and click ok

    Format Options

  9. Confirm the format

    Format Warning Message

  10. Run the Disk Alignment Check Utility to verify the alignment of your new partition

    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    Device ID: Disk #0, Partition #0
    =============================================
    Number Of Blocks:  20948697
    Block Size:        512 KB
    Total Volume Size: 10 GB
    Type:              Installable File System
    Starting Offset:   32256 (31.5 KB)
    Disk Alignment:    NOT ALIGNED!!

    Device ID: Disk #1, Partition #0
    =============================================
    Number Of Blocks:  4174852
    Block Size:        512 KB
    Total Volume Size: 2 GB
    Type:              Installable File System
    Starting Offset:   1048576 (1024 KB)
    Disk Alignment:    Aligned

Congratulations, you've now aligned your new volume!  Just make sure you follow this guide for any new volumes that are created with RAID and LUN volumes and you'll be able to rest easy knowing that your getting the best possible I/O performance within Windows.

 


Add this page to your favorite website
AddThis Social Bookmark Button
Comments
Add New Search
ayaz |04/12/2009 11:20:03
I have configured Raid5 array 64KB stripe size using 6 1TB enterprise class WDC drives on nVidia 3000 professional chipset (Windows 2003 x64 32GB ram, 2quad core AMD cpu)
and I've used diskpart command
create partition primary align=64
and format selecting 64KB allocation unit

and the write speed is just 35- 40MBPS and after say 30mins it drops to 2MB (megabytes). The basic test I've done is13GB(single zip file that has single 16GB file in it ) network file copy on my raid5 array and extract it locally and it took 2hours to extract.
create partition primary align=1024 gives same results
create partition primary align=5120 gives same results (i read some where to align partition as 1024 * number of drives -1 for parity block so that's 1024*5 I believe)

The volume is DATA volume thus I can destroy and create if you have any suggestions
thirt |04/01/2010 06:07:02
Hi Ayaz - I've recently done a lot of performance/benchmarking in my lab experimenting with RAID and array controller performance. A couple pointers for you:

1. It sounds like you are assuming the speed of the network will outperform your local disk. An optimally configured 1000MB/s network will theatrically max out around 112MB/s – 120MB/s. Depending on the number of spindles and performance of your hardware etc., your disk subsystem could very easily outperform the speed of your network. Therefore, you might consider using an I/O load generation tool on your system to check its performance to remove the network as part of the equation.

2. If you insist on using the network, very you have jumbo frames enabled. You’ll get much better throughput on a network that is using jumbo frames and stand a better chance at hitting the performance limitations of your disk subsystem. I’m not sure how much improvement you should expect on a simple CIFS copy/extract, but I would image you should see something.

3. Aside from the network, the disk on the source system could also be the bottleneck. It may not be able to keep up with your RAID 5 6 spindle configuration. Again, consider using a load generation tool on the local system.

Of couple of my results for comparison:
8x SAS 10K RPM in RAID 5: 249MB/s
6x SATA 7200 RPM in RAID 0: 390MB/s


I was running these tests on a RHEL 5.2 system using ‘dd’ to create a 50GB file.
John |01/02/2010 16:14:32
Nice article, do you know of any apps that have been written to fix the offset of a system already built?
Getting error |16/04/2010 22:32:08
Hi,

While running the Disk align I am getting VBScript runtime error "Overflow: '[string : "31453470720"]'.
Any help would be appriciated.

Thanks
Harish
Zeniumtech |22/04/2010 00:13:28
Regarding overflow problem. I found a fix at this site:

http://blogs.msdn.com/ericlippert/archive/2004/12/01/integer-arithmetic-in-vbscript-part-one.aspx

Tried out the myMod function and no more overflow on my 250 GB drive. Don't have a 1TB or 2TB drive so have not tested that large of number.
harish |22/04/2010 08:27:49
Hi,

Thanks a lot. It worked with MyMod. I have tested on 1 TB HDD and it works. I will try on 2TB and let you know.

Thanks
Harish
Madhatterpa  - Please post updated vbs file for large disks |28/05/2010 22:41:03
I'm having the same issue with overflow. Can you please post or let us know how you modified the align.vbs script go use the MyMod function. Thanks
Harish |19/07/2010 09:48:09
Please confirm if you still require the modified script.

Thanks
Harish
superunknown |23/07/2010 08:48:10
Harish, can I have the modified script? Thanks..
Bob_Carswell |17/08/2010 09:38:07
This VB script is really useful but as above I'm having the same issue with overflow and would appreciate knowing how to modified the align.vbs script to use the MyMod function or have access to an already modified version.

Thks
pandawski |08/10/2010 10:05:39
change line 35 (the line with MOD operator), to

If ( objPartition.StartingOffset - Fix( (Fix(CDbl(objPartition.StartingOffset)))/(Fix(CDbl(1024)))) = 0) Then

for the vb overflow problem
scrubman |13/11/2010 08:54:32
thanks Pan! It stopped the overflow but now its innacuractely saying each of my disk are not aligned. any ideas anyone?
LucC |07/12/2010 08:45:56
This is a mod operation.
Replace "= 0" by "mod 1024".
If ( objPartition.StartingOffset - Fix( (Fix(CDbl(objPartition.StartingOffset)))/(Fix(CDbl(1024)))) mod 1024) Then

Pla |10/12/2010 20:13:32
You can also check the starting offset by using msinfo32:
Type "msinfo32" in windows run prompt.
Go to: Components -> Storage -> Disks
And look for "Partition Starting Offset"
donlassini |24/02/2011 18:08:13
I'd suggest replacing line 35 with
If Int(objPartition.StartingOffset / 1024) = (objPartition.StartingOffset / 1024) Then

Much easier to read than (fix(cdbl(....))

And GalnoSpoke, then don't use it. After the modification, it does work for me and shows what I need to see.
murphyld |18/03/2011 12:11:49
I used Diskpart from a Windows 7 recovery disk to create an aligned stripe but after I finished and went back into XP64 and ran the utility it still shows:

Device ID: Disk #0, Partition #0
=============================================
Number Of Blocks: 1953523057
Block Size: 512 KB
Total Volume Size: 932 GB
Type: Logical Disk Manager
Starting Offset: 32256 (31.5 KB)
Disk Alignment: NOT ALIGNED!!

Device ID: Disk #1, Partition #0
=============================================
Number Of Blocks: 1953523057
Block Size: 512 KB
Total Volume Size: 932 GB
Type: Logical Disk Manager
Starting Offset: 32256 (31.5 KB)
Disk Alignment: NOT ALIGNED!!

These are the commands that I used to create the stripe in Win7 diskpart:

SELECT DISK 0
CLEAN
CONVERT DYNAMIC

SELECT DISK 1
CLEAN
CONVERT DYNAMIC

CREATE VOLUME STRIPE DISKS=0,1 ALIGN=1024
ASSIGN LETTER=S
FORMAT FS=NTFS LABEL="STRIPE" QUICK
EXIT

Diskpart only reports success with each operation so why doesn't it work when I go back into XP?
roe |14/09/2011 09:21:12
A bit confused... I played around with different alignments and this script.

When creating a partition with the standard 31,5KB offset the script showed "NOT ALIGNED!!"

However, when creating a partition with offset 137KB (which by my calculations isnt dividable by the 128KB stripe size on my SAN) it showed "Aligned" ??
Geoff Faulkner  - Network and Systems Manager |27/01/2012 00:48:24
I have been using the GPARTED live CD to align the disk partition of a Windows system that is already built. The live CD is a linux boot CD that can move and resize partitions.

In my procedures I make a copy of the virtual machine in case something goes wrong during the resize operation. I strongly suggest this, or having a recent SAN snapshot available because the operation does occassionally fail, destroying the partition.

1. Download the latest GParted live CD from http://gparted.org/ and copy to the datastore with your ISOs.
2. Shutdown the virtual machine.
3. Open the local datastore of on of the VMware hosts, and the SAN datastore where the vm resides.
4. Copy from the SAN to the local datastore.
5. Remove the virtual machine from inventory. The files reside on the SAN if we need to add the original machine back.
6. Add the virtual machine to inventory from the local datastore.
7. Edit the machine settings. Mount the GParted ISO, select connected at startup. In the Options tab choose Boot options and check "the next time the vm boots force entry into the BIOS screen"
8. Power on the VM. Select "I moved it" when promted so the NICs don't get a new MAC address.
9. In the BIOS, make sure the CD-ROM is set to first boot priority (higher than the hard disk).
10. Save and exit, booting to GParted.
11. Select the drive and partition. Click Resize/Move. Put 2MB before the partition. Select align none. Click ok, and accept the warning. GParted won't let you put a 1 here first. For some reason you have to move past 1024, then back.
12. Apply the change. Accept the warning.
13. After complete, do it again. This time change the 2 to a 1MB before the partition. This is the final align to start the partition at 1024.
14. Apply the change. Accept the warning.
15. Repeat for any other drives and parititons on the VM.
16. Shutdown
17. Dismount the ISO and reboot.
18. Windows will run a disk check on the moved parition and then reboot.
19. Windows will find new hardware. Reboot when finished.
20. Check your alignment with the align.vbs utility.
21. If everything is good, then delete the vm folder from the SAN datastore.
22. Perform a storage migration of the virtual machine from the local datastore back to the SAN. This can be done while the machine is powered on with VMware.

I hope this helps! I have gone through all the machines in my inventory and performance of the machines and SAN in general seems better after aligning my disks.

Geofff
Geoff Faulkner  - Network Manager |27/01/2012 00:49:04
I have been using the GPARTED live CD to align the disk partition of a Windows system that is already built. The live CD is a linux boot CD that can move and resize partitions.

In my procedures I make a copy of the virtual machine in case something goes wrong during the resize operation. I strongly suggest this, or having a recent SAN snapshot available because the operation does occassionally fail, destroying the partition.

1. Download the latest GParted live CD from http://gparted.org/ and copy to the datastore with your ISOs.
2. Shutdown the virtual machine.
3. Open the local datastore of on of the VMware hosts, and the SAN datastore where the vm resides.
4. Copy from the SAN to the local datastore.
5. Remove the virtual machine from inventory. The files reside on the SAN if we need to add the original machine back.
6. Add the virtual machine to inventory from the local datastore.
7. Edit the machine settings. Mount the GParted ISO, select connected at startup. In the Options tab choose Boot options and check "the next time the vm boots force entry into the BIOS screen"
8. Power on the VM. Select "I moved it" when promted so the NICs don't get a new MAC address.
9. In the BIOS, make sure the CD-ROM is set to first boot priority (higher than the hard disk).
10. Save and exit, booting to GParted.
11. Select the drive and partition. Click Resize/Move. Put 2MB before the partition. Select align none. Click ok, and accept the warning. GParted won't let you put a 1 here first. For some reason you have to move past 1024, then back.
12. Apply the change. Accept the warning.
13. After complete, do it again. This time change the 2 to a 1MB before the partition. This is the final align to start the partition at 1024.
14. Apply the change. Accept the warning.
15. Repeat for any other drives and parititons on the VM.
16. Shutdown
17. Dismount the ISO and reboot.
18. Windows will run a disk check on the moved parition and then reboot.
19. Windows will find new hardware. Reboot when finished.
20. Check your alignment with the align.vbs utility.
21. If everything is good, then delete the vm folder from the SAN datastore.
22. Perform a storage migration of the virtual machine from the local datastore back to the SAN. This can be done while the machine is powered on with VMware.

I hope this helps! I have gone through all the machines in my inventory and performance of the machines and SAN in general seems better after aligning my disks.

Geofff
John |27/01/2012 01:08:22
I use Paragon's alignment tool, works great.
http://www.paragon-software.com/home/partition-alignment/index.html
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:D:):(:0:shock::confused:8):lol::x:P:oops::cry::evil::twisted::roll::wink::!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

Last Updated on Tuesday, 23 June 2009 15:23
 

Forum Activity

Author:
Author: kenny22
Jan.24.12
Author: AaronRiley
Jan.15.12

Online Stats

Guests Online: 83
Members Online: 0