[Fai-commit] r4927 - in people/michael/features/setup_harddisks_2: . implementation implementation/lib

mt at alioth.debian.org mt at alioth.debian.org
Mon Jun 2 15:16:55 UTC 2008


Author: mt
Date: 2008-06-02 15:16:54 +0000 (Mon, 02 Jun 2008)
New Revision: 4927

Modified:
   people/michael/features/setup_harddisks_2/implementation/lib/commands.pm
   people/michael/features/setup_harddisks_2/implementation/lib/fstab.pm
   people/michael/features/setup_harddisks_2/implementation/lib/init.pm
   people/michael/features/setup_harddisks_2/implementation/lib/parser.pm
   people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm
   people/michael/features/setup_harddisks_2/implementation/lib/volumes.pm
   people/michael/features/setup_harddisks_2/implementation/setup-storage
   people/michael/features/setup_harddisks_2/setup-storage.8
Log:
- preserve_*, fstabkey support for all kinds of volumes
- updated man page according to now extended syntax
- coding improvements as suggested by Thomas


Modified: people/michael/features/setup_harddisks_2/implementation/lib/commands.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/commands.pm	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/implementation/lib/commands.pm	2008-06-02 15:16:54 UTC (rev 4927)
@@ -69,12 +69,8 @@
   ($fs eq "xfs") and $create_options = "$create_options -f" unless ($create_options =~ m/-f/);
   my $pre_encrypt = "exist_$device";
   $pre_encrypt = "encrypt_$device" if ($partition->{encrypt});
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "$create_tool $create_options $device",
-    pre => $pre_encrypt,
-    post => "has_fs_$device"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( "$create_tool $create_options $device", $pre_encrypt,
+    "has_fs_$device" );
   
   # possibly tune the file system - this depends on whether the file system
   # supports tuning at all
@@ -85,12 +81,8 @@
   die "Don't know how to tune $fs\n" unless $tune_tool;
 
   # add the tune command
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "$tune_tool $tune_options $device",
-    pre => "has_fs_$device",
-    post => "has_fs_$device"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( "$tune_tool $tune_options $device", "has_fs_$device",
+    "has_fs_$device" );
 }
 
 ################################################################################
@@ -117,26 +109,17 @@
   my $keyfile = "$ENV{LOGDIR}/$enc_dev_short_name";
 
   # generate a key for encryption
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "head -c 2048 /dev/urandom | head -n 47 | tail -n 46 | od | tee $keyfile",
-    pre => "",
-    post => "keyfile_$device"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( 
+    "head -c 2048 /dev/urandom | head -n 47 | tail -n 46 | od | tee $keyfile",
+    "", "keyfile_$device" );
 
   # prepare encryption
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "yes YES | cryptsetup luksFormat $device $keyfile -c aes-cbc-essiv:sha256 -s 256",
-    pre => "exist_$device,keyfile_$device",
-    post => "crypt_format_$device"
-  };
-  $FAI::n_c_i++;
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "cryptsetup luksOpen $device $enc_dev_short_name --key-file $keyfile",
-    pre => "crypt_format_$device",
-    post => "encrypted_$device"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command(
+    "yes YES | cryptsetup luksFormat $device $keyfile -c aes-cbc-essiv:sha256 -s 256",
+    "exist_$device,keyfile_$device", "crypt_format_$device" );
+  &FAI::push_command(
+    "cryptsetup luksOpen $device $enc_dev_short_name --key-file $keyfile",
+    "crypt_format_$device", "encrypted_$device" );
 
   # add entries to crypttab
   push @FAI::crypttab, "$enc_dev_short_name\t$device\t$keyfile\tluks";
@@ -162,12 +145,8 @@
   # as that may be created later on
   (-b $disk) or die "Specified disk $disk does not exist in this system!\n";
   # set the raid flag
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "parted -s $disk set $part_no $t on",
-    pre => "exist_$d",
-    post => "type_${t}_$d"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( "parted -s $disk set $part_no $t on", "exist_$d",
+    "type_${t}_$d" );
 }
 
 ################################################################################
@@ -184,12 +163,15 @@
     ($config eq "RAID") or &FAI::internal_error("Invalid config $config");
 
     # create all raid devices
-    foreach my $id (sort { $a <=> $b } keys %{ $FAI::configs{$config}{volumes} }) {
+    foreach my $id (&numsort(keys %{ $FAI::configs{$config}{volumes} })) {
 
       # keep a reference to the current volume
       my $vol = (\%FAI::configs)->{$config}->{volumes}->{$id};
       # the desired RAID level
       my $level = $vol->{mode};
+      
+      warn "RAID implementation is incomplete - preserve is not supported\n" if
+        ($vol->{preserve});
 
       # prepend "raid", if the mode is numeric-only
       $level = "raid$level" if ($level =~ /^\d+$/);
@@ -219,12 +201,8 @@
       my $pre_req_no_comma = $pre_req;
       $pre_req_no_comma =~ s/^,//;
       # wait for udev to set up all devices
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "udevsettle --timeout=10",
-        pre => $pre_req_no_comma,
-        post => "settle_for_mdadm_create$id"
-      };
-      $FAI::n_c_i++;
+      &FAI::push_command( "udevsettle --timeout=10", $pre_req_no_comma,
+        "settle_for_mdadm_create$id" );
       
       # create the command
       if (0 == $id) {
@@ -232,14 +210,11 @@
       } else {
         $pre_req = "settle_for_mdadm_create$id,exist_/dev/md" . ( $id - 1 ) . $pre_req;
       }
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "yes | mdadm --create /dev/md$id --level=$level --force --run --raid-devices="
+      &FAI::push_command(
+        "yes | mdadm --create /dev/md$id --level=$level --force --run --raid-devices="
           . scalar(@eff_devs) . " --spare-devices=" . scalar(@spares) . " "
           . join(" ", @eff_devs) . " " . join(" ", @spares),
-        pre => "$pre_req",
-        post => "exist_/dev/md$id"
-      };
-      $FAI::n_c_i++;
+        "$pre_req", "exist_/dev/md$id" );
 
       # create the filesystem on the volume
       &FAI::build_mkfs_commands("/dev/md$id",
@@ -265,12 +240,7 @@
   #   foreach ( @{$devices_aref} );
   my $device_list = join (" ", @{$devices_aref});
   $FAI::debug and print "Erased devices: $device_list\n"; 
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "pvremove -ff -y $device_list",
-    pre => "",
-    post => "pv_sigs_removed"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( "pvremove -ff -y $device_list", "", "pv_sigs_removed" );
 
   # reload module
   # push @FAI::commands, "modprobe dm_mod";
@@ -287,7 +257,7 @@
 sub create_volume_group {
 
   my ($config) = @_;
-  ($config =~ /^VG_(.+)$/) or &FAI::internal_error("Invalid config $config");
+  ($config =~ /^VG_(.+)$/) and ($1 ne "--ANY--") or &FAI::internal_error("Invalid config $config");
   my $vg = $1; # the actual volume group
 
   # create the volume group, if it doesn't exist already
@@ -295,23 +265,13 @@
     # create all the devices
     my @devices = keys %{ $FAI::configs{$config}{devices} };
     &FAI::erase_lvm_signature(\@devices);
-    foreach (@devices) {
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "pvcreate $_",
-        pre => "pv_sigs_removed,exist_$_",
-        post => "pv_done_$_"
-      };
-      $FAI::n_c_i++;
-    }
+    &FAI::push_command( "pvcreate $_", "pv_sigs_removed,exist_$_",
+      "pv_done_$_" ) foreach (@devices);
     # create the volume group
     my $pre_dev = join(",pv_done_", @devices);
     $pre_dev =~ s/^,//;
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "vgcreate $vg " . join (" ", @devices),
-      pre => "$pre_dev",
-      post => "vg_created_$vg"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "vgcreate $vg " . join (" ", @devices), "$pre_dev",
+      "vg_created_$vg" );
     # we are done
     return;
   }
@@ -329,24 +289,13 @@
   # &FAI::erase_lvm_signature( \@new_devices );
 
   # create all the devices
-  foreach (@new_devices) {
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "pvcreate $_",
-      pre => "exist_$_",
-      post => "pv_done_$_"
-    };
-    $FAI::n_c_i++;
-  }
+  &FAI::push_command( "pvcreate $_", "exist_$_", "pv_done_$_" ) foreach (@new_devices);
 
   # extend the volume group by the new devices (includes the current ones)
   my $pre_dev = join(",pv_done_", @new_devices);
   $pre_dev =~ s/^,//;
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "vgextend $vg " . join (" ", @new_devices),
-    pre => "$pre_dev",
-    post => "vg_extended_$vg"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( "vgextend $vg " . join (" ", @new_devices), "$pre_dev",
+    "vg_extended_$vg" );
 
   # the devices to be removed
   my %rm_devs = ();
@@ -358,19 +307,10 @@
   # run vgreduce to get them removed
   if (scalar (keys %rm_devs)) {
     $pre_dev = join(",pv_done_", keys %rm_devs);
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "vgreduce $vg " . join (" ", keys %rm_devs),
-      pre => "vg_extended_$vg$pre_dev",
-      post => "vg_created_$vg"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "vgreduce $vg " . join (" ", keys %rm_devs),
+      "vg_extended_$vg$pre_dev", "vg_created_$vg" );
   } else {
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "true",
-      pre => "vg_extended_$vg",
-      post => "vg_created_$vg"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "true", "vg_extended_$vg", "vg_created_$vg" );
   }
 }
 
@@ -385,7 +325,7 @@
 sub setup_logical_volumes {
 
   my ($config) = @_;
-  ($config =~ /^VG_(.+)$/) or &FAI::internal_error("Invalid config $config");
+  ($config =~ /^VG_(.+)$/) and ($1 ne "--ANY--") or &FAI::internal_error("Invalid config $config");
   my $vg = $1; # the actual volume group
 
   my $lv_rm_pre = "";
@@ -401,12 +341,7 @@
       next;
     }
 
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "lvremove -f $vg/$lv",
-      pre => "vg_enabled_$vg",
-      post => "lv_rm_$vg/$lv"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "lvremove -f $vg/$lv", "vg_enabled_$vg", "lv_rm_$vg/$lv");
     $lv_rm_pre .= ",lv_rm_$vg/$lv";
   }
   $lv_rm_pre =~ s/^,//;
@@ -431,45 +366,23 @@
       if ($lv_size->{eff_size} <
         $FAI::current_lvm_config{$vg}{volumes}{$lv}{size})
       {
-        $FAI::commands{$FAI::n_c_i} = {
-          cmd => "parted -s /dev/$vg/$lv resize 1 0 " . $lv_size->{eff_size} .  "B",
-          pre => "vg_enabled_$vg,$lv_rm_pre",
-          post => "lv_shrink_$vg/$lv"
-        };
-        $FAI::n_c_i++;
-        
-        $FAI::commands{$FAI::n_c_i} = {
-          cmd => "lvresize -L " . $lv_size->{eff_size} . " $vg/$lv",
-          pre => "vg_enabled_$vg,$lv_rm_pre,lv_shrink_$vg/$lv",
-          post => "lv_created_$vg/$lv"
-        };
-        $FAI::n_c_i++;
+        &FAI::push_command( "parted -s /dev/$vg/$lv resize 1 0 " . $lv_size->{eff_size} .  "B",
+          "vg_enabled_$vg,$lv_rm_pre", "lv_shrink_$vg/$lv" );
+        &FAI::push_command( "lvresize -L " . $lv_size->{eff_size} . " $vg/$lv",
+          "vg_enabled_$vg,$lv_rm_pre,lv_shrink_$vg/$lv", "lv_created_$vg/$lv" );
       } else {
-        $FAI::commands{$FAI::n_c_i} = {
-          cmd => "lvresize -L " . $lv_size->{eff_size} . " $vg/$lv",
-          pre => "vg_enabled_$vg,$lv_rm_pre",
-          post => "lv_grow_$vg/$lv"
-        };
-        $FAI::n_c_i++;
-        
-        $FAI::commands{$FAI::n_c_i} = {
-          cmd => "parted -s /dev/$vg/$lv resize 1 0 " . $lv_size->{eff_size} .  "B",
-          pre => "vg_enabled_$vg,$lv_rm_pre,lv_grow_$vg/$lv",
-          post => "exist_/dev/$vg/$lv"
-        };
-        $FAI::n_c_i++;
+        &FAI::push_command( "lvresize -L " . $lv_size->{eff_size} . " $vg/$lv",
+          "vg_enabled_$vg,$lv_rm_pre", "lv_grow_$vg/$lv" );
+        &FAI::push_command( "parted -s /dev/$vg/$lv resize 1 0 " . $lv_size->{eff_size} .  "B",
+          "vg_enabled_$vg,$lv_rm_pre,lv_grow_$vg/$lv", "exist_/dev/$vg/$lv" );
       }
 
       next;
     }
 
     # create a new volume
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "lvcreate -n $lv -L " . $lv_size->{eff_size} . " $vg",
-      pre => "vg_enabled_$vg,$lv_rm_pre",
-      post => "exist_/dev/$vg/$lv"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "lvcreate -n $lv -L " . $lv_size->{eff_size} . " $vg",
+      "vg_enabled_$vg,$lv_rm_pre", "exist_/dev/$vg/$lv" );
 
     # create the filesystem on the volume
     &FAI::build_mkfs_commands("/dev/$vg/$lv",
@@ -492,6 +405,7 @@
     # no physical devices or RAID here
     next if ($config =~ /^PHY_./ || $config eq "RAID");
     ($config =~ /^VG_(.+)$/) or &FAI::internal_error("Invalid config $config");
+    next if ($1 eq "--ANY--");
     my $vg = $1; # the volume group
 
     # set proper partition types for LVM
@@ -500,22 +414,14 @@
     my $type_pre = join(",type_lvm_", keys %{ $FAI::configs{$config}{devices} });
     $type_pre =~ s/^,//;
     # wait for udev to set up all devices
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "udevsettle --timeout=10",
-      pre => "$type_pre",
-      post => "settle_for_vgchange_$vg"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "udevsettle --timeout=10", "$type_pre",
+      "settle_for_vgchange_$vg" );
 
     # create the volume group or add/remove devices
     &FAI::create_volume_group($config);
     # enable the volume group
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "vgchange -a y $vg",
-      pre => "settle_for_vgchange_$vg,vg_created_$vg",
-      post => "vg_enabled_$vg"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "vgchange -a y $vg",
+      "settle_for_vgchange_$vg,vg_created_$vg", "vg_enabled_$vg" );
 
     # perform all necessary operations on the underlying logical volumes
     &FAI::setup_logical_volumes($config);
@@ -539,7 +445,7 @@
   my @to_preserve = ();
 
   # find partitions that should be preserved or resized
-  foreach my $part_id ( sort { $a <=> $b } keys %{ $FAI::configs{$config}{partitions} } ) {
+  foreach my $part_id (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
     # reference to the current partition
     my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
     next unless ($part->{size}->{preserve} || $part->{size}->{resize});
@@ -558,7 +464,7 @@
   }
 
   # sort the list of preserved partitions
-  @to_preserve = sort { $a <=> $b } @to_preserve;
+  @to_preserve = &numsort(@to_preserve);
 
   # add the extended partition as well, if logical partitions must be
   # preserved; and mark it as resize
@@ -594,14 +500,14 @@
     # if the extended partition is not listed yet, find and add it now; note
     # that we need to add the existing one
     if ($has_logical && -1 == $extended) {
-      foreach my $part_id (sort { $a <=> $b } keys %{ $FAI::current_config{$disk}{partitions} }) {
+      foreach my $part_id (&numsort(keys %{ $FAI::current_config{$disk}{partitions} })) {
 
         # no extended partition
         next unless
           $FAI::current_config{$disk}{partitions}{$part_id}{is_extended};
 
         # find the configured extended partition to set the mapping
-        foreach my $p (sort { $a <=> $b } keys %{ $FAI::configs{$config}{partitions} }) {
+        foreach my $p (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
           # reference to the current partition
           my $part = (\%FAI::configs)->{$config}->{partitions}->{$p};
           next unless $part->{size}->{extended};
@@ -622,7 +528,7 @@
         }
 
         # sort the list of preserved partitions (again)
-        @to_preserve = sort { $a <=> $b } @to_preserve;
+        @to_preserve = &numsort(@to_preserve);
 
         last;
       }
@@ -694,12 +600,8 @@
     $post = "rebuilt_" . &FAI::make_device_name($disk, $part_nr) if
       $FAI::configs{$config}{partitions}{$part_id}{size}{resize};
     # build a parted command to create the partition
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "parted -s $disk mkpart $part_type $fs ${start}B ${end}B",
-      pre => "cleared1_$disk",
-      post => $post
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "parted -s $disk mkpart $part_type $fs ${start}B
+      ${end}B", "cleared1_$disk", $post );
   }
 }
 
@@ -728,19 +630,15 @@
     or die "Can't change disklabel, partitions are to be preserved\n";
 
   # write the disklabel to drop the previous partition table
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "parted -s $disk mklabel " . $FAI::configs{$config}{disklabel},
-    pre => "exist_$disk",
-    post => "cleared1_$disk"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( "parted -s $disk mklabel " .
+    $FAI::configs{$config}{disklabel}, "exist_$disk", "cleared1_$disk" );
 
   &FAI::rebuild_preserved_partitions($config, \@to_preserve);
 
   my $pre_all_resize = "";
 
   # resize partitions while checking for dependencies
-  foreach my $part_id (reverse sort { $a <=> $b } (@to_preserve)) {
+  foreach my $part_id (reverse &numsort(@to_preserve)) {
     # reference to the current partition
     my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
     # get the existing id
@@ -755,7 +653,7 @@
     $pre_all_resize .= ",resized_" . &FAI::make_device_name($disk, $p);
     my $deps = "";
     # now walk all other partitions requiring a resize to check for overlaps
-    foreach my $part_other (reverse sort { $a <=> $b } (@to_preserve)) {
+    foreach my $part_other (reverse &numsort(@to_preserve)) {
       # don't compare to self
       next if ($part_id == $part_other);
       # reference to the current partition
@@ -815,47 +713,33 @@
       my $eff_size = $part->{size}->{eff_size};
 
       # wait for udev to set up all devices
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "udevsettle --timeout=10",
-        pre => "rebuilt_" . &FAI::make_device_name($disk, $p) . $deps,
-        post => "settle_for_resize_" . &FAI::make_device_name($disk, $p)
-      };
-      $FAI::n_c_i++;
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "yes | ntfsresize -s $eff_size " .  &FAI::make_device_name($disk, $p),
-        pre => "settle_for_resize_" . &FAI::make_device_name($disk, $p),
-        post => "ntfs_ready_for_rm_" . &FAI::make_device_name($disk, $p)
-      };
-      $FAI::n_c_i++;
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "parted -s $disk rm $p",
-        pre => "ntfs_ready_for_rm_" . &FAI::make_device_name($disk, $p),
-        post => "resized_" . &FAI::make_device_name($disk, $p)
-      };
-      $FAI::n_c_i++;
+      &FAI::push_command( "udevsettle --timeout=10", "rebuilt_" .
+        &FAI::make_device_name($disk, $p) . $deps, "settle_for_resize_" .
+        &FAI::make_device_name($disk, $p) );
+      &FAI::push_command( "yes | ntfsresize -s $eff_size " .
+        &FAI::make_device_name($disk, $p), "settle_for_resize_" .
+        &FAI::make_device_name($disk, $p), "ntfs_ready_for_rm_" .
+        &FAI::make_device_name($disk, $p) );
+      &FAI::push_command( "parted -s $disk rm $p", "ntfs_ready_for_rm_" .
+        &FAI::make_device_name($disk, $p), "resized_" .
+        &FAI::make_device_name($disk, $p) );
     } else {
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "parted -s $disk resize $p ${start}B ${end}B",
-        pre => "rebuilt_" . &FAI::make_device_name($disk, $p),
-        post => "resized_" . &FAI::make_device_name($disk, $p)
-      };
-      $FAI::n_c_i++;
+      &FAI::push_command( "parted -s $disk resize $p ${start}B ${end}B",
+        "rebuilt_" . &FAI::make_device_name($disk, $p), "resized_" .
+        &FAI::make_device_name($disk, $p) );
     }
     
   }
 
   # write the disklabel again to drop the partition table and create a new one
   # that has the proper ids
-  $FAI::commands{$FAI::n_c_i} = {
-    cmd => "parted -s $disk mklabel " . $FAI::configs{$config}{disklabel},
-    pre => "cleared1_$disk$pre_all_resize",
-    post => "cleared2_$disk"
-  };
-  $FAI::n_c_i++;
+  &FAI::push_command( "parted -s $disk mklabel " .
+    $FAI::configs{$config}{disklabel}, "cleared1_$disk$pre_all_resize",
+    "cleared2_$disk" );
 
   my $prev_id = -1;
   # generate the commands for creating all partitions
-  foreach my $part_id (sort { $a <=> $b } keys %{ $FAI::configs{$config}{partitions} }) {
+  foreach my $part_id (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
     # reference to the current partition
     my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
     # get the existing id
@@ -889,23 +773,18 @@
     my $pre = "";
     $pre = ",exist_" . &FAI::make_device_name($disk, $prev_id) if ($prev_id > -1);
     # build a parted command to create the partition
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "parted -s $disk mkpart $part_type $fs ${start}B ${end}B",
-      pre => "cleared2_$disk$pre",
-      post => "exist_" . &FAI::make_device_name($disk, $part_id)
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "parted -s $disk mkpart $part_type $fs ${start}B
+      ${end}B", "cleared2_$disk$pre", "exist_" . &FAI::make_device_name($disk,
+      $part_id) );
     $prev_id = $part_id;
   }
 
   # set the bootable flag, if requested at all
   if ($FAI::configs{$config}{bootable} > -1) {
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "parted -s $disk set " . $FAI::configs{$config}{bootable} . " boot on",
-      pre => "exist_" . &FAI::make_device_name($disk, $FAI::configs{$config}{bootable}),
-      post => "boot_set_$disk"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "parted -s $disk set " .
+      $FAI::configs{$config}{bootable} . " boot on", "exist_" .
+      &FAI::make_device_name($disk, $FAI::configs{$config}{bootable}),
+      "boot_set_$disk" );
   }
 }
 
@@ -929,7 +808,7 @@
     &FAI::setup_partitions($config) unless ($FAI::configs{$config}{virtual});
     
     # generate the commands for creating all filesystems
-    foreach my $part_id ( sort { $a <=> $b } keys %{ $FAI::configs{$config}{partitions} } ) {
+    foreach my $part_id (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
       # reference to the current partition
       my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
 
@@ -958,7 +837,7 @@
         . $FAI::current_config{$disk}{disklabel}, 0, 0);
 
     # generate the commands for creating all partitions
-    foreach my $part_id (sort { $a <=> $b } keys %{ $FAI::current_config{$disk}{partitions} }) {
+    foreach my $part_id (&numsort(keys %{ $FAI::current_config{$disk}{partitions} })) {
       # reference to the current partition
       my $curr_part = (\%FAI::current_config)->{$disk}->{partitions}->{$part_id};
 
@@ -1020,12 +899,8 @@
       die "Cannot satisfy pre-depends for " . $FAI::commands{$i}{cmd} . ": " .
         $FAI::commands{$i}{pre} . " -- system left untouched.\n";
     }
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => $FAI::commands{$i}{cmd},
-      pre => $FAI::commands{$i}{pre},
-      post => $FAI::commands{$i}{post}
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( $FAI::commands{$i}{cmd}, $FAI::commands{$i}{pre},
+      $FAI::commands{$i}{post} );
     delete $FAI::commands{$i};
   }
 }

Modified: people/michael/features/setup_harddisks_2/implementation/lib/fstab.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/fstab.pm	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/implementation/lib/fstab.pm	2008-06-02 15:16:54 UTC (rev 4927)
@@ -73,8 +73,55 @@
   return join ("\t", @fstab_line);
 }
 
+
 ################################################################################
 #
+# @brief Obtain UUID and filesystem label information, if any.
+#
+# @param device_name Full device name
+# @param key_type Type to be used (uuid, label, or device)
+#
+# @return fstab key to be used
+#
+################################################################################
+sub get_fstab_key {
+  my ($device_name, $key_type) = @_;
+
+  ("uuid" eq $key_type) or ("label" eq $key_type) or ("device" eq $key_type) or
+    &FAI::internal_error("Invalid key type $key_type");
+
+  # write the device name as the first entry; if the user prefers uuids
+  # or labels, use these if available
+  my @uuid = ();
+  &FAI::execute_ro_command(
+    "/lib/udev/vol_id -u $device_name", \@uuid, 0);
+
+  # 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";
+
+  # get the label -- this is likely empty
+  my @label = ();
+  &FAI::execute_ro_command(
+    "/lib/udev/vol_id -l $device_name", \@label, 0);
+
+  # using the fstabkey value the desired device entry is defined
+  if ($key_type eq "uuid") {
+    chomp ($uuid[0]);
+    return "UUID=$uuid[0]";
+  } elsif ($key_type eq "label" && scalar(@label) == 1) {
+    chomp($label[0]);
+    return "LABEL=$label[0]";
+  } else {
+    # otherwise, use the usual device path
+    return $device_name;
+  }
+}
+          
+
+################################################################################
+#
 # @brief this function generates the fstab file from our representation of the
 # partitions to be created.
 #
@@ -119,37 +166,6 @@
           $device_name =~ "s#/#_#g";
           $device_name = "/dev/mapper/crypt$device_name";
         }
-
-        # device key used for mounting
-        my $fstab_key = "";
-
-        # write the device name as the first entry; if the user prefers uuids
-        # or labels, use these if available
-        my @uuid = ();
-        &FAI::execute_ro_command(
-          "/lib/udev/vol_id -u $device_name", \@uuid, 0);
-
-        # 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";
-
-        # get the label -- this is likely empty
-        my @label = ();
-        &FAI::execute_ro_command(
-          "/lib/udev/vol_id -l $device_name", \@label, 0);
-
-        # using the fstabkey value the desired device entry is defined
-        if ($config->{$c}->{fstabkey} eq "uuid") {
-          chomp ($uuid[0]);
-          $fstab_key = "UUID=$uuid[0]";
-        } elsif ($config->{$c}->{fstabkey} eq "label" && scalar(@label) == 1) {
-          chomp($label[0]);
-          $fstab_key = "LABEL=$label[0]";
-        } else {
-          # otherwise, use the usual device path
-          $fstab_key = $device_name;
-        }
           
         # if the mount point is / or /boot, the variables should be set, unless
         # they are already
@@ -162,10 +178,13 @@
             $FAI::disk_var{BOOT_DEVICE} = $1;
         }
   
-        push @fstab, &FAI::create_fstab_line($p_ref, $fstab_key, $device_name);
+        push @fstab, &FAI::create_fstab_line($p_ref,
+          &FAI::get_fstab_key($device_name, $config->{$c}->{fstabkey}), $device_name);
 
       }
     } elsif ($c =~ /^VG_(.+)$/) {
+      next if ($1 eq "--ANY--");
+      
       my $device = $1;
 
       # create a line in the output file for each logical volume
@@ -211,7 +230,8 @@
             $FAI::disk_var{BOOT_DEVICE} = $device_name;
         }
 
-        push @fstab, &FAI::create_fstab_line($l_ref, $device_name, $device_name);
+        push @fstab, &FAI::create_fstab_line($l_ref,
+          &FAI::get_fstab_key($device_name, $config->{"VG_--ANY--"}->{fstabkey}), $device_name);
       }
     } elsif ($c eq "RAID") {
 
@@ -242,7 +262,8 @@
             $FAI::disk_var{BOOT_DEVICE} = "$device_name";
         }
 
-        push @fstab, &FAI::create_fstab_line($r_ref, $device_name, $device_name);
+        push @fstab, &FAI::create_fstab_line($r_ref,
+          &FAI::get_fstab_key($device_name, $config->{RAID}->{fstabkey}), $device_name);
       }
     } else {
       &FAI::internal_error("Unexpected key $c");

Modified: people/michael/features/setup_harddisks_2/implementation/lib/init.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/init.pm	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/implementation/lib/init.pm	2008-06-02 15:16:54 UTC (rev 4927)
@@ -124,6 +124,35 @@
 
 ################################################################################
 #
+# @brief Add command to hash
+#
+# @param cmd Command
+# @param pre Preconditions
+# @param post Postconditions
+#
+################################################################################
+sub push_command { 
+  my ($cmd, $pre, $post) = @_;
+    
+  $FAI::commands{$FAI::n_c_i} = {
+    cmd => $cmd,
+    pre => $pre,
+    post => $post
+  };
+  $FAI::n_c_i++;
+}
+
+
+################################################################################
+#
+# @brief Sort integer arrays
+#
+################################################################################
+sub numsort { return sort { $a <=> $b } @_; }
+
+
+################################################################################
+#
 # @brief Check, whether $dev is a physical device, and extract sub-parts
 #
 # @param $dev Device string

Modified: people/michael/features/setup_harddisks_2/implementation/lib/parser.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/parser.pm	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/implementation/lib/parser.pm	2008-06-02 15:16:54 UTC (rev 4927)
@@ -147,7 +147,7 @@
   if ($type eq "primary") {
 
     # find all previously defined primary partitions
-    foreach my $part_id (sort { $a <=> $b } keys %{ $FAI::configs{$FAI::device}{partitions} }) {
+    foreach my $part_id (&numsort(keys %{ $FAI::configs{$FAI::device}{partitions} })) {
 
       # break, if the partition has not been created by init_part_config
       defined ($FAI::configs{$FAI::device}{partitions}{$part_id}{size}{extended}) or last;
@@ -173,7 +173,7 @@
     # this branch, it has been ensured above
 
     # find the index of the new partition, initialise it to the highest current index
-    foreach my $part_id (sort { $a <=> $b } keys %{ $FAI::configs{$FAI::device}{partitions} }) {
+    foreach my $part_id (&numsort(keys %{ $FAI::configs{$FAI::device}{partitions} })) {
 
       # skip primary partitions
       next if ($part_id < 5);
@@ -198,7 +198,7 @@
       my $extended = 0;
 
       # find all previously defined primary partitions
-      foreach my $part_id (sort { $a <=> $b } keys %{ $FAI::configs{$FAI::device}{partitions} }) {
+      foreach my $part_id (&numsort(keys %{ $FAI::configs{$FAI::device}{partitions} })) {
 
         # break, if the partition has not been created by init_part_config
         defined ($FAI::configs{$FAI::device}{partitions}{$part_id}{size}{extended}) or last;
@@ -316,7 +316,9 @@
           # check, whether raid tools are available
           &FAI::in_path("mdadm") or die "mdadm not found in PATH\n";
           $FAI::device = "RAID";
+          $FAI::configs{$FAI::device}{fstabkey} = "device";
         }
+        raid_option(s?)
         | /^lvm/
         {
 
@@ -325,7 +327,9 @@
           # initialise $FAI::device to inform the following lines about the LVM
           # being configured
           $FAI::device = "VG_";
+          $FAI::configs{"VG_--ANY--"}{fstabkey} = "device";
         }
+        lvm_option(s?)
         | 'end'
         {
           # exit config mode
@@ -347,7 +351,60 @@
           &FAI::init_disk_config($item[ 1 ]);
         }
         option(s?)
+    
+    raid_option: /^preserve_always:(\d+(,\d+)*)/
+        {
+          # set the preserve flag for all ids in all cases
+          $FAI::configs{RAID}{volumes}{$_}{preserve} = 1 foreach (split (",", $1));
+        }
+        | /^preserve_reinstall:(\d+(,\d+)*)/
+        {
+          # set the preserve flag for all ids if $FAI::reinstall is set
+          if ($FAI::reinstall) {
+            $FAI::configs{RAID}{volumes}{$_}{preserve} = 1 foreach (split(",", $1));
+          }
+        }
+        | /^fstabkey:(device|label|uuid)/
+        {
+          # the information preferred for fstab device identifieres
+          $FAI::configs{$FAI::device}{fstabkey} = $1;
+        }
 
+    lvm_option: m{^preserve_always:([^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*)}
+        {
+          # set the preserve flag for all ids in all cases
+          foreach (split (",", $1)) {
+            (m{^([^/,\s\-]+)-([^/,\s\-]+)\s+}) or 
+              die &FAI::internal_error("VG re-parse failed");
+            $FAI::configs{"VG_$1"}{volumes}{$2}{size}{preserve} = 1 
+          }
+        }
+        | m{^preserve_reinstall:([^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*)}
+        {
+          # set the preserve flag for all ids if $FAI::reinstall is set
+          if ($FAI::reinstall) {
+            foreach (split (",", $1)) {
+              (m{^([^/,\s\-]+)-([^/,\s\-]+)\s+}) or 
+                die &FAI::internal_error("VG re-parse failed");
+              $FAI::configs{"VG_$1"}{volumes}{$2}{size}{preserve} = 1 
+            }
+          }
+        }
+        | m{^resize:([^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*)}
+        {
+          # set the resize flag for all ids
+          foreach (split (",", $1)) {
+            (m{^([^/,\s\-]+)-([^/,\s\-]+)\s+}) or 
+              die &FAI::internal_error("VG re-parse failed");
+            $FAI::configs{"VG_$1"}{volumes}{$2}{size}{resize} = 1 
+          }
+        }
+        | /^fstabkey:(device|label|uuid)/
+        {
+          # the information preferred for fstab device identifieres
+          $FAI::configs{"VG_--ANY--"}{fstabkey} = $1;
+        }
+
     option: /^preserve_always:(\d+(,\d+)*)/
         {
           # set the preserve flag for all ids in all cases
@@ -421,7 +478,7 @@
           # initialise a logical partition
           &FAI::init_part_config($item[ 1 ]);
         }
-        | m{^([^/\s\-]+)-([^/\s\-]+)\s+}
+        | m{^([^/,\s\-]+)-([^/,\s\-]+)\s+}
         {
           # set $FAI::device to VG_$1
           $FAI::device = "VG_$1";
@@ -429,13 +486,16 @@
           defined ($FAI::configs{$FAI::device}) or 
             die "Volume group $1 has not been declared yet.\n";
           # make sure, $2 has not been defined already
-          defined ($FAI::configs{$FAI::device}{volumes}{$2}) and 
+          defined ($FAI::configs{$FAI::device}{volumes}{$2}{size}{range}) and 
             die "Logical volume $2 has been defined already.\n";
           # initialise the new hash
-          $FAI::configs{$FAI::device}{volumes}{$2} = {};
+          defined($FAI::configs{$FAI::device}{volumes}{$2}) or
+            $FAI::configs{$FAI::device}{volumes}{$2} = {};
           # initialise the preserve and resize flags
-          $FAI::configs{$FAI::device}{volumes}{$2}{size}{preserve} = 0;
-          $FAI::configs{$FAI::device}{volumes}{$2}{size}{resize} = 0;
+          defined($FAI::configs{$FAI::device}{volumes}{$2}{size}{preserve}) or
+            $FAI::configs{$FAI::device}{volumes}{$2}{size}{preserve} = 0;
+          defined($FAI::configs{$FAI::device}{volumes}{$2}{size}{resize}) or
+            $FAI::configs{$FAI::device}{volumes}{$2}{size}{resize} = 0;
           # set the reference to the current volume
           # the reference is used by all further processing of this config line
           $FAI::partition_pointer = (\%FAI::configs)->{$FAI::device}->{volumes}->{$2};
@@ -466,7 +526,7 @@
           }
         }
 
-    name: m{^([^/\s\-]+)}
+    name: m{^([^/,\s\-]+)}
         {
           # set the device name to VG_ and the name of the volume group
           $FAI::device = "VG_$1";

Modified: people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm	2008-06-02 15:16:54 UTC (rev 4927)
@@ -186,6 +186,7 @@
     # for RAID or physical disks there is nothing to be done here
     next if ($config eq "RAID" || $config =~ /^PHY_./);
     ($config =~ /^VG_(.+)$/) or &FAI::internal_error("invalid config entry $config");
+    next if ($1 eq "--ANY--");
     my $vg = $1; # the volume group name
 
     # compute the size of the volume group; this is not exact, but should at
@@ -370,7 +371,7 @@
   $part->{size}->{eff_size} = 0;
   $part->{start_byte} = -1;
 
-  foreach my $p (sort { $a <=> $b } keys %{ $FAI::configs{$config}{partitions} }) {
+  foreach my $p (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
     next if ($p < 5);
 
     $part->{start_byte} = $FAI::configs{$config}{partitions}{$p}{start_byte} -
@@ -586,7 +587,7 @@
     my $current_extended = -1;
 
     # find the first existing extended partition
-    foreach my $part_id (sort { $a <=> $b } keys %{ $current_disk->{partitions} }) {
+    foreach my $part_id (&numsort(keys %{ $current_disk->{partitions} })) {
       if ($current_disk->{partitions}->{$part_id}->{is_extended}) {
         $current_extended = $part_id;
         last;
@@ -621,7 +622,7 @@
     }
 
     # the list of partitions that we need to find start and end bytes for
-    my @worklist = (sort { $a <=> $b } keys %{ $FAI::configs{$config}{partitions} });
+    my @worklist = (&numsort(keys %{ $FAI::configs{$config}{partitions} }));
 
     while (scalar (@worklist))
     {
@@ -683,7 +684,7 @@
     (defined ($FAI::configs{$config}{partitions}{$_}{start_byte})
         && defined ($FAI::configs{$config}{partitions}{$_}{end_byte}))
       or &FAI::internal_error("start or end of partition $_ not set")
-        foreach (sort { $a <=> $b } keys %{ $FAI::configs{$config}{partitions} });
+        foreach (&numsort(keys %{ $FAI::configs{$config}{partitions} }));
   }
 }
 

Modified: people/michael/features/setup_harddisks_2/implementation/lib/volumes.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/volumes.pm	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/implementation/lib/volumes.pm	2008-06-02 15:16:54 UTC (rev 4927)
@@ -51,12 +51,7 @@
 
     # make sure, $disk is a proper block device
     (-b $disk) or die "$disk is not a block special device!\n";
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "true",
-      pre => "",
-      post => "exist_$disk"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "true", "", "exist_$disk" );
 
     # initialise the hash
     $FAI::current_config{$disk}{partitions} = {};
@@ -301,12 +296,7 @@
   foreach my $vg (get_volume_group_list()) {
     # initialise the hash entry
     $FAI::current_lvm_config{$vg}{physical_volumes} = ();
-    $FAI::commands{$FAI::n_c_i} = {
-      cmd => "true",
-      pre => "",
-      post => "vg_created_$vg"
-    };
-    $FAI::n_c_i++;
+    &FAI::push_command( "true", "", "vg_created_$vg" );
     
     # store the vg size in MB
     my %vg_info = get_volume_group_information($vg);
@@ -322,12 +312,7 @@
       $FAI::current_lvm_config{$vg}{volumes}{$short_name}{size} =
         &FAI::convert_unit($lv_info{$lv_name}->{lv_size} .
           $lv_info{$lv_name}->{lv_size_unit});
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "true",
-        pre => "",
-        post => "exist_/dev/$vg/$short_name"
-      };
-      $FAI::n_c_i++;
+      &FAI::push_command( "true", "", "exist_/dev/$vg/$short_name" );
     }
     
     # store the physical volumes
@@ -369,17 +354,84 @@
     if ($line =~ /^ARRAY \/dev\/md(\d+) level=(\S+) num-devices=\d+ UUID=/) {
       $id = $1;
       $FAI::current_raid_config{$id}{mode} = $2;
-      $FAI::commands{$FAI::n_c_i} = {
-        cmd => "true",
-        pre => "",
-        post => "exist_/dev/md$id"
-      };
-      $FAI::n_c_i++;
+      &FAI::push_command( "true", "", "exist_/dev/md$id" );
     } elsif ($line =~ /^\s*devices=(\S+)$/) {
       @{ $FAI::current_raid_config{$id}{devices} } = split (",", $1);
     }
   }
 }
 
+
+################################################################################
+#
+# @brief Set the appropriate preserve flag for $device_name
+#
+# @param device_name Full device path
+#
+################################################################################
+sub mark_preserve {
+  my ($device_name) = @_;
+  my ($i_p_d, $disk, $part_no) = &FAI::phys_dev($device_name);
+
+  if (1 == $i_p_d && defined($FAI::configs{"PHY_$disk"}{partitions}{$part_no})) {
+    $FAI::configs{"PHY_$disk"}{partitions}{$part_no}{size}{preserve} = 1;
+  } elsif ($device_name =~ m{^/dev/md(\d+)$}) {
+    my $vol = $1;
+    if (defined($FAI::configs{RAID}{volumes}{$vol}) && 
+        $FAI::configs{RAID}{volumes}{$vol}{preserve} != 1) {
+      $FAI::configs{RAID}{volumes}{$vol}{preserve} = 1;
+      &FAI::mark_preserve($_) foreach (keys %{ $FAI::configs{RAID}{volumes}{$vol}{devices} });
+    }
+  } elsif ($device_name =~ m{^/dev/([^/\s]+)/([^/\s]+)$}) {
+    my $vg = $1;
+    my $lv = $2;
+    if (defined($FAI::configs{"VG_$vg"}{volumes}{$lv}) &&
+        $FAI::configs{"VG_$vg"}{volumes}{$lv}{size}{preserve} != 1) {
+      $FAI::configs{"VG_$vg"}{volumes}{$lv}{size}{preserve} = 1;
+      &FAI::mark_preserve($_) foreach (keys %{ $FAI::configs{"VG_$vg"}{devices} });
+    }
+  } else {
+    warn "Don't know how to mark $device_name for preserve\n";
+  }
+}
+
+
+################################################################################
+#
+# @brief Mark devices as preserve, in case an LVM volume or RAID device shall be
+# preserved
+#
+################################################################################
+sub propagate_preserve {
+
+  # loop through all configs
+  foreach my $config (keys %FAI::configs) {
+    
+    # no physical devices here
+    next if ($config =~ /^PHY_./);
+    
+    if ($config =~ /^VG_(.+)$/) {
+      next if ($1 eq "--ANY--");
+      # 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);
+        &FAI::mark_preserve($_) foreach (keys %{ $FAI::configs{$config}{devices} });
+        last;
+      }
+    } elsif ($config eq "RAID") {
+      # check for volumes that need to be preserved and preserve the underlying
+      # devices recursively
+      foreach my $r (keys %{ $FAI::configs{$config}{volumes} }) {
+        next unless ($FAI::configs{$config}{volumes}{$r}{preserve} == 1);
+        &FAI::mark_preserve($_) foreach (keys %{ $FAI::configs{$config}{volumes}{$r}{devices} });
+      }
+    } else {
+      &FAI::internal_error("Unexpected key $config");
+    }
+  }
+}
+
+
 1;
 

Modified: people/michael/features/setup_harddisks_2/implementation/setup-storage
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/setup-storage	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/implementation/setup-storage	2008-06-02 15:16:54 UTC (rev 4927)
@@ -52,7 +52,7 @@
 
 package FAI;
 
-my $version = "0.1.4893";
+my $version = "0.9";
 
 # command line parameter handling
 use Getopt::Std;
@@ -110,6 +110,9 @@
 warn "Starting setup-storage $version";
 &FAI::run_parser($config_file);
 
+# mark devices as preserve, where not all already done so
+&FAI::propagate_preserve;
+
 # read the sizes and partition tables of all disks listed in $FAI::disks
 &FAI::get_current_disks;
 
@@ -162,13 +165,13 @@
 
 # run all commands
 # debugging only: print the command script
-$FAI::debug and print "$_:" . $FAI::commands{$_}{cmd} . "\n" foreach (sort { $a <=> $b } keys %FAI::commands);
+$FAI::debug and print "$_:" . $FAI::commands{$_}{cmd} . "\n" foreach (&numsort(keys %FAI::commands));
 
 # run the commands (if $FAI::no_dry_run is set)
 # load the modules to support encryption
 `modprobe aes`;
 `modprobe dm-crypt`;
-&FAI::execute_command($FAI::commands{$_}{cmd}) foreach (sort { $a <=> $b } keys %FAI::commands);
+&FAI::execute_command($FAI::commands{$_}{cmd}) foreach (&numsort(keys %FAI::commands));
 
 # generate the proposed fstab contents
 # wait for udev to set up all devices

Modified: people/michael/features/setup_harddisks_2/setup-storage.8
===================================================================
--- people/michael/features/setup_harddisks_2/setup-storage.8	2008-06-02 12:38:37 UTC (rev 4926)
+++ people/michael/features/setup_harddisks_2/setup-storage.8	2008-06-02 15:16:54 UTC (rev 4927)
@@ -135,8 +135,8 @@
 .Pp
 comment ::= #.* 
 .Pp
-config ::= disk_config lvm 
-           | disk_config raid
+config ::= disk_config lvm( <lvmoption>)* 
+           | disk_config raid( <raidoption>)*
            | disk_config end 
            | disk_config disk[[:digit:]]+( <option>)*
            | disk_config [^[:space:]]+( <option>)*
@@ -144,6 +144,30 @@
             * path is assumed to be /dev/hda */
            | <volume>
 .Pp
+lvmoption ::= /* empty */
+           | preserve_always:[[:digit:]]+(,[[:digit:]]+)*
+           /* preserve partitions -- always */
+           | preserve_reinstall:[[:digit:]]+(,[[:digit:]]+)*
+           /* preserve partitions -- unless the system is installed for the 
+           first time */
+           | resize:[[:digit:]]+(,[[:digit:]]+)*
+           /* attempt to resize partitions */
+           | fstabkey:(device|label|uuid)
+           /* when creating the fstab, the key used for defining the device
+           may be the device (/dev/xxx), a label given using -L, or the uuid
+           */  
+.Pp
+raidoption ::= /* empty */
+           | preserve_always:[[:digit:]]+(,[[:digit:]]+)*
+           /* preserve partitions -- always */
+           | preserve_reinstall:[[:digit:]]+(,[[:digit:]]+)*
+           /* preserve partitions -- unless the system is installed for the 
+           first time */
+           | fstabkey:(device|label|uuid)
+           /* when creating the fstab, the key used for defining the device
+           may be the device (/dev/xxx), a label given using -L, or the uuid
+           */  
+.Pp
 option ::= /* empty */
            | preserve_always:[[:digit:]]+(,[[:digit:]]+)*
            /* preserve partitions -- always */




More information about the Fai-commit mailing list