Add LVM initialization commands to autoinstallscript (only pvcreate for now).
This is a more modular implementation... :)
Bye,
-Andrea
--- etc/autoinstallscript.template~ 2005-01-22 19:39:23.000000000 +0100
+++ etc/autoinstallscript.template 2005-01-22 19:01:50.000000000 +0100
@@ -95,6 +95,18 @@
modprobe jfs
modprobe xfs
+### BEGIN LVM initialization commands -AR- ###
+##INITIALIZE_LVM_PARTITIONS##
+### END LVM initialization commands ###
+
+### BEGIN LVM groups creation commands -AR- ###
+##CREATE_LVM_GROUPS##
+### END LVM groups creation commands ###
+
+### BEGIN LVM volumes creation commands -AR- ###
+##CREATE_LVM_VOLUMES##
+### END LVM volumes creation commands ###
+
### BEGIN swap and filesystem creation commands ###
##CREATE_FILESYSTEMS##
### END swap and filesystem creation commands ###
--- lib/SystemImager/Server.pm~ 2005-01-22 19:52:18.000000000 +0100
+++ lib/SystemImager/Server.pm 2005-01-22 19:59:25.000000000 +0100
@@ -34,6 +34,7 @@
# _imageexists
# _in_script_add_standard_header_stuff
# _read_partition_info_and_prepare_parted_commands
+# _read_partition_info_and_prepare_pvcreate_commands -AR-
# _write_boel_devstyle_entry
# _write_elilo_conf
# _write_out_mkfs_commands
@@ -774,6 +775,76 @@
}
}
+# Usage:
+# _read_partition_info_and_prepare_pvcreate_commands( $out, $image_dir, $auto_install_script_conf );
+sub _read_partition_info_and_prepare_pvcreate_commands {
+ my ($out, $image_dir, $file) = @_;
+
+ my $xml_config = XMLin($file, keyattr => { disk => "+dev", part => "+num" }, forcearray => 1 );
+
+ my @all_devices = get_all_devices($file);
+ my %devfs_map = dev_to_devfs(@all_devices) or return undef;
+
+ foreach my $dev (sort (keys ( %{$xml_config->{disk}} ))) {
+
+ my (
+ $highest_part_num,
+ $m,
+ $cmd,
+ $part,
+ );
+
+ my $devfs_dev = $devfs_map{$dev};
+
+ ### BEGIN Populate the simple hashes. -BEF- ###
+ my (
+ %flags,
+ %p_type,
+ %p_name,
+ );
+
+ foreach my $m (sort (keys ( %{$xml_config->{disk}->{$dev}->{part}} ))) {
+ $flags{$m} = $xml_config->{disk}->{$dev}->{part}{$m}->{flags};
+ $p_name{$m} = $xml_config->{disk}->{$dev}->{part}{$m}->{p_name};
+ $p_type{$m} = $xml_config->{disk}->{$dev}->{part}{$m}->{p_type};
+ }
+
+ # Figure out what the highest partition number is. -BEF-
+ foreach (sort { $a <=> $b } (keys ( %{$xml_config->{disk}->{$dev}->{part}} ))) {
+ $highest_part_num = $_;
+ }
+
+ $m = "0";
+ until ($m >= $highest_part_num) {
+
+ $m++;
+ unless (defined($p_type{$m})) { next; }
+
+ $part = &get_part_name($dev, $m);
+
+ # Extended partitions can't be used by LVM. -AR-
+ if ("$p_type{$m}" eq "extended") { next; }
+
+ ### Deal with LVM flag for each partition. -AR-
+ if (($flags{$m}) and ($flags{$m} ne "-")) {
+ my @flags = split (/,/, $flags{$m});
+ foreach my $flag (@flags) {
+ if ("$flag" eq "lvm") {
+
+ $cmd = "Initializing partition $part for use by LVM.";
+ print $out qq(echo "$cmd"\n);
+
+ $cmd = "pvcreate $part || shellout";
+ print $out qq(echo "$cmd"\n);
+ print $out "$cmd\n";
+ last;
+ }
+ }
+ }
+ }
+ }
+}
+
# Usage:
# upgrade_partition_schemes_to_generic_style($image_dir, $config_dir);
sub upgrade_partition_schemes_to_generic_style {
@@ -1448,7 +1519,22 @@
last SWITCH;
}
- if (/^\s*${delim}CREATE_FILESYSTEMS${delim}\s*$/) {
+ if (/^\s*${delim}INITIALIZE_LVM_PARTITIONS${delim}\s*$/) {
+ _read_partition_info_and_prepare_pvcreate_commands( $MASTER_SCRIPT,
+ $image_dir,
+ $auto_install_script_conf);
+ last SWITCH;
+ }
+
+# if (/^\s*${delim}CREATE_LVM_GROUPS${delim}\s*$/) {
+# last SWITCH;
+# }
+
+# if (/^\s*${delim}CREATE_LVM_VOLUMES${delim}\s*$/) {
+# last SWITCH;
+# }
+
+ if (/^\s*${delim}CREATE_FILESYSTEMS${delim}\s*$/) {
_write_out_mkfs_commands( $MASTER_SCRIPT,
$image_dir,
$auto_install_script_conf,