start of etiona (trisquel 9) support
[automated-distro-installer] / fai / config / hooks / partition.DEFAULT
index b10a3e0f4c67e80fe6061ad23f2628785295c1b3..c637a9bcf6e1c71b00bd4c3fa91a3b7dced02afd 100755 (executable)
@@ -48,6 +48,7 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 #
 # RAID0: forces raid0 filesystem. Normally with 4+ devices, we use
 # raid10.
+# RAID1: forces raid1 filesystem.
 
 if [[ $SPECIAL_DISK ]]; then
   export CLASS_REPARTITION=true
@@ -235,8 +236,10 @@ for dev in ${devs[@]}; do
   fi
 done
 
-if ifclass RAID0 || (( ${#boot_devs[@]} < 4 )); then
+if ifclass RAID0 || (( ${#boot_devs[@]} == 1 )); then
   raid_level=0
+elif ifclass RAID1 || (( ${#boot_devs[@]} <= 3 )); then
+  raid_level=1
 else
   raid_level=10
   # need double the space if we are raid 10, and then
@@ -259,6 +262,8 @@ if [[ ! $DISTRO ]]; then
     DISTRO=trisquelbelenos
   elif ifclass VOL_FLIDAS; then
     DISTRO=trisquelflidas
+  elif ifclass VOL_ETIONA; then
+    DISTRO=trisqueletiona
   else
     echo "PARTITIONER ERROR: no distro class/var set" >&2
     exit 1
@@ -270,6 +275,7 @@ first_boot_dev=${boot_devs[0]}
 bpart() { # btrfs a partition
   case $raid_level in
     0) mkfs.btrfs -f $@ ;;
+    1) mkfs.btrfs -f -m raid1 -d raid1 $@ ;;
     10) mkfs.btrfs -f -m raid10 -d raid10 $@ ;;
   esac
 }
@@ -290,6 +296,9 @@ lukspw=$(cat $luks_dir/iank)
 if ifclass tpnew; then
   lukspw=$(cat $luks_dir/traci)
 fi
+if ifclass ziva; then
+  lukspw=$(cat $luks_dir/ziva)
+fi
 if ifclass demohost; then
   lukspw=x
 fi
@@ -396,8 +405,15 @@ if $partition; then
     # This is just a bit more robust, and it could work for booting
     # into ipxe which can't persist data, if we ever got that working.
     mkfs.ext2 `grub_extdev`
+    # when we move to newer than trisquel 8, we can remove
+    # --type luks1. We can also check on cryptsetup --help | less /compil
+    # to see about the other settings. Default in debian 9 is luks2.
+    # You can convert from luks2 to luks 1 by adding a temporary key:
+    # cryptsetup luksAddKey --pbkdf pbkdf2
+    # then remove the new format keys with cryptsetup luksRemoveKey
+    # then cryptsetup convert DEV --type luks1, then readd old keys and remove temp.
     yes YES | cryptsetup luksFormat `rootdev` $luks_dir/host-$HOSTNAME \
-                         -c aes-cbc-essiv:sha256 -s 256 || [[ $? == 141 ]]
+                         --type luks1 -c aes-cbc-essiv:sha256 -s 256 || [[ $? == 141 ]]
     yes "$lukspw" | \
       cryptsetup luksAddKey --key-file $luks_dir/host-$HOSTNAME \
                  `rootdev` || [[ $? == 141 ]]