[Fai-commit] r6169 - in trunk: lib/setup-storage man
Michael Tautschnig
mt at alioth.debian.org
Fri Oct 29 09:16:17 UTC 2010
Author: mt
Date: 2010-10-29 09:16:11 +0000 (Fri, 29 Oct 2010)
New Revision: 6169
Modified:
trunk/lib/setup-storage/Commands.pm
trunk/lib/setup-storage/Fstab.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:
setup-storage: Added support for using raw disk devices, without partitioning
Thanks: Jordi Funollet <jordi.f at ati.es>
Closes: #589649
Modified: trunk/lib/setup-storage/Commands.pm
===================================================================
--- trunk/lib/setup-storage/Commands.pm 2010-10-28 16:17:41 UTC (rev 6168)
+++ trunk/lib/setup-storage/Commands.pm 2010-10-29 09:16:11 UTC (rev 6169)
@@ -1088,14 +1088,15 @@
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) );
# no partition table operations
$FAI::partition_table_deps{$disk} = "";
}
+ } elsif (defined($FAI::configs{$config}{partitions}{0})) {
+ # no partition table operations
+ $FAI::partition_table_deps{$disk} = "";
} else {
# create partitions on non-virtual configs
&FAI::setup_partitions($config);
@@ -1112,7 +1113,7 @@
|| $part->{size}->{extended} == 1);
# create the filesystem on the device
- &FAI::build_mkfs_commands( &FAI::make_device_name($disk, $part_id), $part );
+ &FAI::build_mkfs_commands( 0 == $part_id ? $disk : &FAI::make_device_name($disk, $part_id), $part );
}
}
}
Modified: trunk/lib/setup-storage/Fstab.pm
===================================================================
--- trunk/lib/setup-storage/Fstab.pm 2010-10-28 16:17:41 UTC (rev 6168)
+++ trunk/lib/setup-storage/Fstab.pm 2010-10-29 09:16:11 UTC (rev 6169)
@@ -170,7 +170,8 @@
# skip extended partitions and entries without a mountpoint
next if ($p_ref->{size}->{extended} || $p_ref->{mountpoint} eq "-");
- my $device_name = &FAI::make_device_name($device, $p_ref->{number});
+ my $device_name = 0 == $p_ref->{number} ? $device :
+ &FAI::make_device_name($device, $p_ref->{number});
# if the mount point is / or /boot, the variables should be set, unless
# they are already
Modified: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk/lib/setup-storage/Parser.pm 2010-10-28 16:17:41 UTC (rev 6168)
+++ trunk/lib/setup-storage/Parser.pm 2010-10-29 09:16:11 UTC (rev 6169)
@@ -145,7 +145,8 @@
#
# @brief Initialise the entry of a partition in @ref $FAI::configs
#
-# @param $type The type of the partition. It must be either primary or logical.
+# @param $type The type of the partition. It must be either primary or logical
+# or raw.
#
################################################################################
sub init_part_config {
@@ -153,9 +154,9 @@
# the type of the partition to be created
my ($type) = @_;
- # type must either be primary or logical, nothing else may be accepted by the
- # parser
- ($type eq "primary" || $type eq "logical") or
+ # type must either be primary or logical or raw, nothing else may be accepted
+ # by the parser
+ ($type eq "primary" || $type eq "logical" || $type eq "raw") or
&FAI::internal_error("invalid type $type");
# check that a physical device is being configured; logical partitions are
@@ -169,6 +170,8 @@
# create a primary partition
if ($type eq "primary") {
+ (defined($FAI::configs{$FAI::device}{partitions}{0})) and
+ die "You cannot use raw-disk together with primary/logical partitions\n";
# find all previously defined primary partitions
foreach my $part_id (&numsort(keys %{ $FAI::configs{$FAI::device}{partitions} })) {
@@ -191,7 +194,14 @@
($part_number < 5 || $FAI::configs{$FAI::device}{virtual} ||
$FAI::configs{$FAI::device}{disklabel} ne "msdos")
or die "$part_number are too many primary partitions\n";
+ } elsif ($type eq "raw") {
+ (0 == scalar(keys %{ $FAI::configs{$FAI::device}{partitions} })) or
+ die "You cannot use raw-disk together with primary/logical partitions\n";
+ # special-case hack: part number 0 is invalid otherwise
+ $part_number = 0;
} else {
+ (defined($FAI::configs{$FAI::device}{partitions}{0})) and
+ die "You cannot use raw-disk together with primary/logical partitions\n";
# no further checks for the disk label being msdos have to be performed in
# this branch, it has been ensured above
@@ -664,6 +674,12 @@
# initialise a logical partition
&FAI::init_part_config($item[ 1 ]);
}
+ | 'raw-disk'
+ {
+ # initialise a pseudo-partition: this disk will be used without
+ # partitioning it
+ &FAI::init_part_config("raw");
+ }
| m{^([^/,\s\-]+)-([^/,\s\-]+)\s+}
{
# set $FAI::device to VG_$1
Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm 2010-10-28 16:17:41 UTC (rev 6168)
+++ trunk/lib/setup-storage/Sizes.pm 2010-10-29 09:16:11 UTC (rev 6169)
@@ -615,8 +615,10 @@
# for RAID, encrypted, tmpfs or LVM, there is nothing to be done here
next if ($config eq "RAID" || $config eq "CRYPT" || $config eq "TMPFS" || $config =~ /^VG_./);
($config =~ /^PHY_(.+)$/) or &FAI::internal_error("invalid config entry $config");
- # nothing to be done, if this is a configuration for a virtual disk
- next if $FAI::configs{$config}{virtual};
+ # nothing to be done, if this is a configuration for a virtual disk or a
+ # disk without partitions
+ next if ($FAI::configs{$config}{virtual} ||
+ defined($FAI::configs{$config}{partitions}{0}));
my $disk = $1; # the device name of the disk
# test, whether $disk is a block special device
(-b $disk) or die "$disk is not a valid device name\n";
Modified: trunk/lib/setup-storage/Volumes.pm
===================================================================
--- trunk/lib/setup-storage/Volumes.pm 2010-10-28 16:17:41 UTC (rev 6168)
+++ trunk/lib/setup-storage/Volumes.pm 2010-10-29 09:16:11 UTC (rev 6169)
@@ -530,12 +530,17 @@
next unless ($part->{size}->{preserve} || $part->{size}->{resize});
($part->{size}->{extended}) and die
"Preserving extended partitions is not supported; mark all logical partitions instead\n";
- defined ($FAI::current_config{$1}{partitions}{$part_id}) or die
- "Can't preserve ". &FAI::make_device_name($1, $part->{number})
- . " because it does not exist\n";
- defined ($part->{size}->{range}) or die
- "Can't preserve ". &FAI::make_device_name($1, $part->{number})
- . " because it is not defined in the current config\n";
+ if (0 == $part_id) {
+ defined ($FAI::current_config{$1}) or die
+ "Can't preserve $1 because it does not exist\n";
+ } else {
+ defined ($FAI::current_config{$1}{partitions}{$part_id}) or die
+ "Can't preserve ". &FAI::make_device_name($1, $part->{number})
+ . " because it does not exist\n";
+ defined ($part->{size}->{range}) or die
+ "Can't preserve ". &FAI::make_device_name($1, $part->{number})
+ . " because it is not defined in the current config\n";
+ }
}
} elsif ($config =~ /^VG_(.+)$/) {
next if ($1 eq "--ANY--");
Modified: trunk/man/setup-storage.8
===================================================================
--- trunk/man/setup-storage.8 2010-10-28 16:17:41 UTC (rev 6168)
+++ trunk/man/setup-storage.8 2010-10-29 09:16:11 UTC (rev 6169)
@@ -305,6 +305,10 @@
.br
/* for physical disks only */
.br
+ | raw-disk
+.br
+ /* for physical disks only: do not partition this disk, use it as-is */
+.br
| raid[0156]
.br
/* raid level */
More information about the Fai-commit
mailing list