[Fai-commit] r6314 - branches/experimental/patches
Michael Tautschnig
mt at alioth.debian.org
Mon Mar 14 21:57:13 UTC 2011
Author: mt
Date: 2011-03-14 21:57:11 +0000 (Mon, 14 Mar 2011)
New Revision: 6314
Added:
branches/experimental/patches/setup-storage_internals-cleanup
Removed:
branches/experimental/patches/setup-storage_no-extra-number
Modified:
branches/experimental/patches/bugfix-498412
branches/experimental/patches/series
branches/experimental/patches/setup-storage_better-error-msg
branches/experimental/patches/setup-storage_deterministic-lv-ordering
branches/experimental/patches/setup-storage_extended-is-not-last
branches/experimental/patches/setup-storage_gpt-bios-fix
branches/experimental/patches/setup-storage_hardcode-63-sectors
branches/experimental/patches/setup-storage_lvm-raid-preserve
branches/experimental/patches/setup-storage_man-page-fixes
branches/experimental/patches/setup-storage_no-cylinder-boundaries
branches/experimental/patches/setup-storage_user-100-percent
Log:
setup-storage: fixed bugs related to partition alignment and some code cleanup
Modified: branches/experimental/patches/bugfix-498412
===================================================================
--- branches/experimental/patches/bugfix-498412 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/bugfix-498412 2011-03-14 21:57:11 UTC (rev 6314)
@@ -15,7 +15,7 @@
# for syntax checks
BASH_SCRIPTS = lib/fai-divert lib/fai-mount-disk lib/fai-savelog lib/fai-vol_id lib/get-boot-info lib/get-config-dir lib/get-config-dir-cvs lib/get-config-dir-file lib/get-config-dir-git lib/get-config-dir-hg lib/get-config-dir-nfs lib/get-config-dir-svn lib/mkramdisk lib/mount2dir lib/prcopyleft lib/subroutines lib/task_sysinfo lib/updatebase
-@@ -75,6 +75,7 @@
+@@ -76,6 +76,7 @@
mkdir -p $(DESTDIR)/etc/{init,init.d} $(DESTDIR)/usr/share/fai/{pixmaps/small,setup-storage}
install man/* $(DESTDIR)/man
pod2man -c '' -r '' -s8 bin/dhcp-edit > $(DESTDIR)/man/dhcp-edit.8
Modified: branches/experimental/patches/series
===================================================================
--- branches/experimental/patches/series 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/series 2011-03-14 21:57:11 UTC (rev 6314)
@@ -25,4 +25,4 @@
setup-storage_better-error-msg
setup-storage_lvm-raid-preserve
setup-storage_deterministic-lv-ordering
-setup-storage_no-extra-number
+setup-storage_internals-cleanup
Modified: branches/experimental/patches/setup-storage_better-error-msg
===================================================================
--- branches/experimental/patches/setup-storage_better-error-msg 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_better-error-msg 2011-03-14 21:57:11 UTC (rev 6314)
@@ -31,7 +31,7 @@
comment: /^\s*#.*/
-@@ -1068,20 +1069,57 @@
+@@ -1068,20 +1069,60 @@
################################################################################
sub check_config {
@@ -43,6 +43,9 @@
(scalar(keys %{ $FAI::configs{$config}{partitions} }) > 0) or
die "Empty disk_config stanza for device $1\n";
+ foreach my $p (keys %{ $FAI::configs{$config}{partitions} }) {
++ next if (1 == $FAI::configs{$config}{partitions}{$p}{size}{extended});
++ defined($FAI::configs{$config}{partitions}{$p}{mountpoint}) or
++ &FAI::internal_error("Undefined mountpoint for non-extended partition");
+ my $this_mp = $FAI::configs{$config}{partitions}{$p}{mountpoint};
+ next if ($this_mp eq "-");
+ defined($all_mount_pts{$this_mp}) and die
Modified: branches/experimental/patches/setup-storage_deterministic-lv-ordering
===================================================================
--- branches/experimental/patches/setup-storage_deterministic-lv-ordering 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_deterministic-lv-ordering 2011-03-14 21:57:11 UTC (rev 6314)
@@ -25,7 +25,7 @@
# init device tree
$FAI::dev_children{$FAI::device} = ();
# the rule must not return undef
-@@ -1140,6 +1144,12 @@
+@@ -1143,6 +1147,12 @@
}
} elsif ($config =~ /^VG_(.+)$/) {
next if ($1 eq "--ANY--");
Modified: branches/experimental/patches/setup-storage_extended-is-not-last
===================================================================
--- branches/experimental/patches/setup-storage_extended-is-not-last 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_extended-is-not-last 2011-03-14 21:57:11 UTC (rev 6314)
@@ -6,7 +6,7 @@
===================================================================
--- trunk.orig/lib/setup-storage/Sizes.pm
+++ trunk/lib/setup-storage/Sizes.pm
-@@ -362,15 +362,9 @@
+@@ -361,15 +361,9 @@
($part->{size}->{extended} == $curr_part->{is_extended})
or die "Preserved partition $part_dev_name can't change extended/normal setting\n";
@@ -25,7 +25,7 @@
}
# on gpt, ensure that the partition ends at a sector boundary
-@@ -714,37 +708,45 @@
+@@ -703,37 +697,45 @@
# reference to the current partition
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
Modified: branches/experimental/patches/setup-storage_gpt-bios-fix
===================================================================
--- branches/experimental/patches/setup-storage_gpt-bios-fix 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_gpt-bios-fix 2011-03-14 21:57:11 UTC (rev 6314)
@@ -6,7 +6,7 @@
===================================================================
--- trunk.orig/lib/setup-storage/Sizes.pm
+++ trunk/lib/setup-storage/Sizes.pm
-@@ -685,13 +685,20 @@
+@@ -674,13 +674,20 @@
$min_req_total_space += 33 * $current_disk->{sector_size};
# on gpt-bios we'll need an additional partition to store what doesn't fit
@@ -29,7 +29,7 @@
# set proper defaults
$FAI::partition_pointer->{encrypt} = 0;
$FAI::partition_pointer->{filesystem} = "-";
-@@ -741,6 +748,11 @@
+@@ -730,6 +737,11 @@
# partition done
shift @worklist;
Modified: branches/experimental/patches/setup-storage_hardcode-63-sectors
===================================================================
--- branches/experimental/patches/setup-storage_hardcode-63-sectors 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_hardcode-63-sectors 2011-03-14 21:57:11 UTC (rev 6314)
@@ -7,7 +7,7 @@
===================================================================
--- trunk.orig/lib/setup-storage/Sizes.pm
+++ trunk/lib/setup-storage/Sizes.pm
-@@ -651,15 +651,11 @@
+@@ -640,15 +640,11 @@
my $next_start = 0;
if ($FAI::configs{$config}{disklabel} eq "msdos") {
Copied: branches/experimental/patches/setup-storage_internals-cleanup (from rev 6310, branches/experimental/patches/setup-storage_no-extra-number)
===================================================================
--- branches/experimental/patches/setup-storage_internals-cleanup (rev 0)
+++ branches/experimental/patches/setup-storage_internals-cleanup 2011-03-14 21:57:11 UTC (rev 6314)
@@ -0,0 +1,268 @@
+2011-03-10 Michael Tautschnig <mt at debian.org>
+
+ * setup-storage/{Parser,Sizes,Fstab,Volumes}.pm: Don't keep redundant number
+ field in config data structure.
+ * setup-storage/Sizes.pm: Removed redundant min_req_total_space tracking
+ variable.
+Index: trunk/lib/setup-storage/Fstab.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Fstab.pm
++++ trunk/lib/setup-storage/Fstab.pm
+@@ -224,8 +224,8 @@
+ # skip extended partitions and entries without a mountpoint
+ next if ($p_ref->{size}->{extended} || $p_ref->{mountpoint} eq "-");
+
+- my $device_name = 0 == $p_ref->{number} ? $device :
+- &FAI::make_device_name($device, $p_ref->{number});
++ my $device_name = 0 == $p ? $device :
++ &FAI::make_device_name($device, $p);
+
+ # if the mount point the /boot mount point, variables must be set
+ if ($p_ref->{mountpoint} eq $boot_mnt_point) {
+Index: trunk/lib/setup-storage/Parser.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Parser.pm
++++ trunk/lib/setup-storage/Parser.pm
+@@ -275,10 +275,6 @@
+ size => {}
+ };
+
+- # as we can't compute the index from the reference, we need to store the
+- # $part_number explicitly
+- (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended}->{number} = $extended;
+-
+ my $part_size =
+ (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended}->{size};
+
+@@ -314,10 +310,6 @@
+ (\%FAI::configs)->{$FAI::device}->{partitions}->{$part_number};
+ $FAI::partition_pointer_dev_name = &FAI::make_device_name($disk, $part_number);
+
+- # as we can't compute the index from the reference, we need to store the
+- # $part_number explicitly
+- $FAI::partition_pointer->{number} = $part_number;
+-
+ # the partition is not an extended one
+ $FAI::partition_pointer->{size}->{extended} = 0;
+
+Index: trunk/lib/setup-storage/Sizes.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Sizes.pm
++++ trunk/lib/setup-storage/Sizes.pm
+@@ -295,15 +295,14 @@
+ # @param $config Disk config
+ # @param $current_disk Current config of this disk
+ # @param $next_start Start of the next partition
+-# @param $min_req_total_space Minimum space required on disk
+ # @param $max_avail The maximum size of a partition on this disk
+ #
+-# @return Updated values of ($next_start, $min_req_total_space)
++# @return Updated value of $next_start
+ #
+ ################################################################################
+ sub do_partition_preserve {
+
+- my ($part_id, $config, $disk, $next_start, $min_req_total_space, $max_avail) = @_;
++ my ($part_id, $config, $disk, $next_start, $max_avail) = @_;
+ # reference to the current disk config
+ my $current_disk = $FAI::current_config{$disk};
+
+@@ -335,9 +334,6 @@
+ $part->{start_byte} = $curr_part->{begin_byte};
+ $part->{end_byte} = $curr_part->{end_byte};
+
+- # and add it to the total disk space required by this config
+- $min_req_total_space += $part->{size}->{eff_size};
+-
+ # set the next start
+ $next_start = $part->{end_byte} + 1;
+
+@@ -354,9 +350,6 @@
+ $current_disk->{bios_heads})) or
+ warn "Preserved partition $part_dev_name does not end at a cylinder boundary, parted may fail to restore the partition!\n";
+
+- # add 512B of disk usage if this is a logical partition
+- $min_req_total_space += 512 if ($part_id > 4);
+-
+ # make sure we don't change extended partitions to ordinary ones and
+ # vice-versa
+ ($part->{size}->{extended} == $curr_part->{is_extended})
+@@ -375,7 +368,7 @@
+ or die "Preserved partition $part_dev_name does not end at a sector boundary\n";
+ }
+
+- return ($next_start, $min_req_total_space);
++ return $next_start;
+ }
+
+ ################################################################################
+@@ -430,17 +423,15 @@
+ # @param $disk This disk
+ # @param $next_start Start of the next partition
+ # @param $block_size Requested alignment
+-# @param $min_req_total_space Minimum space required on disk
+ # @param $max_avail The maximum size of a partition on this disk
+ # @param $worklist Reference to the remaining partitions
+ #
+-# @return Updated values of ($next_start, $min_req_total_space)
++# @return Updated value of $next_start
+ #
+ ################################################################################
+ sub do_partition_real {
+
+- my ($part_id, $config, $disk, $next_start, $block_size, $min_req_total_space,
+- $max_avail, $worklist) = @_;
++ my ($part_id, $config, $disk, $next_start, $block_size, $max_avail, $worklist) = @_;
+ # reference to the current disk config
+ my $current_disk = $FAI::current_config{$disk};
+
+@@ -451,15 +442,8 @@
+
+ # compute the effective start location on the disk
+ # msdos specific offset for logical partitions
+- if (($FAI::configs{$config}{disklabel} eq "msdos")
+- && ($part_id > 4)) {
+-
+- # add 512B disk usage if this is a logical partition
+- $min_req_total_space += 512;
+-
+- # move the start byte as well
+- $next_start += 512;
+- }
++ $next_start += 512 if (($FAI::configs{$config}{disklabel} eq "msdos")
++ && ($part_id > 4));
+
+ # partition starts at where we currently are + requested alignment, or remains
+ # fixed in case of resized ntfs
+@@ -567,13 +551,10 @@
+ # write the end byte to the configuration
+ $part->{end_byte} = $end_byte;
+
+- # and add it to the total disk space required by this config
+- $min_req_total_space += $part->{size}->{eff_size};
+-
+ # set the next start
+ $next_start = $part->{end_byte} + 1;
+
+- return ($next_start, $min_req_total_space);
++ return $next_start;
+ }
+
+ ################################################################################
+@@ -633,9 +614,6 @@
+ }
+ }
+
+- # the space required on the disk
+- my $min_req_total_space = 0;
+-
+ # the start byte for the next partition
+ my $next_start = 0;
+
+@@ -643,7 +621,6 @@
+ # on msdos disk labels, the first partitions starts at head #1; well,
+ # enforce a 63-sectors-per-track layout
+ $next_start = 63 * $current_disk->{sector_size};
+- $min_req_total_space += $next_start;
+
+ } elsif ($FAI::configs{$config}{disklabel} eq "gpt") {
+ # on GPT-EFI disk labels the first 34 and last 33 sectors must be left alone
+@@ -652,31 +629,24 @@
+ # modify the disk to claim the space for the second partition table
+ $current_disk->{end_byte} -= 33 * $current_disk->{sector_size};
+
+- # the space required by the GPTs
+- $min_req_total_space += (34 + 33) * $current_disk->{sector_size};
+-
+ } elsif ($FAI::configs{$config}{disklabel} eq "gpt-bios") {
+ # the MBR requires space, too
+ $next_start = $current_disk->{sector_size};
+- $min_req_total_space += $current_disk->{sector_size};
+ # not too sure whether this is needed: standard GPT partition table space
+ $next_start += 33 * $current_disk->{sector_size};
+- $min_req_total_space += 33 * $current_disk->{sector_size};
+
+ # apparently parted insists in having some space left at the end too
+ # modify the disk to claim the space for the second partition table
+ $current_disk->{end_byte} -= 33 * $current_disk->{sector_size};
+
+- # the space required by the GPTs
+- $min_req_total_space += 33 * $current_disk->{sector_size};
+-
+ # on gpt-bios we'll need an additional partition to store what doesn't fit
+ # in the MBR; this partition must be at the beginning, but it should be
+ # created at the very end such as not to invalidate indices of other
+ # partitions
+ $FAI::device = $config;
+ &FAI::init_part_config("primary");
+- $FAI::configs{$config}{gpt_bios_part} = $FAI::partition_pointer->{number};
++ $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
+ $FAI::partition_pointer->{size}->{range} = "$s-$s";
+@@ -684,7 +654,6 @@
+ $FAI::partition_pointer->{start_byte} = $next_start;
+ $FAI::partition_pointer->{end_byte} = $next_start + $s - 1;
+ $next_start += $s;
+- $min_req_total_space += $s;
+ # set proper defaults
+ $FAI::partition_pointer->{encrypt} = 0;
+ $FAI::partition_pointer->{filesystem} = "-";
+@@ -692,7 +661,7 @@
+ }
+
+ # the size of a 100% partition (the 100% available to the user)
+- my $max_avail = $current_disk->{size} - $min_req_total_space;
++ my $max_avail = $current_disk->{size} - $next_start;
+ # expressed in bytes
+ $max_avail = "${max_avail}B";
+
+@@ -746,15 +715,14 @@
+ shift @worklist;
+ # the partition $part_id must be preserved
+ } elsif ($part->{size}->{preserve}) {
+- ($next_start, $min_req_total_space) = &FAI::do_partition_preserve($part_id,
+- $config, $disk, $next_start, $min_req_total_space, $max_avail);
++ $next_start = &FAI::do_partition_preserve($part_id, $config, $disk,
++ $next_start, $max_avail);
+
+ # partition done
+ shift @worklist;
+ } else {
+- ($next_start, $min_req_total_space) = &FAI::do_partition_real($part_id,
+- $config, $disk, $next_start, $block_size, $min_req_total_space,
+- $max_avail, \@worklist);
++ $next_start = &FAI::do_partition_real($part_id, $config, $disk,
++ $next_start, $block_size, $max_avail, \@worklist);
+
+ # msdos does not support partitions larger than 2TiB
+ ($part->{size}->{eff_size} > (&FAI::convert_unit("2TiB") * 1024.0 *
+@@ -766,8 +734,8 @@
+ }
+
+ # check, whether there is sufficient space on the disk
+- ($min_req_total_space > $current_disk->{size})
+- and die "Disk $disk is too small - at least $min_req_total_space bytes are required\n";
++ ($next_start > $current_disk->{end_byte} + 1)
++ and die "Disk $disk is too small - at least $next_start bytes are required\n";
+
+ # make sure, extended partitions are only created on msdos disklabels
+ ($FAI::configs{$config}{disklabel} ne "msdos" && $extended > -1)
+Index: trunk/lib/setup-storage/Volumes.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Volumes.pm
++++ trunk/lib/setup-storage/Volumes.pm
+@@ -574,10 +574,10 @@
+ defined ($FAI::current_config{$1}) or die
+ "Can't preserve partition on $1 because $1 does not exist\n";
+ defined ($FAI::current_config{$1}{partitions}{$part_id}) or die
+- "Can't preserve ". &FAI::make_device_name($1, $part->{number})
++ "Can't preserve ". &FAI::make_device_name($1, $part_id)
+ . " because it does not exist\n";
+ defined ($part->{size}->{range}) or die
+- "Can't preserve ". &FAI::make_device_name($1, $part->{number})
++ "Can't preserve ". &FAI::make_device_name($1, $part_id)
+ . " because it is not defined in the current config\n";
+ }
+ }
Modified: branches/experimental/patches/setup-storage_lvm-raid-preserve
===================================================================
--- branches/experimental/patches/setup-storage_lvm-raid-preserve 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_lvm-raid-preserve 2011-03-14 21:57:11 UTC (rev 6314)
@@ -578,7 +578,7 @@
}
}
1;
-@@ -1081,6 +1134,8 @@
+@@ -1084,6 +1137,8 @@
next if ($this_mp eq "-");
defined($all_mount_pts{$this_mp}) and die
"Mount point $this_mp used twice\n";
@@ -587,7 +587,7 @@
($this_mp eq "none") or $all_mount_pts{$this_mp} = 1;
}
} elsif ($config =~ /^VG_(.+)$/) {
-@@ -1090,6 +1145,8 @@
+@@ -1093,6 +1148,8 @@
next if ($this_mp eq "-");
defined($all_mount_pts{$this_mp}) and die
"Mount point $this_mp used twice\n";
@@ -596,7 +596,7 @@
($this_mp eq "none") or $all_mount_pts{$this_mp} = 1;
}
next;
-@@ -1101,6 +1158,8 @@
+@@ -1104,6 +1161,8 @@
next if ($this_mp eq "-");
defined($all_mount_pts{$this_mp}) and die
"Mount point $this_mp used twice\n";
Modified: branches/experimental/patches/setup-storage_man-page-fixes
===================================================================
--- branches/experimental/patches/setup-storage_man-page-fixes 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_man-page-fixes 2011-03-14 21:57:11 UTC (rev 6314)
@@ -460,4 +460,4 @@
+Further documentation, including coding related information, is available
in a wiki page at http://wiki.fai-project.org/index.php/Setup-storage.
.SH AUTHOR
- FAI is courtesy of Thomas Lange <lange at informatik.uni-koeln.de>. Michael
+ The
Modified: branches/experimental/patches/setup-storage_no-cylinder-boundaries
===================================================================
--- branches/experimental/patches/setup-storage_no-cylinder-boundaries 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_no-cylinder-boundaries 2011-03-14 21:57:11 UTC (rev 6314)
@@ -1,9 +1,10 @@
-2011-02-11 Julien Blache <jblache at debian.org>
+2011-02-11 Julien Blache <jblache at debian.org>
+
* setup-storage/Sizes.pm: for backward compatibility with previous
- setup-storage versions, msdos partitions must be aligned to cylinder
- boundary and alignment constraints must not apply for start position of
- partitions 1 and 5. Preserving partitions on systems installed with
- previous versions of setup-storage breaks without this.
+ setup-storage versions, msdos partitions must be aligned to cylinder
+ boundary and alignment constraints must not apply for start position of
+ partitions 1 and 5. Preserving partitions on systems installed with previous
+ versions of setup-storage breaks without this.
2010-09-18 Michael Tautschnig <mt at debian.org>
@@ -12,11 +13,50 @@
cylinder-alignment. Thanks Patrick Cervicek for suggesting the
user-specified alignment.
* setup-storage.8: Document new align-at option.
+ * setup-storage/Sizes.pm: Take alignment into account for partition size
+ computation (thanks Frank Doepper for bringing up this problem). Size of
+ extended (partition) boot record is 512B and independent of disk head size.
Index: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk.orig/lib/setup-storage/Sizes.pm
+++ trunk/lib/setup-storage/Sizes.pm
-@@ -436,8 +436,9 @@
+@@ -353,9 +353,8 @@
+ $current_disk->{bios_heads})) or
+ warn "Preserved partition $part_dev_name does not end at a cylinder boundary, parted may fail to restore the partition!\n";
+
+- # add one head of disk usage if this is a logical partition
+- $min_req_total_space += $current_disk->{bios_sectors_per_track} *
+- $current_disk->{sector_size} if ($part_id > 4);
++ # add 512B of disk usage if this is a logical partition
++ $min_req_total_space += 512 if ($part_id > 4);
+
+ # make sure we don't change extended partitions to ordinary ones and
+ # vice-versa
+@@ -407,9 +406,6 @@
+ ($part_id <= 4) or
+ &FAI::internal_error("Extended partition wouldn't be a primary one");
+
+- my $epbr_size = $current_disk->{bios_sectors_per_track} *
+- $current_disk->{sector_size};
+-
+ # initialise the size and the start byte
+ $part->{size}->{eff_size} = 0;
+ $part->{start_byte} = -1;
+@@ -418,10 +414,10 @@
+ next if ($p < 5);
+
+ $part->{start_byte} = $FAI::configs{$config}{partitions}{$p}{start_byte} -
+- $epbr_size if (-1 == $part->{start_byte});
++ 512 if (-1 == $part->{start_byte});
+
+- $part->{size}->{eff_size} += $FAI::configs{$config}{partitions}{$p}{size}{eff_size} +
+- $epbr_size;
++ $part->{size}->{eff_size} +=
++ $FAI::configs{$config}{partitions}{$p}{size}{eff_size} + 512;
+
+ $part->{end_byte} = $FAI::configs{$config}{partitions}{$p}{end_byte};
+ }
+@@ -436,8 +432,9 @@
#
# @param $part_id Partition id within $config
# @param $config Disk config
@@ -27,7 +67,7 @@
# @param $min_req_total_space Minimum space required on disk
# @param $worklist Reference to the remaining partitions
#
-@@ -446,7 +447,7 @@
+@@ -446,7 +443,7 @@
################################################################################
sub do_partition_real {
@@ -36,28 +76,102 @@
# reference to the current disk config
my $current_disk = $FAI::current_config{$disk};
-@@ -549,34 +550,25 @@
- $current_disk->{sector_size};
- }
+@@ -456,6 +453,34 @@
+ my ($start, $end) = &FAI::make_range($part->{size}->{range},
+ $current_disk->{size} . "B");
-- # partition starts at where we currently are, or remains fixed in case of
-- # resized ntfs
++ # compute the effective start location on the disk
++ # msdos specific offset for logical partitions
++ if (($FAI::configs{$config}{disklabel} eq "msdos")
++ && ($part_id > 4)) {
++
++ # add 512B disk usage if this is a logical partition
++ $min_req_total_space += 512;
++
++ # move the start byte as well
++ $next_start += 512;
++ }
++
+ # partition starts at where we currently are + requested alignment, or remains
+ # fixed in case of resized ntfs
+ # Also, don't apply alignment constraint to partition 1 and 5 in an msdos disklabel
- if ($FAI::configs{$config}{partitions}{$part_id}{size}{resize} &&
- ($current_disk->{partitions}->{$part_id}->{filesystem} eq "ntfs")) {
- ($next_start <= $current_disk->{partitions}->{$part_id}->{begin_byte})
- or die "Cannot preserve start byte of ntfs volume on partition $part_id, space before it is too small\n";
- $next_start = $current_disk->{partitions}->{$part_id}->{begin_byte};
++ if ($FAI::configs{$config}{partitions}{$part_id}{size}{resize} &&
++ ($current_disk->{partitions}->{$part_id}->{filesystem} eq "ntfs")) {
++ ($next_start <= $current_disk->{partitions}->{$part_id}->{begin_byte})
++ or die "Cannot preserve start byte of ntfs volume on partition $part_id, space before it is too small\n";
++ $next_start = $current_disk->{partitions}->{$part_id}->{begin_byte};
+ } elsif ((0 != $next_start % $block_size)
+ && ((($part_id != 5) && ($part_id != 1))
+ || ($FAI::configs{$config}{disklabel} ne "msdos"))) {
+ $next_start += $block_size - ($next_start % $block_size);
++ }
++ $FAI::configs{$config}{partitions}{$part_id}{start_byte} =
++ $next_start;
++
+ # check, whether the size is fixed
+ if ($end != $start) {
+
+@@ -483,11 +508,8 @@
+
+ # logical partitions require the space for the EPBR to be left
+ # out
+- if (($FAI::configs{$config}{disklabel} eq "msdos")
+- && ($p > 4)) {
+- $end_of_range -= $current_disk->{bios_sectors_per_track} *
+- $current_disk->{sector_size};
+- }
++ $end_of_range -= 512 if (($FAI::configs{$config}{disklabel} eq "msdos")
++ && ($p > 4));
+ last;
+ } elsif ($FAI::configs{$config}{partitions}{$p}{size}{extended}) {
+ next;
+@@ -497,13 +519,11 @@
+ $current_disk->{size} . "B");
+
+ # logical partitions require the space for the EPBR to be left
+- # out
++ # out; in fact, even alignment constraints would have to be considered
+ if (($FAI::configs{$config}{disklabel} eq "msdos")
+- && ($p > 4)) {
+- $min_size += $current_disk->{bios_sectors_per_track} *
+- $current_disk->{sector_size};
+- $max_size += $current_disk->{bios_sectors_per_track} *
+- $current_disk->{sector_size};
++ && ($p != $part_id) && ($p > 4)) {
++ $min_size += 512;
++ $max_size += 512;
+ }
+
+ $min_req_space += $min_size;
+@@ -535,48 +555,9 @@
+ $end = $start;
}
- $FAI::configs{$config}{partitions}{$part_id}{start_byte} =
- $next_start;
+- # now we compute the effective locations on the disk
+- # msdos specific offset for logical partitions
+- if (($FAI::configs{$config}{disklabel} eq "msdos")
+- && ($part_id > 4)) {
+-
+- # add one head of disk usage if this is a logical partition
+- $min_req_total_space += $current_disk->{bios_sectors_per_track} *
+- $current_disk->{sector_size};
+-
+- # move the start byte as well
+- $next_start += $current_disk->{bios_sectors_per_track} *
+- $current_disk->{sector_size};
+- }
+-
+- # partition starts at where we currently are, or remains fixed in case of
+- # resized ntfs
+- if ($FAI::configs{$config}{partitions}{$part_id}{size}{resize} &&
+- ($current_disk->{partitions}->{$part_id}->{filesystem} eq "ntfs")) {
+- ($next_start <= $current_disk->{partitions}->{$part_id}->{begin_byte})
+- or die "Cannot preserve start byte of ntfs volume on partition $part_id, space before it is too small\n";
+- $next_start = $current_disk->{partitions}->{$part_id}->{begin_byte};
+- }
+- $FAI::configs{$config}{partitions}{$part_id}{start_byte} =
+- $next_start;
+-
- # the end may need some alignment, depending on the disk label
+ # partitions must end at the requested alignment
my $end_byte = $next_start + $start - 1;
@@ -80,7 +194,7 @@
# set $start and $end to the effective values
$start = $end_byte - $next_start + 1;
-@@ -625,6 +617,21 @@
+@@ -625,6 +606,21 @@
# reference to the current disk config
my $current_disk = $FAI::current_config{$disk};
@@ -102,7 +216,7 @@
# at various points the following code highly depends on the desired disk label!
# initialise variables
# the id of the extended partition to be created, if required
-@@ -668,13 +675,12 @@
+@@ -668,13 +664,12 @@
$min_req_total_space += (34 + 33) * $current_disk->{sector_size};
} elsif ($FAI::configs{$config}{disklabel} eq "gpt-bios") {
@@ -121,7 +235,7 @@
# apparently parted insists in having some space left at the end too
# modify the disk to claim the space for the second partition table
-@@ -741,7 +747,7 @@
+@@ -741,7 +736,7 @@
shift @worklist;
} else {
($next_start, $min_req_total_space) = &FAI::do_partition_real($part_id,
Deleted: branches/experimental/patches/setup-storage_no-extra-number
===================================================================
--- branches/experimental/patches/setup-storage_no-extra-number 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_no-extra-number 2011-03-14 21:57:11 UTC (rev 6314)
@@ -1,76 +0,0 @@
-2011-03-10 Michael Tautschnig <mt at debian.org>
-
- * setup-storage/{Parser,Sizes,Fstab,Volumes}.pm: Don't keep redundant number
- field in config data structure.
-Index: trunk/lib/setup-storage/Fstab.pm
-===================================================================
---- trunk.orig/lib/setup-storage/Fstab.pm
-+++ trunk/lib/setup-storage/Fstab.pm
-@@ -224,8 +224,8 @@
- # skip extended partitions and entries without a mountpoint
- next if ($p_ref->{size}->{extended} || $p_ref->{mountpoint} eq "-");
-
-- my $device_name = 0 == $p_ref->{number} ? $device :
-- &FAI::make_device_name($device, $p_ref->{number});
-+ my $device_name = 0 == $p ? $device :
-+ &FAI::make_device_name($device, $p);
-
- # if the mount point the /boot mount point, variables must be set
- if ($p_ref->{mountpoint} eq $boot_mnt_point) {
-Index: trunk/lib/setup-storage/Parser.pm
-===================================================================
---- trunk.orig/lib/setup-storage/Parser.pm
-+++ trunk/lib/setup-storage/Parser.pm
-@@ -275,10 +275,6 @@
- size => {}
- };
-
-- # as we can't compute the index from the reference, we need to store the
-- # $part_number explicitly
-- (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended}->{number} = $extended;
--
- my $part_size =
- (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended}->{size};
-
-@@ -314,10 +310,6 @@
- (\%FAI::configs)->{$FAI::device}->{partitions}->{$part_number};
- $FAI::partition_pointer_dev_name = &FAI::make_device_name($disk, $part_number);
-
-- # as we can't compute the index from the reference, we need to store the
-- # $part_number explicitly
-- $FAI::partition_pointer->{number} = $part_number;
--
- # the partition is not an extended one
- $FAI::partition_pointer->{size}->{extended} = 0;
-
-Index: trunk/lib/setup-storage/Sizes.pm
-===================================================================
---- trunk.orig/lib/setup-storage/Sizes.pm
-+++ trunk/lib/setup-storage/Sizes.pm
-@@ -687,7 +687,8 @@
- # partitions
- $FAI::device = $config;
- &FAI::init_part_config("primary");
-- $FAI::configs{$config}{gpt_bios_part} = $FAI::partition_pointer->{number};
-+ $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
- $FAI::partition_pointer->{size}->{range} = "$s-$s";
-Index: trunk/lib/setup-storage/Volumes.pm
-===================================================================
---- trunk.orig/lib/setup-storage/Volumes.pm
-+++ trunk/lib/setup-storage/Volumes.pm
-@@ -574,10 +574,10 @@
- defined ($FAI::current_config{$1}) or die
- "Can't preserve partition on $1 because $1 does not exist\n";
- defined ($FAI::current_config{$1}{partitions}{$part_id}) or die
-- "Can't preserve ". &FAI::make_device_name($1, $part->{number})
-+ "Can't preserve ". &FAI::make_device_name($1, $part_id)
- . " because it does not exist\n";
- defined ($part->{size}->{range}) or die
-- "Can't preserve ". &FAI::make_device_name($1, $part->{number})
-+ "Can't preserve ". &FAI::make_device_name($1, $part_id)
- . " because it is not defined in the current config\n";
- }
- }
Modified: branches/experimental/patches/setup-storage_user-100-percent
===================================================================
--- branches/experimental/patches/setup-storage_user-100-percent 2011-03-14 05:48:44 UTC (rev 6313)
+++ branches/experimental/patches/setup-storage_user-100-percent 2011-03-14 21:57:11 UTC (rev 6314)
@@ -33,7 +33,7 @@
($start > $curr_part->{count_byte} || $end < $curr_part->{count_byte})
and warn "Preserved partition $part_dev_name retains size " .
$curr_part->{count_byte} . "B\n";
-@@ -435,6 +435,7 @@
+@@ -431,6 +431,7 @@
# @param $next_start Start of the next partition
# @param $block_size Requested alignment
# @param $min_req_total_space Minimum space required on disk
@@ -41,7 +41,7 @@
# @param $worklist Reference to the remaining partitions
#
# @return Updated values of ($next_start, $min_req_total_space)
-@@ -442,15 +443,15 @@
+@@ -438,15 +439,15 @@
################################################################################
sub do_partition_real {
@@ -58,9 +58,9 @@
- $current_disk->{size} . "B");
+ my ($start, $end) = &FAI::make_range($part->{size}->{range}, $max_avail);
- # check, whether the size is fixed
- if ($end != $start) {
-@@ -489,8 +490,7 @@
+ # compute the effective start location on the disk
+ # msdos specific offset for logical partitions
+@@ -510,8 +511,7 @@
next;
} else {
my ($min_size, $max_size) = &FAI::make_range(
@@ -69,8 +69,8 @@
+ $FAI::configs{$config}{partitions}{$p}{size}{range}, $max_avail);
# logical partitions require the space for the EPBR to be left
- # out
-@@ -654,6 +654,7 @@
+ # out; in fact, even alignment constraints would have to be considered
+@@ -643,6 +643,7 @@
# on msdos disk labels, the first partitions starts at head #1
$next_start = $current_disk->{bios_sectors_per_track} *
$current_disk->{sector_size};
@@ -78,7 +78,7 @@
# the MBR requires space, too
$min_req_total_space += $current_disk->{bios_sectors_per_track} *
-@@ -705,6 +706,11 @@
+@@ -694,6 +695,11 @@
$FAI::partition_pointer->{mountpoint} = "-";
}
@@ -90,7 +90,7 @@
# the list of partitions that we need to find start and end bytes for
my @worklist = (&numsort(keys %{ $FAI::configs{$config}{partitions} }));
-@@ -756,13 +762,14 @@
+@@ -745,13 +751,14 @@
# the partition $part_id must be preserved
} elsif ($part->{size}->{preserve}) {
($next_start, $min_req_total_space) = &FAI::do_partition_preserve($part_id,
More information about the Fai-commit
mailing list