3

Proper partition alignment ensures ideal performance during data access. Incorrect partition alignment will cause reduced performance, especially with regard to SSDs (with an internal page size of 4,096 or 8,192 bytes, for example), hard disks with four-kilobyte (4,096 byte) sectors and RAID volumes.

-- http://www.thomas-krenn.com/en/wiki/Partition_Alignment

You might still wonder just how important proper partition alignment is. Then check this out, http://www.ibm.com/developerworks/library/l-4kb-sector-disks/#benchmarks

The best Linux disk partitioning and alignment check utility is sfdisk. I used it for 10+ years, till now, when it can't handle the GPT partitions.

I know the de facto Linux disk partitioning tool is gparted, which can handle GPT disks. But IMHO, it is not handling it correctly, because the default alignment option is MiB, which IMHO is wrong. Well, not wrong strictly speaking, but at least not optimal, i.e., not properly done.

According to my finding (from MS, http://support.microsoft.com/kb/300415/en-us),

On all MBR disks, the size or offset parameters are rounded up to cylinder alignment. On GPT disks, the size or offset parameters are rounded to sector alignment.

If it is true, then the gparted's default alignment option for GPT is wrong. But the problem is that the only other sanity option is to align to cylinder, which is overkill, and no option to align to sector. Thus my question, because I need to look elsewhere.

I found a

How to align partitions for best performance using parted
http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/

it has a good start, but ends with partitioning the GPT disk as a whole (100%), which fails to explain how to align partitions for best performance for other/normal partitions.

So, which Linux tools can partition GPT with proper alignment?

1 Answer 1

4

The best Linux disk partitioning and alignment check utility is sfdisk. I used it for 10+ years, till now, when it can't handle the GPT partitions.

You don't say how you did this, so I'm a bit puzzled, since AFAIK sfdisk doesn't have any alignment options to speak of. (You can specify certain values in units of KiB, MiB, etc., though.) Note that the options to set cylinder/head/sector (CHS) geometry values are 100% useless today. CHS was useful back in the 1970s and 1980s, but by the mid-1990s it was nothing but a convenient fiction. By the late 1990s it had become an inconvenient fiction and today it's either worse than useless or irrelevant, depending on what you're doing with CHS. This is both because of the newer alignment needs of Advanced Format, RAID, and SSD configurations and because CHS maxes out at about 8GiB, which means that it's ignored on most modern disks.

I know the de facto Linux disk partitioning tool is gparted, which can handle GPT disks. But IMHO, it is not handling it correctly, because the default alignment option is MiB, which IMHO is wrong. Well, not wrong strictly speaking, but at least not optimal, i.e., not properly done.

The minimal optimal alignment value varies from one disk to another, but on most disks, the optimal alignment is some power-of-2 multiple, such as 4KiB, 256KiB, or 512KiB. Using 1MiB alignment is therefore optimal for most disks in terms of performance, although a few disks (mostly SSDs) have values that are higher than this.

Note that setting a 1MiB alignment value on something that has smaller needs results in, at most, a bit under 1MiB of wasted space at the start of the disk (and maybe some more wasted space between partitions, but that's not certain). 1MiB of wasted space on a modern disk is puny. On a 1TB disk, for instance, 1MiB is 0.0001% of the total disk space, if I've done my arithmetic correctly. I wouldn't worry about such a tiny amount of wasted disk space.

According to my finding (from MS, http://support.microsoft.com/kb/300415/en-us),

On all MBR disks, the size or offset parameters are rounded up to cylinder alignment. On GPT disks, the size or offset parameters are rounded to sector alignment.

I'm not too familiar with Microsoft tools, but I know that the Windows GUI tools have been using 1MiB alignment by default on all disks since Windows Vista. If the text-mode DISKPART described on that page is still doing cylinder alignment, then IMO it's badly broken. Nothing today should be using CHS or cylinder alignment, except possibly tools intended to use it in order to support very old OSes. (The last I checked, the Linux cfdisk still used cylinder alignment. For this reason, I say it's broken.)

I suspect that the reference to "sector alignment" means specifying values in sectors by default. Certainly using unaligned partitions (which is what "sector alignment" really means) is likely to produce degraded performance on most modern disks.

How to align partitions for best performance using parted http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/

it has a good start, but ends with partitioning the GPT disk as a whole (100%), which fails to explain how to align partitions for best performance for other/normal partitions.

No, that site describes aligning a single partition on the disk. You'd simply apply the same principles to all subsequent partitions. In other words, if you find that the optimum value for your disk is 2048-sector alignment, you'd make sure that every partition begins on a multiple of that value, such as 2,097,152 or 15,403,008.

To answer the question that's implicit in the title of this thread, my own GPT fdisk (gdisk, sgdisk, and cgdisk), which is available in most Linux distributions in the gdisk or gptfdisk package, supports setting any alignment value you like. The default is 1MiB (2048 sectors on most disks), but you can adjust it by using the l option on the experts' menu (in gdisk; details differ for the other tools in this family). Unfortunately, I've found that the Linux system calls that are supposed to return alignment data are unreliable (although they've become more reliable recently than they were a couple of years ago). Thus, you may need to look up model specifications or check your RAID settings to learn what's optimal for your disks.

2
  • "Using 1MiB alignment is therefore optimal for most disks in terms of performance". Thanks
    – xpt
    Mar 23, 2014 at 2:03
  • "Note that the options to set cylinder/head/sector (CHS) geometry values are 100% useless today." -- Add zone recording to the list of HHD characteristics that invalidate the concept of "cylinder alignment". The manufacturers do not provide the actual number of sectors per track allocated for each physical cylinder. So specifying "cylinder alignment" will likely put the partition boundary in the middle of a track on a modern HDD (which all use zone recording). Bottom line: you don't have the salient info to optimize partition boundaries on a HDD.
    – sawdust
    Mar 24, 2014 at 0:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .