[Fai-commit] r6711 - trunk/lib/setup-storage

Michael Tautschnig mt at alioth.debian.org
Sat Oct 22 12:53:02 UTC 2011


Author: mt
Date: 2011-10-22 12:53:02 +0000 (Sat, 22 Oct 2011)
New Revision: 6711

Modified:
   trunk/lib/setup-storage/Sizes.pm
Log:
setup-storage/Sizes.pm: properly handle alignment and preserving first partition.



Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm	2011-10-22 12:52:16 UTC (rev 6710)
+++ trunk/lib/setup-storage/Sizes.pm	2011-10-22 12:53:02 UTC (rev 6711)
@@ -625,6 +625,9 @@
     # the start byte for the next partition - first partition starts at 1M as is
     # new default for most systems it seems
     my $next_start = 1024 * 1024;
+    # force original start if first partition will be preserved
+    $next_start = $current_disk->{partitions}->{1}->{begin_byte}
+      if ($FAI::configs{$config}{partitions}{1}{size}{preserve});
 
     if ($FAI::configs{$config}{disklabel} eq "gpt") {
       # modify the disk to claim the space for the second partition table
@@ -643,13 +646,24 @@
       &FAI::init_part_config("primary");
       $FAI::configs{$config}{gpt_bios_part} =
         (&FAI::phys_dev($FAI::partition_pointer_dev_name))[2];
-      my ($s, $e) = &FAI::make_range("1-1", $current_disk->{size} . "B");
       # enter the range into the hash
+      my $s = 1024 * 1024;
       $FAI::partition_pointer->{size}->{range} = "$s-$s";
       # retain the free space at the beginning and fix the position
-      $FAI::partition_pointer->{start_byte} = $next_start;
-      $FAI::partition_pointer->{end_byte} = $next_start + $s - 1;
-      $next_start += $s;
+      if ($FAI::configs{$config}{partitions}{1}{size}{preserve})
+      {
+        # try to squeeze it in before first partition
+        ($next_start - $s > 63 * $current_disk->{sector_size}) or
+          die "Insufficient space before first and preserved partition to insert gpt-bios partiton\n";
+        $FAI::partition_pointer->{start_byte} = $next_start - $s;
+        $FAI::partition_pointer->{end_byte} = $next_start - 1;
+      }
+      else
+      {
+        $FAI::partition_pointer->{start_byte} = $next_start;
+        $FAI::partition_pointer->{end_byte} = $next_start + $s - 1;
+        $next_start += $s;
+      }
       # set proper defaults
       $FAI::partition_pointer->{encrypt} = 0;
       $FAI::partition_pointer->{filesystem} = "-";




More information about the Fai-commit mailing list