diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index 43b3ec30..7987ef9e 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -101,8 +101,31 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector= (MEBIBYTE / selected_partition .sector_size) + ) + { + //Find maximum sector_end (allocated or unallocated) within list of + // partitions inside the extended partition + Sector max_sector_end = 0 ; + for (unsigned int k = 0 ; k < partitions .size() ; k++ ) + { + if ( partitions[ k ] .sector_end > max_sector_end ) + max_sector_end = partitions[ k ] .sector_end ; + } + + //If not within 1 MiB of the end of the extended partition, then reserve 1 MiB + if ( ( max_sector_end - partitions[t+1] .sector_end ) > ( MEBIBYTE / selected_partition .sector_size ) ) + next -= MEBIBYTE / selected_partition .sector_size ; + } + } + //Only calculate MIN_SPACE_BEFORE_MB if we have a previous (unallocated) partition. // Otherwise there will not be enough graphical space to reserve a full 1 MiB for MBR/EBR. // Since this is an existing partition, if an MBR/EBR was needed then it already exists with enough space.