+devs=()
+shopt -s extglob
+for short_dev in ${short_devs[@]}; do
+ devs+=($(devbyid $short_dev))
+done
+if [[ ! ${devs[0]} ]]; then
+ echo "$0: error: failed to detect devs" >&2
+ exit 1
+fi
+
+boot_space=0
+first=false
+boot_devs=()
+for dev in ${devs[@]}; do
+ if ifclass frodo; then
+ # I ran into a machine where the bios doesn't know about some disks,
+ # so 1st stage of grub also doesn't know about them.
+ # Also, grub does not support mounting degraded btrfs as far as
+ # I can tell with some googling.
+ # From within an arch install env, I could detect them by noting
+ # their partitions were mixed with the next disk in /dev/disk/by-path,
+ # and I have mixed model disks, and I could see the 8 models which showed
+ # up in the bios, and thus see which 2 models were missing.
+ # hdparm -I /dev/sdh will give model info in linux.
+ # However, in fai on jessie, /dev/disk/by-path dir doesn't exist,
+ # and I don't see another way, so I'm hardcoding them.
+ # We still put grub on them and partition them the same, for uniformity
+ # and in case they get moved to a system that can recognize them,
+ # we just exclude them from the boot filesystem.
+ cd /dev/disk/by-id/
+ bad_disk=false
+ for id in ata-TOSHIBA_MD04ACA500_8539K4TQFS9A \
+ ata-TOSHIBA_MD04ACA500_Y5IFK6IJFS9A; do
+ if [[ $(readlink -f $id) == "$(readlink -f $dev)" ]]; then
+ bad_disk=true
+ break
+ fi
+ done
+ $bad_disk || boot_devs+=($(bootdev))
+ else
+ boot_space=$(( boot_space + $(parted -m $dev unit MiB print | \
+ sed -nr "s#^/dev/[^:]+:([0-9]+).*#\1#p") - 1))
+ boot_devs+=($(bootdev))
+ fi
+ if [[ $boot_devs && $first ]]; then
+ first_grub_extdev=$(grub_extdev)
+ first=false
+ fi
+done
+
+if ifclass RAID0 || (( ${#boot_devs[@]} == 1 )); then
+ raid_level=0
+elif ifclass RAID1 || (( ${#boot_devs[@]} <= 3 )); then
+ raid_level=1
+else
+ raid_level=10
+fi
+
+### Begin calculate boot partition space
+# due to raid duplication
+case $raid_level in
+ 1*) boot_space=$(( boot_space / 2 )) ;;
+esac
+if (( boot_space > 60000 )); then
+ # this is larger than needed for several /boot subvols,
+ # becuase I keep a minimal debian install on it for
+ # recovery needs and for doing pxe-kexec.
+ boot_mib=10000
+elif (( boot_space > 30000 )); then
+ boot_mib=$(( 5000 + (boot_space - 30000) / 2 ))
+else
+ # Small vms don't have room for /boot recovery. With 3 kernels
+ # installed, i'm using 132M on t8, so this seems like plenty of
+ # room. note: rhel 8 recomments 1g for /boot.
+ boot_mib=500
+ #
+fi
+case $raid_level in
+ 1*) boot_mib=$(( boot_mib * 2 )) ;;
+esac
+### end calculate boot partition space
+
+
+
+if [[ ! $DISTRO ]]; then
+ if ifclass VOL_STRETCH_BOOTSTRAP; then
+ DISTRO=debianstretch_bootstrap
+ elif ifclass VOL_STRETCH; then
+ DISTRO=debianstretch
+ elif ifclass VOL_BUSTER; then
+ DISTRO=debianbuster
+ elif ifclass VOL_TESTING; then
+ DISTRO=debiantesting
+ elif ifclass VOL_XENIAL; then
+ DISTRO=ubuntuxenial
+ elif ifclass VOL_BELENOS; 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
+ fi
+fi
+first_boot_dev=${boot_devs[0]}