mostly fixes, one new partition option
[automated-distro-installer] / fai / config / hooks / partition.DEFAULT
index fc6da117fcd01cc2aafb91784c11a8fb7175961c..d702351a38178de41b5ed2e6395af241ab9035dc 100755 (executable)
@@ -75,6 +75,8 @@ fi
 #
 # NOWIPE: use existing subvolumes if they exist
 #
+# REROOTFS: Don't reuse the root filesystem, even if we normally would
+#
 # ROTATIONAL: forces to install onto hdds instead of sdds. normally sdds
 # are chosen if they exist.
 #
@@ -168,6 +170,7 @@ grub_extn=7
 # bios boot partition,
 # https://wiki.archlinux.org/index.php/GRUB
 bios_grubn=8
+# for an even raid (raid 1), when one disk is bigger, this partition goes on the big disk
 even_bign=9
 lastn=$bios_grubn
 
@@ -252,15 +255,18 @@ luks-setup() {
 
 
 ##### begin variable setup
+partition=false
 if ifclass REPARTITION; then
   partition=true # force a full wipe
-else
-  partition=false # change to true to force a full wipe
 fi
+wipe=true
 if ifclass NOWIPE; then
   wipe=false
-else
-  wipe=true
+fi
+
+rerootfs=false
+if ifclass REROOTFS; then
+  rerootfs=true
 fi
 
 if (($(nproc) > 2)); then
@@ -380,7 +386,7 @@ for dev in ${devs[@]}; do
     boot_devs+=("$(bootdev)")
     boot2_devs+=("$(boot2dev)")
   fi
-  if $first && (( ${boot_devs[@]} >= 1 )) ; then
+  if $first && (( ${#boot_devs[@]} >= 1 )) ; then
     first_efi=$(efidev)
     first_grub_extdev=$(grub_extdev)
     first=false
@@ -556,7 +562,7 @@ EOF
       # but it is safely ignorable and gets us the ability to just type our password
       # in once at boot. A downside is that they are probably needed to be plugged in to boot.
       cat >>/tmp/fai/crypttab <<EOF
-crypt_dev_ata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V-part${even_bign} /dev/disk/by-id/ata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V-part7  none  keyscript=decrypt_keyctl,discard,luks,initramfs
+crypt_dev_ata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V-part${even_bign} /dev/disk/by-id/ata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V-part${even_bign}  none  keyscript=decrypt_keyctl,discard,luks,initramfs
 crypt_dev_ata-TOSHIBA_MD04ACA500_84R2K773FS9A-part1 /dev/disk/by-id/ata-TOSHIBA_MD04ACA500_84R2K773FS9A-part1  none  keyscript=decrypt_keyctl,discard,luks,initramfs
 crypt_dev_ata-ST6000DM001-1XY17Z_Z4D29EBL-part1 /dev/disk/by-id/ata-ST6000DM001-1XY17Z_Z4D29EBL-part1  none  keyscript=decrypt_keyctl,discard,luks,initramfs
 EOF
@@ -820,9 +826,20 @@ else
     if [[ -e /dev/mapper/$(root-cryptname) ]]; then
       continue
     fi
-    cryptsetup luksOpen $(rootdev) $(root-cryptname) \
-               --key-file $luks_file
+    if $rerootfs; then
+      luks-setup $(rootdev)
+      sleep 1
+      bpart $(for dev in ${devs[@]}; do root-cryptdev; done)
+    else
+      cryptsetup luksOpen $(rootdev) $(root-cryptname) \
+                 --key-file $luks_file
+    fi
   done
+
+  if $rerootfs; then
+    sleep 1
+    bpart $(for dev in ${devs[@]}; do root-cryptdev; done)
+  fi
   sleep 1
 fi