[Fai-commit] r5443 - in trunk: bin debian lib/setup-storage
Michael Tautschnig
mt at alioth.debian.org
Sun Jul 19 15:23:00 UTC 2009
Author: mt
Date: 2009-07-19 15:22:59 +0000 (Sun, 19 Jul 2009)
New Revision: 5443
Modified:
trunk/bin/setup-storage
trunk/debian/changelog
trunk/lib/setup-storage/Fstab.pm
trunk/lib/setup-storage/Init.pm
trunk/lib/setup-storage/Sizes.pm
trunk/lib/setup-storage/Volumes.pm
Log:
merged setup-storage_ignore-gpt-warning and setup-storage_better-error-msgs
Modified: trunk/bin/setup-storage
===================================================================
--- trunk/bin/setup-storage 2009-07-19 15:06:31 UTC (rev 5442)
+++ trunk/bin/setup-storage 2009-07-19 15:22:59 UTC (rev 5443)
@@ -56,8 +56,10 @@
# command line parameter handling
use Getopt::Std;
+$main::VERSION = $version;
+$Getopt::Std::STANDARD_HELP_VERSION = 1;
our ($opt_X, $opt_f, $opt_h, $opt_d); # the variables for getopt
-&getopts('Xf:hd') || die <<EOF;
+(&getopts('Xf:hd') && !$opt_h) || die <<EOF;
setup-storage version $version
USAGE: [-X] no test, your harddisks will be formated
@@ -67,17 +69,19 @@
[-h] print this help message
EOF
-# $disklist must be provided by the environment
-defined ($ENV{disklist}) or die "Environment variable disklist is not set\n";
-
################################################################################
#
# @brief Really write any changes to disk
#
################################################################################
-$FAI::no_dry_run = 0;
-$opt_X and $FAI::no_dry_run = 1;
-$opt_X or warn "setup-harddisks is running in test-only mode\n";
+if ($opt_X) {
+ # we use $ENV{LOGDIR} later on, make sure it is actually set
+ defined ($ENV{LOGDIR}) or die "Environment variable LOGDIR is not set\n";
+ $FAI::no_dry_run = 1;
+} else {
+ warn "setup-harddisks is running in test-only mode\n";
+ $FAI::no_dry_run = 0;
+}
# include all subparts, which are part of the FAI perl package
use lib "/usr/share/fai/setup-storage/";
@@ -92,11 +96,18 @@
# enable debug mode, if requested using -d
$opt_d and $FAI::debug = 1;
+# $disklist must be provided by the environment
+defined ($ENV{disklist}) or die "Environment variable disklist is not set\n";
+ at FAI::disks = split( /\n/, $ENV{disklist} );
+print "disklist was: $ENV{disklist}\n" if ($FAI::debug);
+
# the config source file
my $config_file = undef;
# use the config file, if given
open($config_file, $opt_f) or die "Failed to open config file $opt_f\n" if ($opt_f);
unless ($opt_f) {
+ defined ($ENV{classes}) or
+ die "Environment variable classes is not set and -f was not given\n";
# see which class file to use
foreach my $classfile (reverse split(/\s+/, $ENV{classes})) {
next unless (-r "$ENV{FAI}/disk_config/$classfile");
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2009-07-19 15:06:31 UTC (rev 5442)
+++ trunk/debian/changelog 2009-07-19 15:22:59 UTC (rev 5443)
@@ -28,6 +28,14 @@
matrix.systems at matrix.msu.edu for a first patch). (closes: #530656)
* setup-storage/Volumes.pm: Updated mdadm --scan output parser to work with
current mdadm versions.
+ * setup-storage/Volumes.pm: Ignore another line of output from parted
+ (GPT-related warning). Thanks Andreas Schuldei for noticing this.
+ * setup-storage, setup-storage/Sizes.pm: Properly handle -h, early check for
+ unset (but necessary) environment variables, print full device names in
+ several error/warning messages instead of the partition id only.
+ * setup-storage/Fstab.pm: Be more verbose if obtaining the UUID fails (may
+ be caused by earlier use in RAID array, tell the user how to solve the
+ problem). Ignore exit code 3 of vol_id -l.
-- Thomas Lange <lange at debian.org> Sun, 19 Jul 2009 12:08:02 +0200
Modified: trunk/lib/setup-storage/Fstab.pm
===================================================================
--- trunk/lib/setup-storage/Fstab.pm 2009-07-19 15:06:31 UTC (rev 5442)
+++ trunk/lib/setup-storage/Fstab.pm 2009-07-19 15:22:59 UTC (rev 5443)
@@ -99,12 +99,16 @@
# every device must have a uuid, otherwise this is an error (unless we
# are testing only)
($FAI::no_dry_run == 0 || scalar (@uuid) == 1)
- or die "Failed to obtain UUID for $device_name\n";
+ or die "Failed to obtain UUID for $device_name.\n
+ This may happen if the device was part of a RAID array in the past;\n
+ in this case run mdadm --zero-superblock $device_name and retry\n";
- # get the label -- this is likely empty
+ # get the label -- this is likely empty; exit code 3 if no label, but that is
+ # ok here
my @label = ();
&FAI::execute_ro_command(
- "/lib/udev/vol_id -l $device_name", \@label, 0);
+ "( /lib/udev/vol_id -l $device_name ; exc=\$? ; if [ \$exc -eq 3 ] ;" .
+ " then exit 0 ; else exit \$exc ; fi )", \@label, 0);
# using the fstabkey value the desired device entry is defined
if ($key_type eq "uuid") {
Modified: trunk/lib/setup-storage/Init.pm
===================================================================
--- trunk/lib/setup-storage/Init.pm 2009-07-19 15:06:31 UTC (rev 5442)
+++ trunk/lib/setup-storage/Init.pm 2009-07-19 15:22:59 UTC (rev 5443)
@@ -58,8 +58,7 @@
# @brief The lists of disks of the system
#
################################################################################
- at FAI::disks = split( /\n/, $ENV{disklist} );
-( $FAI::debug > 0 ) and print "disklist was: $ENV{disklist}\n";
+ at FAI::disks = ();
################################################################################
#
Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm 2009-07-19 15:06:31 UTC (rev 5442)
+++ trunk/lib/setup-storage/Sizes.pm 2009-07-19 15:22:59 UTC (rev 5443)
@@ -285,26 +285,30 @@
################################################################################
sub do_partition_preserve {
- my ($part_id, $config, $current_disk, $next_start, $min_req_total_space) = @_;
+ my ($part_id, $config, $disk, $next_start, $min_req_total_space) = @_;
+ # reference to the current disk config
+ my $current_disk = $FAI::current_config{$disk};
# reference to the current partition
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
+ # full device name
+ my $part_dev_name = &FAI::make_device_name($disk, $part_id);
# a partition that should be preserved must exist already
defined($current_disk->{partitions}->{$part_id})
- or die "$part_id can't be preserved, it does not exist.\n";
+ or die "$part_dev_name can't be preserved, it does not exist.\n";
my $curr_part = $current_disk->{partitions}->{$part_id};
($next_start > $curr_part->{begin_byte})
- and die "Previous partitions overflow begin of preserved partition $part_id\n";
+ and die "Previous partitions overflow begin of preserved partition $part_dev_name\n";
# get what the user desired
my ($start, $end) = &FAI::make_range($part->{size}->{range},
$current_disk->{size} . "B");
($start > $curr_part->{count_byte} || $end < $curr_part->{count_byte})
- and warn "Preserved partition $part_id retains size " .
- $curr_part->{count_byte} . "\n";
+ and warn "Preserved partition $part_dev_name retains size " .
+ $curr_part->{count_byte} . "B\n";
# set the effective size to the value known already
$part->{size}->{eff_size} = $curr_part->{count_byte};
@@ -330,7 +334,7 @@
% ($current_disk->{sector_size} *
$current_disk->{bios_sectors_per_track} *
$current_disk->{bios_heads})) or
- warn "Preserved partition $part_id does not end at a cylinder boundary, parted may fail to restore the partition!\n";
+ 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} *
@@ -339,7 +343,7 @@
# make sure we don't change extended partitions to ordinary ones and
# vice-versa
($part->{size}->{extended} == $curr_part->{is_extended})
- or die "Preserved partition $part_id can't change extended/normal setting\n";
+ or die "Preserved partition $part_dev_name can't change extended/normal setting\n";
# extended partitions consume no space
if ($part->{size}->{extended}) {
@@ -357,7 +361,7 @@
$FAI::configs{$config}{disklabel} eq "gpt-bios") {
(0 == ($current_disk->{partitions}{$part_id}{end_byte} + 1)
% $current_disk->{sector_size})
- or die "Preserved partition $part_id does not end at a sector boundary\n";
+ or die "Preserved partition $part_dev_name does not end at a sector boundary\n";
}
return ($next_start, $min_req_total_space);
@@ -425,8 +429,9 @@
################################################################################
sub do_partition_real {
- my ($part_id, $config, $current_disk, $next_start, $min_req_total_space,
- $worklist) = @_;
+ my ($part_id, $config, $disk, $next_start, $min_req_total_space, $worklist) = @_;
+ # reference to the current disk config
+ my $current_disk = $FAI::current_config{$disk};
# reference to the current partition
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
@@ -496,7 +501,8 @@
# the next boundary is closer than the minimal space that we need
($available_space < $min_req_space)
- and die "Insufficient space available for partition $part_id\n";
+ and die "Insufficient space available for partition " .
+ &FAI::make_device_name($disk, $part_id) . "\n";
# the new size
my $scaled_size = $end;
@@ -686,7 +692,7 @@
# the partition $part_id must be preserved
if ($part->{size}->{preserve}) {
($next_start, $min_req_total_space) = &FAI::do_partition_preserve($part_id,
- $config, $current_disk, $next_start, $min_req_total_space);
+ $config, $disk, $next_start, $min_req_total_space);
# partition done
shift @worklist;
@@ -716,7 +722,7 @@
shift @worklist;
} else {
($next_start, $min_req_total_space) = &FAI::do_partition_real($part_id,
- $config, $current_disk, $next_start, $min_req_total_space, \@worklist);
+ $config, $disk, $next_start, $min_req_total_space, \@worklist);
# msdos does not support partitions larger than 2TB
($part->{size}->{eff_size} > (&FAI::convert_unit("2TB") * 1024.0 *
Modified: trunk/lib/setup-storage/Volumes.pm
===================================================================
--- trunk/lib/setup-storage/Volumes.pm 2009-07-19 15:06:31 UTC (rev 5442)
+++ trunk/lib/setup-storage/Volumes.pm 2009-07-19 15:22:59 UTC (rev 5443)
@@ -146,7 +146,8 @@
# now we test line by line - some of them may be ignored
next if ($line =~ /^Disk / || $line =~ /^Model: / || $line =~ /^\s*$/
- || $line =~ /^WARNING: You are not superuser/);
+ || $line =~ /^WARNING: You are not superuser/
+ || $line =~ /^Warning: Not all of the space available to/);
# determine the logical sector size
if ($line =~ /^Sector size \(logical\/physical\): (\d+)B\/\d+B$/) {
More information about the Fai-commit
mailing list