What is partition alignment and why whould I need it? [duplicate]

Solution 1:

Newer hard drives are being manufactured to utilise 4 kilobyte sectors rather than the conventional 512-byte sectors.

This is done to make more efficient use of the physical space on hard drives as for every sector there is a small batch of error correction data on the drive, and by going from 0.5kilobytes to 4kilobytes per sector means that there can be much less space on the drive wasted in this error correction data. To show what I mean here is an image taken from the Wikipedia article on Advanced Format Drives:

enter image description here

The reason for having to align your disk stems from the interaction of software that was written to expect 512-byte sectors working on a drive with 4-kilobyte sectors. If the software expects 512-byte sectors then it may well be trying to write to what it thinks is the "second" sector of a cluster, but is in fact the second 512 bytes of a 4-kilobyte sector.

The problem is that "Advanced Format" drives that simulate a 512-byte sector to the operating system but actually work with 4-kilobyte sectors internally is that a sector can only be written "in one go". In order to write to that second 512 byte area the entire 4KB sector must be read, and then re-written back to the drive, and this is a slower process than simply telling the drive to rewrite the whole 4KB sector.

Even if the operating system is aware of 4KB sectors it must have the drive properly aligned so that the boundaries between sectors agrees between where the drive says they are and where the operating system thinks they are.

Then there are SSDs, which have a similar problem in that they can be written byte-by-byte, but only erased in large blocks of typically 256KB or 512KB. In this way, in order to maximise performance you must align the partition (and thus sector) boundaries along one of those 256 or 512KB blocks.

For this reason a lot of modern partitioning tools simply align the entire drive along a 1MB boundary, which neatly does away with the need to detect whether you have any of the many types of drive, be they 512-byte sectors, 4KB sectors, or SSD with some arbitrary block size.

-=EDIT=-

To tell if your drive is properly aligned there are a number of ways to check, as this article on Lifehacker mentions. The advice applies mainly to SSds but is equally relevant to making sure a normal hard drive is aligned properly:

To see if your partitions are aligned correctly, hit the Start menu and type in msinfo32. Enter Msinfo32 and go to Components > Storage > Disks. Look for your SSD on the list and find the "Partition Starting Offset" item. If this number is divisible by 4096 (that is, if dividing it by 4096 equals a whole number and not a decimal), your partition is correctly aligned. If not, you need to realign it. Luckily, this is pretty easy to do with the Gparted live CD. If you have an Ubuntu live CD lying around, that will work too, since it has Gparted available under System > Administration.