[gparted] Ensure 1 MiB reserved when moving extended partition to start of drive



commit 37689eef9db42eed96058ab10cc7532a8a11d39d
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Wed Oct 20 22:06:10 2021 +0100

    Ensure 1 MiB reserved when moving extended partition to start of drive
    
    On an MSDOS partitioned drive, create an extended partition at least 2
    MiBs from the start of the drive.  Like this:
        dd if=/dev/zero bs=1M of=dev/sdb
        echo 4096,4096,5 | sfdisk -uS --force /dev/sdb
    
    The resize/move dialog appears to allow the extended partition to be
    moved and/or resized to the very start of the drive, over the top of the
    partition table, without reserving the first 1 MiB.  Ensure the dialog
    reserves the first 1 MiB, like it does when moving normal partitions.
    
    Reference:
        ceab9bde57fafbc96f9d90d2a86713cd07126f8b
        Ensure 1 MiB reserved when moving partition to start of disk

 src/Dialog_Partition_Resize_Move.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index b3fea9d5..3064ea1b 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -265,7 +265,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const PartitionVector &
        if ( previous <= 0 )
                MIN_SPACE_BEFORE_MB = 0 ;
        else
-               MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( *new_partition );
+       {
+               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);
+       }
        total_length = previous + new_partition->get_sector_length() + next;
        TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, new_partition->sector_size, UNIT_MIB ) 
);
        MB_PER_PIXEL = TOTAL_MB / 500.00 ;


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