X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=fai%2Fconfig%2Fhooks%2Fpartition.DEFAULT;h=e9cce5009a04fb20311611299064982c7cd51353;hp=ea8d2378039860719cd3e46da40f30d19d979425;hb=21353fd35096ba6786c1bae3046b763bfeac5890;hpb=e11bc15a6dd70c363602bdfe90171c2b72aca703 diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index ea8d237..e9cce50 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -74,7 +74,7 @@ skiptask partition || ! type skiptask if ! type -p devbyid; then for d in $FAI/distro-install-common \ - /a/bin/fai/fai/config/distro-install-common $FAI $PWD; do + /a/bin/fai/fai/config/distro-install-common $FAI $PWD; do [[ -d $d ]] || continue if [[ -e $d/devbyid ]]; then devbyid=$d/devbyid @@ -270,9 +270,13 @@ for dev in ${devs[@]}; do fi done +even_raid=false if ifclass RAID0 || (( ${#boot_devs[@]} == 1 )); then raid_level=0 elif ifclass RAID1 || (( ${#boot_devs[@]} <= 3 )); then + if (( ${#boot_devs[@]} == 2 )); then + even_raid=true + fi raid_level=1 else raid_level=10 @@ -406,6 +410,17 @@ if $partition; then fi ### end wipefs + + if $even_raid; then + for dev in ${devs[@]}; do + disk_mib=$(( $(parted -m $dev unit MiB print | \ + sed -nr "s#^/dev/[^:]+:([0-9]+).*#\1#p") - 1)) + if [[ ! min_disk_mib ]] || (( disk_mib < min_disk_mib )); then + min_disk_mib=$disk_mib + fi + done + fi + for dev in ${devs[@]}; do if [[ $SPECIAL_DISK ]]; then dev=$(devbyid $SPECIAL_DISK) @@ -417,8 +432,12 @@ if $partition; then # # Note: parted print error output is expected. example: # Error: /dev/vda: unrecognised disk label - disk_mib=$(( $(parted -m $dev unit MiB print | \ - sed -nr "s#^/dev/[^:]+:([0-9]+).*#\1#p") - 1)) + if $even_raid; then + disk_mib=$min_disk_mib + else + disk_mib=$(( $(parted -m $dev unit MiB print | \ + sed -nr "s#^/dev/[^:]+:([0-9]+).*#\1#p") - 1)) + fi root_end=$(( disk_mib - swap_mib - boot_mib / ${#boot_devs[@]} )) swap_end=$(( root_end + swap_mib))