[Fai-commit] r4863 - people/michael/features/setup_harddisks_2/implementation/lib
mt at alioth.debian.org
mt at alioth.debian.org
Tue Apr 8 19:50:24 UTC 2008
Author: mt
Date: 2008-04-08 19:50:23 +0000 (Tue, 08 Apr 2008)
New Revision: 4863
Modified:
people/michael/features/setup_harddisks_2/implementation/lib/commands.pm
people/michael/features/setup_harddisks_2/implementation/lib/exec.pm
people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm
Log:
- proper resizing of ntfs volumes (but moving is not supported)
- catch more parted error messages
- warn, if any command exits with a non-zero exit status
Modified: people/michael/features/setup_harddisks_2/implementation/lib/commands.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/commands.pm 2008-04-08 17:11:50 UTC (rev 4862)
+++ people/michael/features/setup_harddisks_2/implementation/lib/commands.pm 2008-04-08 19:50:23 UTC (rev 4863)
@@ -563,16 +563,32 @@
# get the existing id
my $mapped_id = $part->{maps_to_existing};
+
+ # get the intermediate partition id
+ my $p = $FAI::current_config{$disk}{partitions}{$mapped_id}{new_id};
- # get the new partition id
- my $p = $FAI::current_config{$disk}{partitions}{$mapped_id}{new_id};
-
# get the new starts and ends
my $start = $part->{start_byte};
my $end = $part->{end_byte};
-
+
# build an appropriate command
- push @FAI::commands, "parted -s $disk resize $p ${start}B ${end}B";
+ # ntfs requires specific care
+ if ($FAI::current_config{$disk}{partitions}{$mapped_id}{filesystem} eq
+ "ntfs") {
+ # check, whether ntfsresize is available
+ &FAI::in_path("ntfsresize") or die "ntfsresize not found in PATH\n";
+ # ntfs partition can't be moved
+ ($start == $FAI::current_config{$disk}{partitions}{$mapped_id}{begin_byte})
+ or &FAI::internal_error("ntfs partition supposed to move");
+ # ntfsresize requires device names
+ my $eff_size = $part->{size}->{eff_size};
+ my $dev = $disk;
+ $dev = "${dev}p" if ($dev =~ m{^/dev/(cciss/c\dd\d|ida/c\dd\d|rd/c\dd\d|ataraid/d\d)$});
+ $dev = $dev . $p;
+ push @FAI::commands, "ntfsresize -s $eff_size $dev";
+ } else {
+ push @FAI::commands, "parted -s $disk resize $p ${start}B ${end}B";
+ }
}
# write the disklabel again to drop the partition table and create a new one
Modified: people/michael/features/setup_harddisks_2/implementation/lib/exec.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/exec.pm 2008-04-08 17:11:50 UTC (rev 4862)
+++ people/michael/features/setup_harddisks_2/implementation/lib/exec.pm 2008-04-08 19:50:23 UTC (rev 4863)
@@ -101,11 +101,27 @@
{
error => "parted_6",
message => "Parted was unable to read the partition table\n",
- stderr_regex => "No Implementation: Partition 1 isn't aligned to cylinder boundaries",
+ stderr_regex => "No Implementation: Partition \d+ isn't aligned to cylinder boundaries",
stdout_regex => "",
program => "parted",
response => "die",
},
+ {
+ error => "parted_7",
+ message => "Parted doesn't support ntfs resizing\n",
+ stderr_regex => "No Implementation: Support for opening ntfs file systems is not implemented yet",
+ stdout_regex => "",
+ program => "parted",
+ response => "die",
+ },
+ {
+ error => "parted_8",
+ message => "Parted failed to resize due to a setup-storage internal error\n",
+ stderr_regex => "Error: Can't have overlapping partitions",
+ stdout_regex => "",
+ program => "parted",
+ response => "die",
+ },
];
################################################################################
@@ -249,6 +265,7 @@
# execute the bash command, write stderr and stdout into the testfiles
`$command 1> $stdout_filename 2> $stderr_filename`;
+ ( ($?>>8) ne 0 ) and warn "Command had exit code " . ($?>>8) . "\n";
} else {
print "would run command $command; to have them executed, use -X \n";
}
Modified: people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm 2008-04-08 17:11:50 UTC (rev 4862)
+++ people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm 2008-04-08 19:50:23 UTC (rev 4863)
@@ -414,7 +414,7 @@
if ($end != $start) {
# the end of the current range (may be the end of the disk or some
- # preserved partition
+ # preserved partition or an ntfs volume to be resized)
my $end_of_range = -1;
# minimum space required by all partitions, i.e., the lower ends of the
@@ -430,7 +430,9 @@
foreach my $p (@{$worklist}) {
# we have found the delimiter
- if ($FAI::configs{$config}{partitions}{$p}{size}{preserve}) {
+ if ($FAI::configs{$config}{partitions}{$p}{size}{preserve} ||
+ ($FAI::configs{$config}{partitions}{$p}{size}{resize} &&
+ ($current_disk->{partitions}->{$p}->{filesystem} eq "ntfs"))) {
$end_of_range = $current_disk->{partitions}->{$p}->{begin_byte};
# logical partitions require the space for the EPBR to be left
@@ -500,7 +502,14 @@
$current_disk->{sector_size};
}
- # partition starts at where we currently are
+ # 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;
More information about the Fai-commit
mailing list