fixup SPECIAL_DISK partitioning
authorIan Kelling <iank@fsf.org>
Sat, 1 Feb 2025 07:35:39 +0000 (02:35 -0500)
committerIan Kelling <iank@fsf.org>
Sat, 1 Feb 2025 07:35:39 +0000 (02:35 -0500)
fai/config/hooks/partition.DEFAULT

index 6ed98faacc7d93e774efee512c7f101bbbe9f241..034a98ce73003a1ab3caff53c58710c6d2a84fc6 100755 (executable)
@@ -29,34 +29,33 @@ if [[ $EUID != 0 ]]; then
   exit 1
 fi
 
-# for calling outside of FAI without args:
+
+# for calling outside of FAI.
 #
-# source /b/fai/fai-wrapper
+# source /b/fai/fai-wrapper (note: this exports everything, including functions).
 # - set any appropriate classes with: fai-setclass OPT1... which sets CLASS_OPT1=true...
 #   or run eval-fai-classfile FILE.
-# - Set a VOL_DISTROVER (if not doing mkroot2) eg:
-#   fai-setclass VOL_NABIA
-# - fai-setclass IANK|FSF
+# - fai-setclass IANK|FSF (if not already set in 51-multiboot)
 # /a/bin/fai/fai/config/hooks/partition.DEFAULT
 #
-# ARGS (only 1 is valid):
+## ARGS (only 0 or 1 is valid). All args are for use outside of fai.
 #
-# mkroot2: for running outside of fai and setting up the root2/boot2 luks and btrfs and tab files
+# mkroot2: for setting up the root2/boot2 luks and btrfs and tab files
 #
-# mkroot2tab: for running outside of fai and setting up the root2/boot2 tab files, in case luks and btrfs
+# mkroot2tab: for setting up the root2/boot2 tab files, in case luks and btrfs
 # happen to already be setup.
 #
-# mktab: for running outside of fai and generating a crypttab for
-# the main root fs in /tmp/fai. Must run with env var, eg export DISTRO=trisquelaramo.
+# mktab: for generating a crypttab for the main root fs in
+# /tmp/fai. Requires DISTRO be set, see below.
 #
 # Example use in a bootstrap distro:
 # scp /b/fai/fai-wrapper /a/bin/fai/fai/config/{distro-install-common/devbyid,hooks/partition.DEFAULT} root@HOST:
-# sl HOST
+# sl root@HOST
 # . fai-wrapper # ignore error that FAI is not set, it is not needed for SPECIAL_DISK purposes.
 # fai-setclass FSF
 # export SPECIAL_DISK=/dev/sde
 # export DISTRO=trisquelecne # not actually used
-# ./partition.DEFAULT
+# . ./partition.DEFAULT
 #
 # ## cryptsetup wont take within a pipeline
 # mapfile -t lines < <(awk '! /swap/ {print $2,$1}' /tmp/fai/crypttab )
@@ -68,21 +67,25 @@ fi
 ## potentially useful later:
 # sed 's#/root/keyscript,#decrypt_keyctl,#;s/$/,noauto/' /tmp/fai/crypttab >/etc/crypttab
 #
-## environment variables:
+##### environment variables:
 #
 # HOSTNAME: if demohost, we set the luks password to just
 # 'x'. Used in various other ways too.
 #
 # SPECIAL_DISK: For use outside of fai. A base disk name like
 # /dev/sdk. If set, we just cryptsetup and partition this one disk then
-# exit. This is useful for partitioning a disk in preparation to replace
-# a failed or failing disk from a raid10 array. This also sets REPARTITION.
+# exit. It creates a single lvm pv/vg/lv called "data". If this is
+# partitioning intended to go into a root filesystem, you can modify the
+# script to change that, or run commands manually afterwards. This also
+# sets REPARTITION.
 #
-# DISTRO: if not set, derived from VOL_... variable in a switch below.
+# DISTRO: if not set, derived from VOL_... variable in a switch.
+# Required except for mkroot2, mkroot2tab, or SPECIAL_DISK.
 #
-# classes:
+##### classes:
 #
-# FSF|IANK: what kind of partitioning we want to do.
+# FSF|IANK: what kind of partitioning we want to do. Required anytime we
+# do partitioning.
 #
 # REPARTITION: forces repartitioning even if we detect the proper amount
 # of partitions already exist.
@@ -854,7 +857,7 @@ if [[ ! $DISTRO ]]; then
     DISTRO=trisquelaramo
   elif ifclass VOL_ECNE; then
     DISTRO=trisquelecne
-  elif $mkroot2 || $mkroot2tab; then
+  elif $mkroot2 || $mkroot2tab || [[ $SPECIAL_DISK ]]; then
     :
   else
     echo "PARTITIONER ERROR: no distro class/var set" >&2
@@ -897,7 +900,7 @@ elif $mktab; then
   exit 0
 else
   mktab
-  if ! fsf && [[ ! $SPECIAL_DISK ]]; then
+  if ! fsf; then
     getluks
   fi
 fi