Allow resize/move of partition to sector 2048 when following another (#172)

This case is an extension of the setup in the previous commit.  Add a
second partition several megabytes after the first.  It looks like this:

  [TABLE][PTN#1]                  [PTN#2]
  <-- 1st MiB -><- several MiBs ->

Just need to make the gap 2 MiB or more so that it can be seen what the
resize/move dialog is allowing.  Setup like this using an 8 MiB gap and
8 MiB partition #2.

For MSDOS use:
    dd if=/dev/zero bs=1M of=/dev/sdb
    (echo 1,2047; echo 18432,16384) | sfdisk -uS --force /dev/sdb
    mkswap /dev/sdb2

For GPT use:
    sgdisk --zap-all /dev/sdb
    sgdisk --set-alignment=1 --new 1:34:2047 /dev/sdb
    sgdisk --new 2:18432:34815 /dev/sdb
    mkswap /dev/sdb2

In GParted try to move partition sdb2 to the left as much as possible,
or try to resize the start to the left as much as possible.  GParted
insists on having a 1 MiB of padding before the start of sdb2, forcing
it to start at sector 4096, even though sector 2048 is free and aligns
to whole megabytes.

Delete the preceding partition.  Now GParted allows sdb2 to be moved or
resize to start at sector 2048.

Fix another off by one error in the sector comparison for the
resizing/moving of partitions.

Closes #172 - GParted doesn't allow creation of a partition starting at
              sector 2048 if there is a partition before it
This commit is contained in:
Mike Fleetwood 2021-10-19 20:05:55 +01:00 committed by Curtis Gedak
parent 0bfbac4f65
commit 19186e2152
1 changed files with 1 additions and 1 deletions

View File

@ -159,7 +159,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const PartitionVector & p
MIN_SPACE_BEFORE_MB = 0 ;
else
{
if ( START <= MEBIBYTE / new_partition->sector_size )
if (START < MEBIBYTE / new_partition->sector_size)
MIN_SPACE_BEFORE_MB = 1 ;
else
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( *new_partition );