[Fai-commit] r5263 - in trunk: debian lib lib/setup-storage man
mt at alioth.debian.org
mt at alioth.debian.org
Mon Feb 16 13:01:27 UTC 2009
Author: mt
Date: 2009-02-16 13:01:27 +0000 (Mon, 16 Feb 2009)
New Revision: 5263
Modified:
trunk/debian/changelog
trunk/lib/disk-info
trunk/lib/setup-storage/Commands.pm
trunk/lib/setup-storage/Init.pm
trunk/lib/setup-storage/Parser.pm
trunk/lib/setup-storage/Sizes.pm
trunk/lib/setup-storage/Volumes.pm
trunk/man/setup-storage.8
Log:
Second series of setup-storage patch imports from experimental, merged:
- setup-storage_non-existing-device-fail-early
- setup-storage_proper-vg-existance-handling
- setup-storage_force-disklabel
- setup-storage_raid0-has-no-spares
- setup-storage_proper-partition-index
- aoe-support
- setup-storage_bugfix-virtual
- setup-storage_crypto-for-all-mountspecs
- setup-storage_partition-too-large-for-disk-error
- setup-storage_command-dep-debugging
- setup-storage_crypto-with-random-init-configurable
Merging into trunk completed, cleanup of experimental will follow
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/debian/changelog 2009-02-16 13:01:27 UTC (rev 5263)
@@ -25,8 +25,34 @@
fixed.
* setup-storage/Parser.pm, setup-storage.8: Added and documented support for
glob patterns in device names (e.g., /dev/disk/by-id/scsi-*)
+ * setup-storage/Sizes.pm: Fail early, if a non-existing device is used in a
+ volume group.
+ * setup-storage/Commands.pm: Properly handle existing volume groups and only
+ extend them if the underlying devices are preserved, otherwise create them
+ anew.
+ * setup-storage/Volumes.pm, setup-storage/Parser.pm: Always write a new
+ disklabel, if no partition on the disk must be preserved
+ * setup-storage/Parser.pm, setup-storage/Commands.pm: Make sure that the
+ user hasn't configured spares/missing devices with RAID-0 and only add
+ --spare-devices if at least 1 is configured. Thanks Camille Barette.
+ (closes: #508192)
+ * setup-storage/Commands.pm: Use the proper id for telling the user about
+ preserved/resized partitions.
+ * setup-storage/Init.pm, disk-info: Added AOE etherd/ device names to
+ regular expressions (thanks Jean Spirat)
+ * setup-storage/Commands.pm: If the disk config is marked virtual, create
+ dummy commands to tell later commands that the devices exist
+ (closes: #508247)
+ * setup-storage/Parser.pm: Support :encrypt with all mountpoint
+ specifications
+ * setup-storage/Sizes.pm: Properly tell the user that the lower bound of a
+ parition size is already too high
+ * setup-storage/Commands.pm: Added debug output in command dependency sorter
+ * setup-storage/Parser.pm, setup-storage/Commands.pm: Make random
+ initialization of encrypted partitions configurable
+ * setup-storage.8: Document new encryption possibilities
- -- Thomas Lange <lange at debian.org> Mon, 16 Feb 2009 13:39:38 +0100
+ -- Thomas Lange <lange at debian.org> Mon, 16 Feb 2009 13:59:13 +0100
fai (3.2.16) unstable; urgency=high
Modified: trunk/lib/disk-info
===================================================================
--- trunk/lib/disk-info 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/lib/disk-info 2009-02-16 13:01:27 UTC (rev 5263)
@@ -21,6 +21,6 @@
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# echo a space separated list of devices and their block size
-egrep ' i2o/hd.\b| cciss/c.d.\b| ida/c.d.\b| rd/c.d.\b| hd.\b| sd[a-z]{1,2}\b|/disc\b| vd.\b' /proc/partitions | diskandsize
+egrep ' etherd/e[[:digit:]]+\.[[:digit:]]+\b| i2o/hd.\b| cciss/c.d.\b| ida/c.d.\b| rd/c.d.\b| hd.\b| sd[a-z]{1,2}\b|/disc\b| vd.\b' /proc/partitions | diskandsize
Modified: trunk/lib/setup-storage/Commands.pm
===================================================================
--- trunk/lib/setup-storage/Commands.pm 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/lib/setup-storage/Commands.pm 2009-02-16 13:01:27 UTC (rev 5263)
@@ -125,12 +125,16 @@
"head -c 2048 /dev/urandom | head -n 47 | tail -n 46 | od | tee $keyfile",
"", "keyfile_$device" );
# prepare encryption
+ my $prepare_deps = "keyfile_$device";
+ if ($partition->{encrypt} > 1) {
+ &FAI::push_command(
+ "dd if=/dev/urandom of=$device",
+ "exist_$device", "random_init_$device" );
+ $prepare_deps = "random_init_$device,$prepare_deps";
+ }
&FAI::push_command(
- "dd if=/dev/urandom of=$device",
- "exist_$device", "random_init_$device" );
- &FAI::push_command(
"yes YES | cryptsetup luksFormat $device $keyfile -c aes-cbc-essiv:sha256 -s 256",
- "random_init_$device,keyfile_$device", "crypt_format_$device" );
+ $prepare_deps, "crypt_format_$device" );
&FAI::push_command(
"cryptsetup luksOpen $device $enc_dev_short_name --key-file $keyfile",
"crypt_format_$device", "encrypted_$enc_dev_name" );
@@ -226,7 +230,7 @@
$pre_req =~ s/^,//;
&FAI::push_command(
"yes | mdadm --create /dev/md$id --level=$level --force --run --raid-devices="
- . scalar(@eff_devs) . " --spare-devices=" . scalar(@spares) . " "
+ . scalar(@eff_devs) . (scalar(@spares) !=0 ? " --spare-devices=" . scalar(@spares) : "") . " "
. join(" ", @eff_devs) . " " . join(" ", @spares),
"$pre_req", "exist_/dev/md$id" );
@@ -274,8 +278,26 @@
($config =~ /^VG_(.+)$/) and ($1 ne "--ANY--") or &FAI::internal_error("Invalid config $config");
my $vg = $1; # the actual volume group
+ my $vg_exists = 0;
+ if (defined ($FAI::current_lvm_config{$vg})) {
+ $vg_exists = 1;
+ foreach my $dev (@{ $FAI::current_lvm_config{$vg}{"physical_volumes"} }) {
+ my ($i_p_d, $disk, $part_no) = &FAI::phys_dev($dev);
+ # if this is not a physical disk, just assume that the volume group will
+ # not exist anymore
+ if ($i_p_d) {
+ defined ($FAI::configs{"PHY_$disk"}) or next;
+ defined ($FAI::configs{"PHY_$disk"}{partitions}{$part_no}) and
+ ($FAI::configs{"PHY_$disk"}{partitions}{$part_no}{size}{preserve}) and
+ next;
+ }
+ $vg_exists = 0;
+ last;
+ }
+ }
+
# create the volume group, if it doesn't exist already
- if (!defined ($FAI::current_lvm_config{$vg})) {
+ if (!$vg_exists) {
# create all the devices
my @devices = keys %{ $FAI::configs{$config}{devices} };
&FAI::erase_lvm_signature(\@devices);
@@ -670,9 +692,9 @@
$pre_all_resize .= ",exist_" . &FAI::make_device_name($disk, $p) unless
$part->{size}->{resize};
if ($part->{size}->{resize}) {
- warn &FAI::make_device_name($disk, $p) . " will be resized\n";
+ warn &FAI::make_device_name($disk, $mapped_id) . " will be resized\n";
} else {
- warn &FAI::make_device_name($disk, $p) . " will be preserved\n";
+ warn &FAI::make_device_name($disk, $mapped_id) . " will be preserved\n";
next;
}
@@ -825,8 +847,18 @@
($config =~ /^PHY_(.+)$/) or &FAI::internal_error("Invalid config $config");
my $disk = $1; # the device to be configured
- # create partitions on non-virtual configs
- &FAI::setup_partitions($config) unless ($FAI::configs{$config}{virtual});
+ if ($FAI::configs{$config}{virtual}) {
+ foreach my $part_id (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
+ # reference to the current partition
+ my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
+ # virtual disks always exist
+ &FAI::push_command( "true", "",
+ "exist_" . &FAI::make_device_name($disk, $part_id) );
+ }
+ } else {
+ # create partitions on non-virtual configs
+ &FAI::setup_partitions($config);
+ }
# generate the commands for creating all filesystems
foreach my $part_id (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
@@ -901,6 +933,11 @@
my $pushed = -1;
while ($i < $FAI::n_c_i) {
+ if ($FAI::debug) {
+ print "Trying to add CMD: " . $FAI::commands{$i}{cmd} . "\n";
+ defined($FAI::commands{$i}{pre}) and print "PRE: " . $FAI::commands{$i}{pre} . "\n";
+ defined($FAI::commands{$i}{post}) and print "POST: " . $FAI::commands{$i}{post} . "\n";
+ }
my $all_matched = 1;
if (defined($FAI::commands{$i}{pre})) {
foreach (split(/,/, $FAI::commands{$i}{pre})) {
Modified: trunk/lib/setup-storage/Init.pm
===================================================================
--- trunk/lib/setup-storage/Init.pm 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/lib/setup-storage/Init.pm 2009-02-16 13:01:27 UTC (rev 5263)
@@ -168,7 +168,8 @@
defined($2) or return (1, "/dev/$1", -1);
return (1, "/dev/$1", $2);
}
- elsif ($dev =~ m{^/dev/(cciss/c\dd\d|ida/c\dd\d|rd/c\dd\d|ataraid/d\d)p(\d+)?$})
+ elsif ($dev =~
+ m{^/dev/(cciss/c\dd\d|ida/c\dd\d|rd/c\dd\d|ataraid/d\d|etherd/e\d+\.\d+)p(\d+)?$})
{
defined($2) or return (1, "/dev/$1", -1);
return (1, "/dev/$1", $2);
@@ -190,7 +191,7 @@
sub make_device_name {
my ($dev, $p) = @_;
$dev .= "p" if ($dev =~
- m{^/dev/(cciss/c\dd\d|ida/c\dd\d|rd/c\dd\d|ataraid/d\d)$});
+ m{^/dev/(cciss/c\dd\d|ida/c\dd\d|rd/c\dd\d|ataraid/d\d|etherd/e\d+\.\d+)$});
$dev .= $p;
internal_error("Invalid device $dev") unless (&FAI::phys_dev($dev))[0];
return $dev;
Modified: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk/lib/setup-storage/Parser.pm 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/lib/setup-storage/Parser.pm 2009-02-16 13:01:27 UTC (rev 5263)
@@ -117,6 +117,7 @@
disklabel => "msdos",
bootable => -1,
fstabkey => "device",
+ preserveparts => 0,
partitions => {}
};
}
@@ -414,18 +415,21 @@
{
# set the preserve flag for all ids in all cases
$FAI::configs{$FAI::device}{partitions}{$_}{size}{preserve} = 1 foreach (split (",", $1));
+ $FAI::configs{$FAI::device}{preserveparts} = 1;
}
| /^preserve_reinstall:(\d+(,\d+)*)/
{
# set the preserve flag for all ids if $FAI::reinstall is set
if ($FAI::reinstall) {
$FAI::configs{$FAI::device}{partitions}{$_}{size}{preserve} = 1 foreach (split(",", $1));
+ $FAI::configs{$FAI::device}{preserveparts} = 1;
}
}
| /^resize:(\d+(,\d+)*)/
{
# set the resize flag for all ids
$FAI::configs{$FAI::device}{partitions}{$_}{size}{resize} = 1 foreach (split(",", $1));
+ $FAI::configs{$FAI::device}{preserveparts} = 1;
}
| /^disklabel:(msdos|gpt)/
{
@@ -506,27 +510,16 @@
$FAI::partition_pointer = (\%FAI::configs)->{$FAI::device}->{volumes}->{$2};
}
- mountpoint: '-'
+ mountpoint: m{^(-|swap|/[^\s\:]*)(:encrypt(:randinit)?)?}
{
- # this partition should not be mounted
- $FAI::partition_pointer->{mountpoint} = "-";
- $FAI::partition_pointer->{encrypt} = 0;
- }
- | 'swap'
- {
- # this partition is swap space, not mounted
- $FAI::partition_pointer->{mountpoint} = "none";
- $FAI::partition_pointer->{encrypt} = 0;
- }
- | m{^/\S*}
- {
# set the mount point, may include encryption-request
- if ($item[ 1 ] =~ m{^(/[^:]*):encrypt$}) {
+ $FAI::partition_pointer->{mountpoint} = $1;
+ $FAI::partition_pointer->{mountpoint} = "none" if ($1 eq "swap");
+ if (defined($2)) {
&FAI::in_path("cryptsetup") or die "cryptsetup not found in PATH\n";
- $FAI::partition_pointer->{mountpoint} = $1;
$FAI::partition_pointer->{encrypt} = 1;
+ ++$FAI::partition_pointer->{encrypt} if (defined($3));
} else {
- $FAI::partition_pointer->{mountpoint} = $item[ 1 ];
$FAI::partition_pointer->{encrypt} = 0;
}
}
@@ -573,7 +566,10 @@
# enter the range into the hash
$FAI::partition_pointer->{size}->{range} = $range;
# set the resize flag, if required
- defined ($4) and $FAI::partition_pointer->{size}->{resize} = 1;
+ if (defined ($4)) {
+ $FAI::partition_pointer->{size}->{resize} = 1;
+ $FAI::configs{$FAI::device}{preserveparts} = 1;
+ }
}
| /^(-\d+[kMGTP%]?)(:resize)?\s+/
{
@@ -587,7 +583,10 @@
# enter the range into the hash
$FAI::partition_pointer->{size}->{range} = $range;
# set the resize flag, if required
- defined( $2 ) and $FAI::partition_pointer->{size}->{resize} = 1;
+ if (defined ($2)) {
+ $FAI::partition_pointer->{size}->{resize} = 1;
+ $FAI::configs{$FAI::device}{preserveparts} = 1;
+ }
}
| <error: invalid partition size near "$text">
@@ -622,6 +621,8 @@
($2 =~ /spare/) and $spare = 1;
($2 =~ /missing/) and $missing = 1;
}
+ (($spare == 1 || $missing == 1) && $FAI::partition_pointer->{mode} == 0)
+ and die "RAID-0 does not support spares or missing devices\n";
if ($missing) {
die "Failed to resolve $dev to a unique device name\n" if (scalar(@candidates) > 1);
$dev = $candidates[0] if (scalar(@candidates) == 1);
Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/lib/setup-storage/Sizes.pm 2009-02-16 13:01:27 UTC (rev 5263)
@@ -73,6 +73,8 @@
$end = $end * 1024.0 * 1024.0;
}
+ # the user may have specified a partition that is larger than the entire disk
+ ($start <= $size_b) or die "Lower bound of partition size is greater than disk size\n";
# make sure that $end >= $start
($end >= $start) or &FAI::internal_error("end < start");
@@ -115,7 +117,7 @@
# the size is known from the current configuration on disk, return it
defined ($FAI::current_config{$disk}{partitions}{$part_no}{count_byte})
and return $FAI::current_config{$disk}{partitions}{$part_no}{count_byte} /
- (1024 * 1024);
+ (1024 * 1024) unless defined ($FAI::configs{"PHY_$disk"}{partitions});
# the size is not known (yet?)
warn "Cannot determine size of $dev\n";
@@ -197,7 +199,10 @@
# $dev may be a partition, an entire disk or a RAID device; otherwise we
# cannot deal with it
- $vg_size += &FAI::estimate_size($dev);
+ my $cur_size = &FAI::estimate_size($dev);
+ ($cur_size > 0)
+ or die "Size of device $dev in volume group $vg cannot be determined\n";
+ $vg_size += $cur_size;
}
# now subtract 1% of overhead
Modified: trunk/lib/setup-storage/Volumes.pm
===================================================================
--- trunk/lib/setup-storage/Volumes.pm 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/lib/setup-storage/Volumes.pm 2009-02-16 13:01:27 UTC (rev 5263)
@@ -51,36 +51,36 @@
# make sure, $disk is a proper block device
(-b $disk) or die "$disk is not a block special device!\n";
- &FAI::push_command( "true", "", "exist_$disk" );
- # initialise the hash
- $FAI::current_config{$disk}{partitions} = {};
-
# the list to hold the output of parted commands as parsed below
my @parted_print = ();
# try to obtain the partition table for $disk
# it might fail with parted_2 in case the disk has no partition table
my $error =
- &FAI::execute_ro_command("parted -s $disk unit TiB print", \@parted_print, 0);
+ &FAI::execute_ro_command("parted -s $disk unit TiB print", \@parted_print, 0);
- # parted_2 happens when the disk has no disk label, because parted then
- # provides no information about the disk
- if ($error eq "parted_2" || $error eq "parted_2_new") {
+ # possible problems
+ if (!defined($FAI::configs{"PHY_$disk"}) && $error ne "") {
+ warn "Could not determine size and contents of $disk, skipping\n";
+ next;
+ } elsif (defined($FAI::configs{"PHY_$disk"}) &&
+ $FAI::configs{"PHY_$disk"}{preserveparts} == 1 && $error ne "") {
+ die "Failed to determine size and contents of $disk, but partitions should have been preserved\n";
+ }
+
+ # parted_2 happens when the disk has no disk label, parted_4 means unaligned
+ # partitions
+ if ($error eq "parted_2" || $error eq "parted_2_new" ||
+ $error eq "parted_4" || $error eq "parted_4_new") {
+
$FAI::no_dry_run or die
"Can't run on test-only mode on this system because there is no disklabel on $disk\n";
- # if there is no disk configuration, write an msdos disklabel
- if (!defined ($FAI::configs{"PHY_$disk"}{disklabel})) {
-
- # write the disk label as configured
- $error = &FAI::execute_command("parted -s $disk mklabel msdos");
- } else {
-
- # write the disk label as configured
- $error = &FAI::execute_command("parted -s $disk mklabel "
- . $FAI::configs{"PHY_$disk"}{disklabel});
- }
+ # write the disk label as configured
+ $error = &FAI::execute_command("parted -s $disk mklabel "
+ . $FAI::configs{"PHY_$disk"}{disklabel});
+ ($error eq "") or die "Failed to write disk label\n";
# retry partition-table print
$error =
&FAI::execute_ro_command("parted -s $disk unit TiB print", \@parted_print, 0);
@@ -88,6 +88,13 @@
($error eq "") or die "Failed to read the partition table from $disk\n";
+ # disk is usable
+ &FAI::push_command( "true", "", "exist_$disk" );
+
+ # initialise the hash
+ $FAI::current_config{$disk}{partitions} = {};
+
+
# the following code parses the output of parted print, using various units
# (TiB, B, chs)
# the parser is capable of reading the output of parted version 1.7.1, which
@@ -375,6 +382,7 @@
if (1 == $i_p_d && defined($FAI::configs{"PHY_$disk"}{partitions}{$part_no})) {
$FAI::configs{"PHY_$disk"}{partitions}{$part_no}{size}{preserve} = 1;
+ $FAI::configs{"PHY_$disk"}{preserveparts} = 1;
} elsif ($device_name =~ m{^/dev/md(\d+)$}) {
my $vol = $1;
if (defined($FAI::configs{RAID}{volumes}{$vol}) &&
@@ -415,7 +423,8 @@
# check for logical volumes that need to be preserved and preserve the
# underlying devices recursively
foreach my $l (keys %{ $FAI::configs{$config}{volumes} }) {
- next unless ($FAI::configs{$config}{volumes}{$l}{size}{preserve} == 1);
+ next unless ($FAI::configs{$config}{volumes}{$l}{size}{preserve} == 1 ||
+ $FAI::configs{$config}{volumes}{$l}{size}{resize} == 1);
&FAI::mark_preserve($_) foreach (keys %{ $FAI::configs{$config}{devices} });
last;
}
Modified: trunk/man/setup-storage.8
===================================================================
--- trunk/man/setup-storage.8 2009-02-16 12:50:02 UTC (rev 5262)
+++ trunk/man/setup-storage.8 2009-02-16 13:01:27 UTC (rev 5263)
@@ -264,20 +264,16 @@
.br
-mountpoint ::= -
+mountpoint ::= (-|swap|/[^\:[:space:]]*)(:encrypt(:randinit)?)?
.br
- /* do not mount */
+ /* do not mount, mount as swap, or mount at fully qualified path;
.br
- | swap
+ * if :encrypt is given the partition will be encrypted, the key
.br
- /* swap space */
+ * is generated automatically; :randinit adds random
.br
- | /[^[:space:]]*(:encrypt)?
+ * initialization of the partition */
.br
- /* fully qualified path; if :encrypt is given the partition
-.br
- * will be encrypted, the key is generated automatically */
-.br
name ::= [^/[:space:]]+
More information about the Fai-commit
mailing list