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



commit 19186e21523f59280acd61ff5cb41d6bd278df4b
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Oct 19 20:05:55 2021 +0100

    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

 src/Dialog_Partition_Resize_Move.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index bd9457b3..b3fea9d5 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -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 );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]