Manual GPT partition alignment

  • Follow


Hi all, I need a second opinion on partition alignment of GPT
partitions on a 4K sector disk.
  parted /dev/sda unit s print
    Model: ATA WDC WD20EARS-00J (scsi)
    Disk /dev/sda: 3907029168s
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

As far as I know a GPT partitioned drive looks like this:
  LBA 0: MBR
  LBA 1-33: GPT1
  LBA 34-(nsect-34): addressable space
  LBA (nsect-33)-(nsect-1): GPT2

We're talking about 512 byte sectors since this 4K drive doesn't tell
its real sector size to the OS (hdparm -i /dev/sda: SectSize=0). So a
4K aligned GPT partitioned drive looks like this:
  [0...MBR/GPT1...33]
  [34...lost...8a-1]
  [8a...part1...8b-1]
  [8b...part2...8c-1]
  ...
  [8d...partk...8e-1]
  [8e...lost...nsect-34]
  [nsect-33...GPT2...nsect-1]

Suppose I just want 1 partition that covers the whole drive:
  [0...MBR/GPT1...33]
  [34...lost...8a-1]
  [8a...part1...8b-1]
  [8b...lost...nsect-34]
  [nsect-33...GPT2...nsect-1]

To maximize the partition but keep it aligned with the 4K sectors
  a = ceil(34/8.) = 5
  b = floor((n-34)/8.) = 488378641

So we should make a partition that start at 8a and ends at 8b-1:
  parted /dev/sda unit s mkpart primary 40 3907029127

Is this the correct way of thinking? When I do this, parted informs me
that "the resulting partition is not properly aligned for best
performance". Should I just ignore it?

Thx,

Wox
0
Reply Wox 9/28/2010 12:26:39 PM

> Hi all, I need a second opinion on partition alignment of GPT
> partitions on a 4K sector disk.

Align to a 1MiB boundary:  LBA of the first sector (in 4KiB units)
should be divisible by 256, and divisible by 2048 if somebody
is counting in 512-byte sectors.

-- 

0
Reply John 9/28/2010 1:49:50 PM


On Tue, 28 Sep 2010 06:49:50 -0700, John Reiser
<jreiserfl@comcast.net> wrote:

>> Hi all, I need a second opinion on partition alignment of GPT
>> partitions on a 4K sector disk.
>
>Align to a 1MiB boundary:  LBA of the first sector (in 4KiB units)
>should be divisible by 256, and divisible by 2048 if somebody
>is counting in 512-byte sectors.

Can you also explain me why I should start from 2048 and not 40?

Aligment to 4K means starting at byte a*4096 or 8*b*512. So when
counting in 512-byte sectors (as parted does), the first LBA should be
divisible by 8 (not 2048) and should be higher than 33 (last LBA of
GPT). Therefor one can start from 40. No?


0
Reply Wox 9/28/2010 2:25:20 PM

>>> Hi all, I need a second opinion on partition alignment of GPT
>>> partitions on a 4K sector disk.

>> Align to a 1MiB boundary:  LBA of the first sector (in 4KiB units)
>> should be divisible by 256, and divisible by 2048 if somebody
>> is counting in 512-byte sectors.

> Can you also explain me why I should start from 2048 and not 40?

If it's a memory technology drive such as Solid State Drive (SATA
or PATA flash memory) or USB flash memory drive, then most current
"erase blocks" in the flash hardware are 128KiB.  So you should
align to at least that much, else many 128KiB write operations will
be split across 128KiB boundaries, becoming two read-modify-write ops
with a 4X slowdown: a factor of 2 for the split, times a factor of 2
for the R-M-W.  Mechanical rotating drives sometimes are "cloned"
onto flash media, and it's handy if partitions are aligned already.
Not using (2048 - 40) 512-byte sectors on a mechanical drive is
a fractional loss of less than 0.001% (1MiB in 100GiB).

-- 
0
Reply John 9/28/2010 5:31:40 PM

3 Replies
823 Views

(page loaded in 0.073 seconds)

Similiar Articles:





7/23/2012 1:49:08 AM


Reply: