t11 and new partitioner fixes
[automated-distro-installer] / fai / config / hooks / partition.DEFAULT
index 7990a19918faf90e56760428b54fce9e032f1120..1586e48a2f86866c16552ff7b4ce27be3d0e161f 100755 (executable)
@@ -358,6 +358,7 @@ EOF
 # todo: update for lvm
 doroot2() {
 
+
   # We write to these files instead of just /etc/fstab, /etc/crypttab,
   # because these are filesystems created after our current root, and so
   # this allows us to update other root filesystems too.
@@ -366,10 +367,16 @@ doroot2() {
     echo $0: error: found partition=true but have mkroot2 arg
     exit 1
   fi
+
+
   root2_devs=()
   for vg in ${vgs[@]}; do
+
+
     root2_devs+=(/dev/mapper/crypt-$vg-root2)
     if $mkroot2; then
+      lvcreate -y -L $root2_part_mib $vg -n root2
+      lvcreate -y -L $boot2_part_mib $vg -n boot2
       luks-setup /dev/$vg/root2 crypt-$vg-root2
     fi
     cat >>/mnt/root/root2-crypttab <<EOF
@@ -658,11 +665,11 @@ fi
 boot_part_mib=$(( boot_mib * raid_duplication / ${#boot_devs[@]} ))
 
 if zilap; then
-  boot2_part_mib=0
-  root2_part_mib=0
-else
   boot2_part_mib=$(( boot2_mib * raid_duplication / ${#boot_devs[@]}  ))
   root2_part_mib=$(( root2_mib * raid_duplication / ${#root_devs[@]}  ))
+else
+  boot2_part_mib=0
+  root2_part_mib=0
 fi
 ### end calculate boot partition space
 
@@ -744,14 +751,18 @@ if $partition; then
     # we do lvm removals just for the disks we are using
     pv_wipes=()
     vg_wipes=()
+    declare -A vg_map
     pv_devs=$(pvs --noheadings -o pvname)
     for pv_dev in $pv_devs; do
-      pv_disk=${pv_dev%%[0-9]*}
       for short_dev in ${short_devs[@]}; do
-        if [[ $pv_disk == "$short_dev" ]]; then
+        if [[ $pv_dev == $short_dev* ]]; then
           pv_wipes+=($pv_dev)
-          vgs=$(pvs --noheadings -o vgname $pv_dev)
-          for vg in $vgs; do
+          vgs_of_pv=$(pvs --noheadings -o vgname $pv_dev)
+          for vg in $vgs_of_pv; do
+            if [[ ${vg_map[$vg]} ]]; then
+              continue
+            fi
+            vg_map[$vg]=t
             vg_wipes+=($vg)
             lvs=$(vgs --noheadings -o lv_path $vg)
             for lv in $lvs; do
@@ -779,7 +790,10 @@ if $partition; then
       while ! wipefs -a $dev; do
         sleep 2
         count_down=$((count_down - 1))
-        (( count_down > 0 )) || exit 1
+        if (( count_down <= 0 )); then
+          echo "$0: wipefs failed 10 times. exiting" >&2
+          exit 1
+        fi
       done
     done
   fi
@@ -869,12 +883,6 @@ if $partition; then
       fi
     fi
 
-    if zilap; then
-      # todo: now that we are using lvm, this doesnt need to be done until mkroot2
-      lvcreate -y -L $root2_part_mib $vg -n root2
-      lvcreate -y -L $boot2_part_mib $vg -n boot2
-    fi
-
     $pcmd mkpart primary "" ${pv_end}MiB ${disk_mib}MiB
     $pcmd name $bootn boot
     $pcmd set $bootn boot on