Home > Storage > How to Create 4KB Aligned Partitions in Windows XP and Linux

How to Create 4KB Aligned Partitions in Windows XP and Linux

There has been some news regarding the new Western Digital “EARS” series “Advanced Format” hard drives and the associated performance problems. While these drives can be faster than older drives because of the larger sector size, a partition formatted without the correct alignment can slow to less than a third.

Read on for brief instructions on how to fix the problem in Linux and Windows XP.

If you formatted the drive in Windows Vista or later, your partition is already aligned properly.

If you are using Windows XP or earlier, or if you are using a more recent version of Windows but formatted your drive in Windows XP, download and use the Western Digital Advanced Format Software.

If you are using Linux, you will need to use a command line utility named fdisk. Read below for instructions:

  1. Enter a Linux console. There should be an icon in your UI menus named something like “Console,” “Terminal,” or perhaps “xterm.” Alternatively, if you are at the keyboard of the machine itself, you may press CTRL ALT F1 to get to a console.
  2. Log in with your account
  3. You’ll need to figure out which device corresponds to the 4k drive. If you don’t already know this, enter the command “fdisk -l” (that’s a dash and then the lower case  letter l, as in “list”).
    You will get a list of all detected hard drives. Look for the entry that matches your new drive’s size. For example, for a 2TB WD EARS drive, you may see something like this, followed by several lines of additional information:

    Disk /dev/sdg: 2000.4 GB, 2000398934016 bytes
    Look for the part in bold. It will generally be of the form “/dev/sdX” where X is some letter.

    If you follow the instructions from here on, it will delete all data on your drive. Make backups as necessary.

  4. Type “fdisk /dev/sdX” where X is the drive letter you found earlier.
  5. If you already have a partition on the drive, delete it by pressing ‘d’ and then ‘enter’, and for each partition enter the number when instructed, then repeat this step until all partitions are gone.
  6. From this step on,  follow the example fdisk session below. Enter commands as shown in red, and read the notes  in blue.
root@sheridan:/media# fdisk /dev/sdg     Replace "sdg" with the device found above in step 3.
The number of cylinders for this disk is set to 243201.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-243201, default 1):
Using default value 1                   Just press enter for the two cylinder prompts
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201):
Using default value 243201              Press enter again here
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83

Command (m for help): x

Expert command (m for help): b
Partition number (1-4): 1
New beginning of data (63-3907024064, default 63): 64

Expert command (m for help): r

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Once this is done, your partition is created and you may format a drive as you normally would, using mkfs.ext4 or similar.

Addendum, 20 May 2010: It may be worth taking a look at this post on the San Francisco Nomad which suggest a slightly different approach.

Categories: Storage Tags:
  1. notgonnatellya
    March 27th, 2010 at 12:03 | #1

    Charles, I just bought an EARS drive. I have 7, but I really bought it for my WHS box. Are you saying I can format it in 7 and just drop it in the WHS box and I’m good to go? If so, that’s a pretty simple solution.

    Thanks.

  2. Sean
    March 27th, 2010 at 19:54 | #2

    I had to format a EARS drive recently and I was using Win7, so I wasn’t worried about alignment. However, I couldn’t find a single shred of information anywhere about what to select for (what windows calls) “Allocation Unit Size” in the format options. I’m assuming this refers to sector size, and that I should select 4096 bytes, which is what I did. But nowhere in Western Digital’s website or documentation does it mention what I was supposed to do, and I’m still not sure if I selected the right thing.

  3. March 27th, 2010 at 20:45 | #3

    notgonnatellya :

    Charles, I just bought an EARS drive. I have 7, but I really bought it for my WHS box. Are you saying I can format it in 7 and just drop it in the WHS box and I’m good to go? If so, that’s a pretty simple solution.

    Thanks.

    Yes, Windows Home Server, and any post-XP version of Windows, and most recent Linux distributions, should format the drive with 4K sectors in mind,

  4. notgonnatellya
    March 28th, 2010 at 11:51 | #4

    I’ve done some research since my first post. From what I’ve seen on various WHS boards, it appears that you cannot format it in 7, because data share drives are always reformatted when added to the drive pool.

    However, it appears that the ISO/Acronis based alignment tool does work. I’m still researching it, but I’m guessing that the way it works is you add it to the pool, WHS formats the drive and then you shut down, boot from the WD/Acronis CD, realign the sectors and go from there.

    Hopefully this is the right way to go….I’d hate to think of the pain I’d suffer if I had to completely rebuild the data when WHS 2.0 comes out….but I assume that aligning vs using the jumper is the more future proof method….though I’ve yet to see anything to convince me of that.

  5. March 29th, 2010 at 13:33 | #5

    How does one create two consecutive aligned partitions on one disk? Is it possible, or alignment is only possible with one sole partition?

  6. April 2nd, 2010 at 21:53 | #6

    @Sean
    Sean, you made the right choice by selecting a 4096 byte allocation size.

    This refers to the file system cluster size, which is the minimum size a file can occupy (any smaller file is still given that many bytes). This is different than sector size because it is at the file system (software) level, independent of the hard drive.
    4096 is almost always the best choice for NTFS. Larger sizes can save the file system a little work and can slightly improve performance in certain cases, but most Windows file system utilities assume 4k clusters and some simply will not work with any other size.
    Even fundamental features like compression, part of NTFS since the beginning (1993), do not function with non 4096 byte “allocation units”.

  7. April 2nd, 2010 at 22:00 | #7

    @Panos
    Panos, it should be the same process to make a second aligned partition. In Linux, follow the instructions above, but make both partitions in fdisk. In the expert menu where you press ‘b’ to change the partition alignment, it asks which partition you would like to align. You can set the first one to 64 and the second one to be a few larger than the default — enough to evenly divide by 4.

    A more current Linux distribution, like a more current version of Windows, should handle this automatically. If they don’t, they will soon, because 4k drives will soon be the norm.

  8. notgonnatellya
    April 3rd, 2010 at 19:02 | #8

    Just thought I’d add that I used the WD/Acronis utility and it was very quick and easy. I spent far more time researching what to do than it took to reboot, run the utility and boot back into WHS.

    With that said, by all accounts, if you already have a lot of data on the HD, it will take significantly longer. I had virtually no data, so it only took a few seconds.

  9. May 19th, 2010 at 06:34 | #9

    Charles, I just bought an EARS drive. I have 7, but I really bought it for my WHS box. Are you saying I can format it in 7 and just drop it in the WHS box and I’m good to go? If so, that’s a pretty simple solution.

    Thanks.

  10. May 20th, 2010 at 18:19 | #10

    @Bruce
    Yes, Windows Home Server makes creating a properly aligned partition much, much easier than Linux, though using fdisk is easier than using Linux’s “parted” utility, whose interface is just slightly better than manipulating your hard drive with a small magnet.

  11. Roy
    October 12th, 2010 at 08:45 | #11

    I know this topic is old, but now other vendors are selling 4k drives.

    Are there any instructions on what to do for Win XP for (for example) the latest Samsung 2TB drives, which cannot use the WD align utility?

    Thanks!

  12. Roy
    October 12th, 2010 at 10:06 | #12

    Update: Further reading leads me to believe that any of these would work (but can you confirm):

    1. Partition/format the disk in a Win7 system before using it in an XP system

    2. Use XP’s DISKPART tool to partition the drive, via “create partition primary align=64″

    3. Acquire the Paragon Alignment Tool ($30)

    4. Boot from a Linux disk and use “parted” (haven’t learned details yet)

    Comments appreciated!

  13. Roy
    October 12th, 2010 at 10:47 | #13

    Sorry, I meant “Gparted” for #4.

  14. Roy
    October 13th, 2010 at 05:39 | #14

    (The very next day after I posted the above, GiveAwayoftheDay is giving away the Paragon Alignment Tool, so I was able to get a free copy.)

  15. Nobody
    December 29th, 2010 at 00:27 | #15

    A easier way in Linux is to use the -u Option. This way you don’t have to use Expert stuff.
    Here how it works:

    # fdisk -u /dev/sdX

    #################### Start ################################
    The number of cylinders for this disk is set to 121601.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): p

    Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
    255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Disk identifier: 0x10bd10bc

    Device Boot Start End Blocks Id System

    Command (m for help): n
    Command action
    e extended
    p primary partition (1-4)
    p
    Partition number (1-4): 1
    First sector (63-1953525167, default 63): 64
    Last sector, +sectors or +size{K,M,G} (64-1953525167, default 1953525167):
    Using default value 1953525167

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.

    #################### END ################################

    Source: http://www.linuxconfig.org/linux-wd-ears-advanced-format

  1. May 15th, 2010 at 09:17 | #1
  2. August 25th, 2010 at 06:30 | #2
  3. March 29th, 2011 at 10:56 | #3
  4. April 24th, 2011 at 01:45 | #4