minor improvements
authorIan Kelling <iank@fsf.org>
Mon, 16 Feb 2026 03:59:35 +0000 (22:59 -0500)
committerIan Kelling <iank@fsf.org>
Mon, 16 Feb 2026 04:02:19 +0000 (23:02 -0500)
fai/config/hooks/partition.DEFAULT
faiserver-setup

index fc5e521a20c31cdba39c3bb186149de95c2c33cf..34abf44ca8f7053ce6b4e6a50b8b9000f73738ef 100755 (executable)
@@ -30,9 +30,10 @@ usage() {
   cat <<'EOF'
 Example of calling outside of FAI:
 
+/a/bin/fai/fai/config/hooks/partition.DEFAULT
 
+HOSTNAME=kd DISTRO=ecne /a/bin/fai/fai/config/hooks/partition.DEFAULT -s /dev/sdk -m
 
-/a/bin/fai/fai/config/hooks/partition.DEFAULT
 
 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:
@@ -59,15 +60,13 @@ Options
 -c DISK_COUNT   Meant for use with -s, the count of disks for doing swap size calculation.
 
 -d   Create data partition instead of root partition. Meant for use with -s.
+     It creates a single lvm pv/vg/lv called "data".
 
 -m   Create root/data partition with maximum size instead of the 1tb limit. Meant for use with -s.
 
 -s 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. 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.
+exit. This also sets REPARTITION.
 
 ARGS (only 0 or 1 is valid). All args are for use outside of fai.
 
@@ -85,7 +84,7 @@ environment variables:
 HOSTNAME: if demohost, we set the luks password to just
 'x'. Used in various other ways too.
 
-DISTRO: if not set, derived from VOL_... variable in a switch.
+DISTRO: Distro release codename. if not set, derived from VOL_... variable in a switch.
 Required except for mkroot2, mkroot2tab, or SPECIAL_DISK.
 
 classes:
@@ -133,8 +132,8 @@ fi
 
 
 if ! type -t ifclass &>/dev/null; then
-  echo "$0: error: install ifclass" >&2
-  exit 1
+  /b/fai/faiserver-setup --pi-only
+  type -t ifclass >/dev/null
 fi
 
 
@@ -336,7 +335,7 @@ luks-setup() {
 }
 
 mktab() {
-  fstabstd="x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s"
+  fstabstd="x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s"
 
   mkdir -p /tmp/fai
   dev=${boot_devs[0]}
@@ -357,7 +356,7 @@ EOF
   if $data_part; then
     vg=${vgs[0]}
     cat >/tmp/fai/crypttab <<EOF
-crypt-$vg-data /dev/$vg/data  /mnt/root/q/root/luks/iank  discard,luks
+crypt-$vg-data /dev/$vg/data  /mnt/root/q/root/luks/iank  nofail,discard,luks
 EOF
     cat >/tmp/fai/fstab <<EOF
 /dev/mapper/crypt-$vg-data   /mnt/dataTBD  btrfs    nofail,$fstabstd,noatime,subvolid=0$mopts  0 0
@@ -383,11 +382,11 @@ EOF
     if ! fsf; then
       cat >>/tmp/fai/crypttab <<EOF
 crypt-$vg-root /dev/$vg/root  none  keyscript=/root/keyscript,discard,luks,initramfs
-crypt-$vg-swap /dev/$vg/swap  /dev/urandom  swap,cipher=aes-xts-plain64,size=256,hash=ripemd160
+crypt-$vg-swap /dev/$vg/swap  /dev/urandom  nofail,swap,cipher=aes-xts-plain64,size=256,hash=ripemd160
 EOF
       if ! $skip_o; then
       cat >>/tmp/fai/crypttab <<EOF
-crypt-$vg-o    /dev/$vg/o     none  keyscript=/root/keyscript,discard,luks,initramfs
+crypt-$vg-o    /dev/$vg/o     none  nofail,keyscript=/root/keyscript,discard,luks,initramfs
 EOF
       fi
     fi
@@ -484,7 +483,7 @@ doroot2() {
       luks-setup /dev/$vg/root2 crypt-$vg-root2
     fi
     cat >>/mnt/root/root2-crypttab <<EOF
-crypt-$vg-root2 /dev/$vg/root2  $luks_file  discard,luks,initramfs
+crypt-$vg-root2 /dev/$vg/root2  $luks_file  nofail,discard,luks,initramfs
 EOF
   done
   if $mkroot2; then
@@ -493,8 +492,8 @@ EOF
   fi
   mkdir -p /mnt/root2 /mnt/boot2
   cat >>/mnt/root/root2-fstab <<EOF
-${root2_devs[0]} /mnt/root2  btrfs  nofail,x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s,noatime,subvolid=0$mopts  0 0
-${boot2_devs[0]} /mnt/boot2  btrfs  nofail,x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s,noatime,subvolid=0  0 0
+${root2_devs[0]} /mnt/root2  btrfs  nofail,x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s,noatime,subvolid=0$mopts  0 0
+${boot2_devs[0]} /mnt/boot2  btrfs  nofail,x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s,noatime,subvolid=0  0 0
 EOF
   exit 0
 }
index 6bf7295ef00a3aa7e9bc9638c7fb9bd181b012ad..413c86a0622df38dbd38057f40ee2745837c8530 100755 (executable)
@@ -19,10 +19,10 @@ set -e; . /usr/local/lib/bash-bear; set +e
 
 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
 
-
+base=bookworm
 usage() {
   cat <<'EOF'
-usage: faiserver-setup [-h|--help] [BASE_CODENAME] [ARCH]
+usage: faiserver-setup [-h|--help] [ARCH]
 install fai-server on the current machine
 
 Initial setup of a fai server. works on localhost.  Set's the current ip
@@ -30,10 +30,12 @@ as the tftp server. I vaguely remember that using a hostname does not
 work.  Separate from running this, faiserver needs to be setup in dns to
 point to whatever host this is run on.
 
-Default BASE_CODENAME is bookworm. Default ARCH is 64. The script expects corresponding
-$BASEFILE_DIR/${UPCASED_BASE_CODENAME}${ARCH}.tar.(zst|xz) to exist, and it must have been
-generated around the same time as the nfsroot, at least so it has the
-same kernel version.
+We install based on $base. In theory, we could use an older release, I had
+conditionals for this but decided it was a waste of time. Default ARCH
+is 64. The script expects corresponding
+$BASEFILE_DIR/${UPCASED_BASE_CODENAME}${ARCH}.tar.(zst|xz) to exist, and
+it must have been generated around the same time as the nfsroot, at
+least so it has the same kernel version.
 
 for copying and running this on a remote server,
 scp -tPrl fai SERVER:
@@ -57,21 +59,27 @@ Note: in t9, there is a bug in recent fai packages (eg 2021+), where
 EOF
   exit 0
 }
-case $1 in
-  -h|--help) usage ;;
-esac
+pi_only=false
+while [[ $1 == -* ]]; do
+  case $1 in
+    --pi-only)
+      pi_only=true
+      shift
+      ;;
+    -h|--help) usage ;;
+    *) exit 1 ;;
+  esac
+done
 
 
 e() { echo "+ $*"; "$@"; }
 
+armhf() {
+  [[ $(dpkg --print-architecture) == armhf ]]
+}
 
-base=${1:-bookworm}
-arch=${2:-64}
 
-if [[ $base == [[:upper:]] ]]; then
-  echo $0: error: use lowercase base
-  exit 1
-fi
+arch=${1:-64}
 
 basefile=$BASEFILE_DIR/${base^^}${arch^^}.tar.zst
 sed="sed -ri --follow-symlinks"
@@ -91,29 +99,18 @@ if ! type -p wget &>/dev/null; then
   apt-get install -y wget
 fi
 
-armhf() {
-  [[ $(dpkg --print-architecture) == armhf ]]
-}
 
 # fai on ubuntu only has official support using the universe repo, but newer
 # tends to have less bugs.
 wget -O - https://fai-project.org/download/fai-project.gpg | sudo dd of=/etc/apt/trusted.gpg.d/fai-project.gpg
 
 update=false
-case $base in
-  stretch|buster|bullseye|bookworm)
-    if ! grep -qFx "deb https://fai-project.org/download $base koeln" /etc/apt/sources.list.d/fai.list; then
-      update=true
-    fi
-    cat >/etc/apt/sources.list.d/fai.list <<EOF
+if ! grep -qFx "deb https://fai-project.org/download $base koeln" /etc/apt/sources.list.d/fai.list; then
+  update=true
+fi
+cat >/etc/apt/sources.list.d/fai.list <<EOF
 deb https://fai-project.org/download $base koeln
 EOF
-    ;;
-  *)
-    echo "$0: error: script needs updating for new base" >&2
-    exit 1
-    ;;
-esac
 
 f=/var/cache/apt/pkgcache.bin;
 if [[ -r $f ]]; then
@@ -129,6 +126,7 @@ if $update; then
   apt-get update
 fi
 
+
 # Relevant packages from fai-quickstart depends and fai-server recommends.
 # I especially do not wait isc-dhcp-server or an inetd. Also excludes
 # nfs-kernel-server. On an android chroot, we don\'t have nfs in the
@@ -149,6 +147,11 @@ e apt-get install -y ${pkgs[@]}
 # fai-client is already a fai-server dependency, but make sure it gets upgraded
 e apt-get install --no-install-recommends -y -o Dpkg::Options::=--no-force-confdef -o Dpkg::Options::=--force-confnew fai-server fai-client
 
+if $pi_only; then
+  exit 0
+fi
+
+
 r=http://http.us.debian.org/debian
 # like default, but scrap httpredir, and nonfree.
 # All my systems should be able to get along without nonfree
@@ -158,20 +161,9 @@ cat >/etc/fai/apt/sources.list <<EOF
 deb $r $base main contrib
 EOF
 
-### begin setup security repo ###
-case $base in
-  stretch|buster)
-    cat >>/etc/fai/apt/sources.list <<EOF
-deb http://security.debian.org/debian-security $base/updates main contrib
-EOF
-    ;;
-  *)
-    # new naming convention
-    cat >>/etc/fai/apt/sources.list <<EOF
+cat >>/etc/fai/apt/sources.list <<EOF
 deb http://security.debian.org/debian-security $base-security main contrib
 EOF
-esac
-### end setup security repo ###
 
 
 cat >>/etc/fai/apt/sources.list <<EOF
@@ -297,7 +289,7 @@ EOF
 fi
 
 rm -f /srv/fai/nfsroot/root/.ssh/known_hosts
-key=$(ssh-keyscan $keyscan_arg localhost |& grep -o "ecdsa-sha2-nistp256.*")
+key=$(ssh-keyscan localhost |& grep -o "ecdsa-sha2-nistp256.*")
 for ip in faiserver.b8.nz $(ip addr show up| grep -w '^ *inet' | awk '{print $2}'| cut -d / -f 1 | grep -vF 127.0.0.1); do
   echo "$ip $key" >>/srv/fai/nfsroot/root/.ssh/known_hosts
 done