[SETUP] Align partition start at 2048 minimum
authorPierre Schweitzer <pierre@reactos.org>
Sun, 11 Nov 2018 16:34:35 +0000 (17:34 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 11 Nov 2018 16:38:37 +0000 (17:38 +0100)
This will allow compatibility with modern OSes and
modern disk management utilities.
It will also improve performances by properly aligning
partition start.
And it will let enough room at the begin of the disk
for 3rd party bootloaders.

WARNING: this is not compatible with previous partition
model, and old one will likely not be compatible. You'll
have to erase your whole partition table and start from
scratch.

base/setup/lib/utils/partlist.c

index 7145b2f..0d66b6c 100644 (file)
@@ -819,7 +819,10 @@ ScanForUnpartitionedDiskSpace(
         NewPartEntry->DiskEntry = DiskEntry;
 
         NewPartEntry->IsPartitioned = FALSE;
         NewPartEntry->DiskEntry = DiskEntry;
 
         NewPartEntry->IsPartitioned = FALSE;
-        NewPartEntry->StartSector.QuadPart = (ULONGLONG)DiskEntry->SectorAlignment;
+        if (DiskEntry->SectorAlignment < 2048)
+            NewPartEntry->StartSector.QuadPart = 2048ULL;
+        else
+            NewPartEntry->StartSector.QuadPart = (ULONGLONG)DiskEntry->SectorAlignment;
         NewPartEntry->SectorCount.QuadPart = AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) -
                                              NewPartEntry->StartSector.QuadPart;
 
         NewPartEntry->SectorCount.QuadPart = AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) -
                                              NewPartEntry->StartSector.QuadPart;
 
@@ -837,7 +840,10 @@ ScanForUnpartitionedDiskSpace(
     }
 
     /* Start partition at head 1, cylinder 0 */
     }
 
     /* Start partition at head 1, cylinder 0 */
-    LastStartSector = DiskEntry->SectorAlignment;
+    if (DiskEntry->SectorAlignment < 2048)
+        LastStartSector = 2048ULL;
+    else
+        LastStartSector = DiskEntry->SectorAlignment;
     LastSectorCount = 0ULL;
     LastUnusedSectorCount = 0ULL;
 
     LastSectorCount = 0ULL;
     LastUnusedSectorCount = 0ULL;