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:
    ceab9bde57
    Ensure 1 MiB reserved when moving partition to start of disk
This commit is contained in:
Mike Fleetwood 2021-10-20 22:06:10 +01:00 committed by Curtis Gedak
parent 19186e2152
commit 37689eef9d
1 changed files with 6 additions and 1 deletions

View File

@ -265,7 +265,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const PartitionVector &
if ( previous <= 0 ) if ( previous <= 0 )
MIN_SPACE_BEFORE_MB = 0 ; MIN_SPACE_BEFORE_MB = 0 ;
else 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_length = previous + new_partition->get_sector_length() + next;
TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, new_partition->sector_size, UNIT_MIB ) ); TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, new_partition->sector_size, UNIT_MIB ) );
MB_PER_PIXEL = TOTAL_MB / 500.00 ; MB_PER_PIXEL = TOTAL_MB / 500.00 ;