[Fai-commit] r6571 - branches/experimental/patches

Michael Tautschnig mt at alioth.debian.org
Sun Jun 5 21:42:01 UTC 2011


Author: mt
Date: 2011-06-05 21:42:01 +0000 (Sun, 05 Jun 2011)
New Revision: 6571

Added:
   branches/experimental/patches/setup-storage_align-first-part-preserve
Modified:
   branches/experimental/patches/series
   branches/experimental/patches/setup-storage_loopback-support
Log:
setup-storage: align+preserve first partition bugfix, fixed error in loopback patch


Modified: branches/experimental/patches/series
===================================================================
--- branches/experimental/patches/series	2011-06-05 19:06:48 UTC (rev 6570)
+++ branches/experimental/patches/series	2011-06-05 21:42:01 UTC (rev 6571)
@@ -19,3 +19,4 @@
 setup-storage_loopback-support
 setup-storage_syntax-check-mode
 setup-storage_softraid-assemble-error
+setup-storage_align-first-part-preserve

Added: branches/experimental/patches/setup-storage_align-first-part-preserve
===================================================================
--- branches/experimental/patches/setup-storage_align-first-part-preserve	                        (rev 0)
+++ branches/experimental/patches/setup-storage_align-first-part-preserve	2011-06-05 21:42:01 UTC (rev 6571)
@@ -0,0 +1,47 @@
+2011-06-05  Michael Tautschnig  <mt at debian.org>
+
+	* setup-storage/Sizes.pm: properly handle alignment and preserving first
+		partition.
+Index: trunk/lib/setup-storage/Sizes.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Sizes.pm
++++ trunk/lib/setup-storage/Sizes.pm
+@@ -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} = "-";

Modified: branches/experimental/patches/setup-storage_loopback-support
===================================================================
--- branches/experimental/patches/setup-storage_loopback-support	2011-06-05 19:06:48 UTC (rev 6570)
+++ branches/experimental/patches/setup-storage_loopback-support	2011-06-05 21:42:01 UTC (rev 6571)
@@ -83,15 +83,11 @@
    }
  }
  
-@@ -1128,11 +1132,16 @@
-       if ($part->{size}->{preserve} || $part->{size}->{resize});
-     $fs = "" if ($fs eq "-");
- 
-+    my $dn = &FAI::make_device_name($disk, $part_id);
+@@ -1131,8 +1135,13 @@
      my $pre = "cleared2_$disk";
--    $pre .= ",exist_" . &FAI::make_device_name($disk, $prev_id) if ($prev_id > -1);
-+    $pre .= ",exist_$dn" if ($prev_id > -1);
+     $pre .= ",exist_" . &FAI::make_device_name($disk, $prev_id) if ($prev_id > -1);
      # build a parted command to create the partition
++    my $dn = &FAI::make_device_name($disk, $part_id);
      &FAI::push_command( "parted -s $disk mkpart $part_type \"$fs\" ${start}B ${end}B",
 -      $pre, "exist_" . &FAI::make_device_name($disk, $part_id) );
 +      $pre, "prep2_$dn");




More information about the Fai-commit mailing list