[Fai-commit] r6247 - in branches/stable/3.4: lib/setup-storage man
Michael Prokop
mika at alioth.debian.org
Thu Dec 23 12:45:35 UTC 2010
Author: mika
Date: 2010-12-23 12:45:33 +0000 (Thu, 23 Dec 2010)
New Revision: 6247
Modified:
branches/stable/3.4/lib/setup-storage/Fstab.pm
branches/stable/3.4/lib/setup-storage/Parser.pm
branches/stable/3.4/man/setup-storage.8
Log:
setup-storage/{Fstab.pm,Parser.pm}: Cleanup code for defining BOOT_DEVICE
setup-storage.8: Properly document semantics of BOOT_DEVICE and disk_var.sh.
Thanks: Julien Blache <jblache at debian.org>
Modified: branches/stable/3.4/lib/setup-storage/Fstab.pm
===================================================================
--- branches/stable/3.4/lib/setup-storage/Fstab.pm 2010-12-23 12:45:25 UTC (rev 6246)
+++ branches/stable/3.4/lib/setup-storage/Fstab.pm 2010-12-23 12:45:33 UTC (rev 6247)
@@ -128,7 +128,58 @@
}
}
+################################################################################
+#
+# @brief Find the mount point for /boot
+#
+# @return mount point for /boot
+#
+################################################################################
+sub find_boot_mnt_point {
+ my $mnt_point;
+ # walk through all configured parts
+ foreach my $c (keys %FAI::configs) {
+
+ if ($c =~ /^PHY_(.+)$/) {
+ foreach my $p (keys %{ $FAI::configs{$c}{partitions} }) {
+ my $this_mp = $FAI::configs{$c}{partitions}{$p}{mountpoint};
+
+ next if (!defined($this_mp));
+
+ return $this_mp if ($this_mp eq "/boot");
+ $mnt_point = $this_mp if ($this_mp eq "/");
+ }
+ } elsif ($c =~ /^VG_(.+)$/) {
+ next if ($1 eq "--ANY--");
+ foreach my $l (keys %{ $FAI::configs{$c}{volumes} }) {
+ my $this_mp = $FAI::configs{$c}{volumes}{$l}{mountpoint};
+
+ next if (!defined($this_mp));
+
+ return $this_mp if ($this_mp eq "/boot");
+ $mnt_point = $this_mp if ($this_mp eq "/");
+ }
+ } elsif ($c eq "RAID" || $c eq "CRYPT") {
+ foreach my $r (keys %{ $FAI::configs{$c}{volumes} }) {
+ my $this_mp = $FAI::configs{$c}{volumes}{$r}{mountpoint};
+
+ next if (!defined($this_mp));
+
+ return $this_mp if ($this_mp eq "/boot");
+ $mnt_point = $this_mp if ($this_mp eq "/");
+ }
+ } elsif ($c eq "TMPFS") {
+ # not usable for /boot
+ next;
+ } else {
+ &FAI::internal_error("Unexpected key $c");
+ }
+ }
+
+ return $mnt_point;
+}
+
################################################################################
#
# @brief this function generates the fstab file from our representation of the
@@ -148,6 +199,9 @@
# the file to be returned, a list of lines
my @fstab = ();
+ # mount point for /boot
+ my $boot_mnt_point = &FAI::find_boot_mnt_point();
+
# walk through all configured parts
# the order of entries is most likely wrong, it is fixed at the end
foreach my $c (keys %$config) {
@@ -171,15 +225,11 @@
my $device_name = &FAI::make_device_name($device, $p_ref->{number});
- # if the mount point is / or /boot, the variables should be set, unless
- # they are already
- if ($p_ref->{mountpoint} eq "/boot" || ($p_ref->{mountpoint} eq "/" &&
- !defined ($FAI::disk_var{BOOT_PARTITION}))) {
- # set the BOOT_DEVICE and BOOT_PARTITION variables, if necessary
+ # if the mount point the /boot mount point, variables must be set
+ if ($p_ref->{mountpoint} eq $boot_mnt_point) {
+ # set the BOOT_DEVICE and BOOT_PARTITION variables
$FAI::disk_var{BOOT_PARTITION} = $device_name;
- ($c =~ /^PHY_(.+)$/) or &FAI::internal_error("unexpected mismatch");
- defined ($FAI::disk_var{BOOT_DEVICE}) and ($FAI::disk_var{BOOT_DEVICE} ne "") or
- $FAI::disk_var{BOOT_DEVICE} = $1;
+ $FAI::disk_var{BOOT_DEVICE} = $device;
}
push @fstab, &FAI::create_fstab_line($p_ref,
@@ -202,16 +252,9 @@
my $device_name = "/dev/$device/$l";
- # according to http://grub.enbug.org/LVMandRAID, this should work...
- # if the mount point is / or /boot, the variables should be set, unless
- # they are already
- if ($l_ref->{mountpoint} eq "/boot" || ($l_ref->{mountpoint} eq "/" &&
- !defined ($FAI::disk_var{BOOT_PARTITION}))) {
- # set the BOOT_DEVICE and BOOT_PARTITION variables, if necessary
- $FAI::disk_var{BOOT_PARTITION} = $device_name;
- defined ($FAI::disk_var{BOOT_DEVICE}) and ($FAI::disk_var{BOOT_DEVICE} ne "") or
- $FAI::disk_var{BOOT_DEVICE} = $device_name;
- }
+ # if the mount point the /boot mount point, variables must be set
+ $FAI::disk_var{BOOT_DEVICE} = $device_name
+ if ($l_ref->{mountpoint} eq $boot_mnt_point);
push @fstab, &FAI::create_fstab_line($l_ref,
&FAI::get_fstab_key($device_name, $config->{"VG_--ANY--"}->{fstabkey}), $device_name);
@@ -229,16 +272,9 @@
my $device_name = "/dev/md$r";
- # according to http://grub.enbug.org/LVMandRAID, this should work...
- # if the mount point is / or /boot, the variables should be set, unless
- # they are already
- if ($r_ref->{mountpoint} eq "/boot" || ($r_ref->{mountpoint} eq "/" &&
- !defined ($FAI::disk_var{BOOT_PARTITION}))) {
- # set the BOOT_DEVICE and BOOT_PARTITION variables, if necessary
- $FAI::disk_var{BOOT_PARTITION} = "$device_name";
- defined ($FAI::disk_var{BOOT_DEVICE}) and ($FAI::disk_var{BOOT_DEVICE} ne "") or
- $FAI::disk_var{BOOT_DEVICE} = "$device_name";
- }
+ # if the mount point the /boot mount point, variables must be set
+ $FAI::disk_var{BOOT_DEVICE} = $device_name
+ if ($r_ref->{mountpoint} eq $boot_mnt_point);
push @fstab, &FAI::create_fstab_line($r_ref,
&FAI::get_fstab_key($device_name, $config->{RAID}->{fstabkey}), $device_name);
@@ -251,8 +287,7 @@
my $device_name = &FAI::enc_name($c_ref->{device});
- ($c_ref->{mountpoint} eq "/boot" || ($c_ref->{mountpoint} eq "/" &&
- !defined ($FAI::disk_var{BOOT_PARTITION}))) and
+ ($c_ref->{mountpoint} eq $boot_mnt_point) and
die "Boot partition cannot be encrypted\n";
push @fstab, &FAI::create_fstab_line($c_ref, $device_name, $device_name);
@@ -263,8 +298,7 @@
next if ($c_ref->{mountpoint} eq "-");
- ($c_ref->{mountpoint} eq "/boot" || ($c_ref->{mountpoint} eq "/" &&
- !defined ($FAI::disk_var{BOOT_PARTITION}))) and
+ ($c_ref->{mountpoint} eq $boot_mnt_point) and
die "Boot partition cannot be a tmpfs\n";
if (($c_ref->{mount_options} =~ m/size=/) || ($c_ref->{mount_options} =~ m/nr_blocks=/)) {
Modified: branches/stable/3.4/lib/setup-storage/Parser.pm
===================================================================
--- branches/stable/3.4/lib/setup-storage/Parser.pm 2010-12-23 12:45:25 UTC (rev 6246)
+++ branches/stable/3.4/lib/setup-storage/Parser.pm 2010-12-23 12:45:33 UTC (rev 6247)
@@ -546,7 +546,6 @@
$FAI::configs{$FAI::device}{bootable} = $1;
($FAI::device =~ /^PHY_(.+)$/) or
&FAI::internal_error("unexpected device name");
- $FAI::disk_var{BOOT_DEVICE} .= " $1";
}
| 'virtual'
{
Modified: branches/stable/3.4/man/setup-storage.8
===================================================================
--- branches/stable/3.4/man/setup-storage.8 2010-12-23 12:45:25 UTC (rev 6246)
+++ branches/stable/3.4/man/setup-storage.8 2010-12-23 12:45:33 UTC (rev 6247)
@@ -103,18 +103,19 @@
.SH FILES
If
\fBsetup-storage\fP
-executes successfully an
+executes successfully, an
\fBfstab\fP(5)
file matching the specified configuration is generated as
-$LOGDIR/fstab. Further $LOGDIR/disk_var.sh
-is generated and may be sourced to get the variables
+$LOGDIR/fstab. Furthermore the file $LOGDIR/disk_var.sh
+is generated. This file defines the following variables, if not yet set:
.IR SWAPLIST ,
.IR ROOT_PARTITION ,
.IR BOOT_PARTITION
-and
+(which is only set in case this resides on a disk drive), and
.IR BOOT_DEVICE .
-The latter two will only be set in case they
-reside on a disk drive.
+The latter two describe the partition and disk/RAID/LVM device hosting the mount
+point for /boot. If /boot has no extra mount point, / is used instead.
+You may source $LOGDIR/disk_var.sh to get the variables set.
.SH SYNTAX
This section describes the syntax of disk_config files
More information about the Fai-commit
mailing list