Mailing List Archive

Gparted leaves gaps
Hello list,

I use gparted often, usually from SystemRescueCD, and a common task is to
move partitions to allow for one to be enlarged. I should be able to specify
all the operations in a list, but whenever I do that gparted inserts 1MB gaps
between partitions, so I have to do one at a time. Even the latest bootable
gparted CD image does the same.

Can anyone tell me what causes this? Has it anything to do with my always
specifying partition size as a power of 8? (I'm of the old school, having been
sent on my first computer hardware course in 1972.)

--
Regards,
Peter.
Re: Gparted leaves gaps [ In reply to ]
On 1/4/21 12:39 am, Peter Humphrey wrote:
> Hello list,
>
> I use gparted often, usually from SystemRescueCD, and a common task is to
> move partitions to allow for one to be enlarged. I should be able to specify
> all the operations in a list, but whenever I do that gparted inserts 1MB gaps
> between partitions, so I have to do one at a time. Even the latest bootable
> gparted CD image does the same.
>
> Can anyone tell me what causes this? Has it anything to do with my always
> specifying partition size as a power of 8? (I'm of the old school, having been
> sent on my first computer hardware course in 1972.)
>
Forcing alignment on megabyte boundaries? - I cant find a reason, but I
think I read in the past it was for efficiency with modern file systems.

BillK
Re: Gparted leaves gaps [ In reply to ]
On Thursday, 1 April 2021 03:04:31 BST William Kenworthy wrote:
> On 1/4/21 12:39 am, Peter Humphrey wrote:
> > Hello list,
> >
> > I use gparted often, usually from SystemRescueCD, and a common task is to
> > move partitions to allow for one to be enlarged. I should be able to
> > specify all the operations in a list, but whenever I do that gparted
> > inserts 1MB gaps between partitions, so I have to do one at a time. Even
> > the latest bootable gparted CD image does the same.
> >
> > Can anyone tell me what causes this? Has it anything to do with my always
> > specifying partition size as a power of 8? (I'm of the old school, having
> > been sent on my first computer hardware course in 1972.)
>
> Forcing alignment on megabyte boundaries? - I cant find a reason, but I
> think I read in the past it was for efficiency with modern file systems.
>
> BillK

Yes, 4K physical sector size and partition alignment, ubiquitous on modern
'Advanced Format' drives, is used by all partitioning tools these days.

There are many references in the interwebs, but in summary modern AF spinning
drives have 4096 byte physical sector size with a 512 byte logical sector
size. To ensure alignment you could start a partition at an LBA divisible by
8, but since Microsoft came out with Vista's partition manager a convention of
1MB has been set as the starting point:

512 * 2048 = 1,048,576

The 1MB (2048 logical sectors) convention for the start of a partition is used
to cater for various hardware and partitioning requirements, inc. different
RAID data stripe sizes, SSDs with different erase block sizes, etc. It
ensures logical-physical partition alignment to optimise performance when
delete/write operations take place and as long as you are not trying to
squeeze the very last ounce of usable space out of your terabytes of storage,
it achieves its stated aim.

Parted has 3 options for aligning the start of a partition: none, minimal and
optimal. With 'none' it will start a partition wherever you ask it, without
paying heed to logical-to-physical sector alignment. With 'minimal' it will
shift the start/end of a partition to make sure the minimum alignment between
logical and physical sectors is achieved. With 'optimal' it will check if the
partition is aligned to a multiple of the physical block size. 'Optimal' is
the default. You could check/set the alignment of logical-physical sectors
yourself, by making sure the start of your partitions is divisible by 8,
instead of adopting the GParted 1MB default boundary in any cases where it is
not necessary.
Re: Gparted leaves gaps [ In reply to ]
On Thursday, 1 April 2021 11:13:07 BST Michael wrote:

> You could check/set the alignment of logical-physical sectors yourself, by
> making sure the start of your partitions is divisible by 8, instead of
> adopting the GParted 1MB default boundary in any cases where it is not
> necessary.

So it seems to be the partition start points that matter; sizes have nothing
to do with it. Makes sense, now I think about it.

I've just realigned all my partitions to accord with that insight. It turned
out that most of them had small differences from 8^n sizes and start points,
which would explain all those unpartitioned spaces.

All well now. Thanks all.

--
Regards,
Peter.
Re: Gparted leaves gaps [ In reply to ]
On Thursday, 1 April 2021 16:06:37 BST Peter Humphrey wrote:
> On Thursday, 1 April 2021 11:13:07 BST Michael wrote:
> > You could check/set the alignment of logical-physical sectors yourself, by
> > making sure the start of your partitions is divisible by 8, instead of
> > adopting the GParted 1MB default boundary in any cases where it is not
> > necessary.
>
> So it seems to be the partition start points that matter; sizes have nothing
> to do with it. Makes sense, now I think about it.

Yes, it is the starting point which determines the first 512 byte logical
sector and those what follow it, are aligned with the first 4096 byte physical
sector and those that follow it.

When these are not aligned a write operation instructed by software could
straddle more than one physical sector, even when the data to be stored is
less than 4096B. This results in moving, deleting, writing more sectors and
data than necessary, a measurably inefficient process. This is noticeable on
spinning drive benchmarks and can get much worse on flash and SSDs with their
coarser erase Vs write pages (a.k.a. write amplification).


> I've just realigned all my partitions to accord with that insight. It turned
> out that most of them had small differences from 8^n sizes and start
> points, which would explain all those unpartitioned spaces.
>
> All well now. Thanks all.

I recall fighting against gparted's optimal alignment myself when partitioning
tools first started catering for 4K size sectors, only having to realign my
partitions as soon as I realised the error of my ways! ;-)