From 593c7e9993e4f2110846f869f468c4247a349700 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 19 Feb 2016 23:27:53 -0800 Subject: [PATCH] fix arch install with new partition scheme --- arch-init | 18 +++++++++++++----- arch-init-chroot | 6 +++--- fai-revm | 8 +++----- fai/config/hooks/partition.DEFAULT | 14 +++++++++++--- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/arch-init b/arch-init index 28ffe37..f5a6687 100755 --- a/arch-init +++ b/arch-init @@ -43,6 +43,7 @@ fi curl -s 'https://www.archlinux.org/mirrorlist/?country=US&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' | sed -r 's/^[ #]*(Server *=)/\1/' >> /etc/pacman.d/mirrorlist +# export class vars with CLASS_ in front to avoid name colissions. ifclass() { local var=${1/#/CLASS_} [[ $hostname == $1 || ${!var} ]] @@ -51,21 +52,24 @@ export -f ifclass for x in $(bash 50-host-classes); do export CLASS_$x=true done - +export CLASS_TWO_DISK=true export LUKS_DIR=/root/luks export HOSTNAME=$hostname chmod +x partition.DEFAULT ./partition.DEFAULT # arch doesn't need crypttab entries for initramfs crypt partititions +export rootn=1 +export bootn=3 +export swapn=2 sed -ri '/^crypt_dev/d' /tmp/fai/crypttab -mount -o subvol=/root /dev/mapper/crypt_dev_?da3 /mnt +mount -o subvol=/root /dev/mapper/crypt_dev_?da$rootn /mnt mkdir -p /mnt/{q,home} -mount -o subvol=/q /dev/mapper/crypt_dev_?da3 /mnt/q -mount -o subvol=/home /dev/mapper/crypt_dev_?da3 /mnt/home +mount -o subvol=/q /dev/mapper/crypt_dev_?da$rootn /mnt/q +mount -o subvol=/home /dev/mapper/crypt_dev_?da$rootn /mnt/home mkdir -p /mnt/etc cp /tmp/fai/{fstab,crypttab} /mnt/etc mkdir -p /mnt/boot -mount /dev/?da1 /mnt/boot +mount /dev/?da$bootn /mnt/boot # https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption#Keyfiles cp /root/luks/host-$hostname /mnt/crypto_keyfile.bin @@ -121,7 +125,11 @@ UUID=dd67766f-93c5-4ce3-9877-a1d9841dd4a4 none swap sw 0 0 EOF ;; *) + echo "$0: first fstab:" + cat /mnt/etc/fstab genfstab -p /mnt > /mnt/etc/fstab + echo "$0: 2nd fstab:" + cat /mnt/etc/fstab cp -r .ssh /mnt/root cp -r /root/distro-install-common /mnt/root ;;& diff --git a/arch-init-chroot b/arch-init-chroot index 53a2b94..e4dcb41 100755 --- a/arch-init-chroot +++ b/arch-init-chroot @@ -56,14 +56,14 @@ if [[ $hostname == x2 || $hostname == demohost ]]; then # but, if you are using your own fstab, it seems you just give it a name, # which will be the crypt device name under /dev/mapper/ # https://wiki.archlinux.org/index.php/GRUB#Additional_arguments - crypt_dev=(/dev/?da3) + crypt_dev=(/dev/?da$rootn) crypt_name=crypt_dev_${crypt_dev##/dev/} k_args=( cryptdevice=$crypt_dev:$crypt_name:allow-discards root=/dev/mapper/$crypt_name - resume=${crypt_dev%3}2 + resume=${crypt_dev%[0-9]}$swapn ) - crypt_mapper_devs=(/dev/mapper/crypt_dev_?d[a-z]3) + crypt_mapper_devs=(/dev/mapper/crypt_dev_?d[a-z]$rootn) keyfile_vars=() for ((i=1; i < ${#crypt_mapper_devs[@]}; i++)); do ((i!=1)) || dup_keys=(" ") diff --git a/fai-revm b/fai-revm index 79b54a2..3b1b514 100755 --- a/fai-revm +++ b/fai-revm @@ -15,18 +15,16 @@ script_dir=$(dirname $(readlink -f "$BASH_SOURCE")) if [[ $script_dir == /a/bin/* ]]; then rm -rf /a/tmp/fai2 - cp -r /a/bin/fai /a/tmp/fai2 - exec /a/tmp/fai2/fai-revm "$@" + cp -ar /a/bin/fai /a/tmp/fai2 + exec /a/tmp/fai2/${BASH_SOURCE##*/} "$@" fi -cd $(dirname $(readlink -f "$BASH_SOURCE")) +cd $script_dir new_disk=false [[ ! $1 ]] || new_disk=true -cd $(dirname $(readlink -f "$BASH_SOURCE")) - if [[ $0 == *arch-revm ]]; then # via osinfo-query os. guessing arch is closest to latest fedora. variant=fedora22 diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index adb7b62..89ae1e4 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -36,7 +36,7 @@ fi ##### end configuration -bpart() { +bpart() { # btrfs a partition dev_n=$1 case ${#@} in [1-3]) mkfs.btrfs -f $@ ;; @@ -88,7 +88,7 @@ swap_mib=$(( $(grep ^MemTotal: /proc/meminfo | \ # fully 1MiB unit partitions for easy resizing of the last partition. # Otherwise we would pass in -0 for the end argument for the last partition. disk_mib=$(( $(parted -m ${devs[0]} unit MiB print | \ - sed -nr "s#^${devs[0]}:([0-9]+).*#\1#p") - 1)) + sed -nr "s#^${devs[0]}:([0-9]+).*#\1#p") - 1)) root_end=$(( disk_mib - swap_mib - boot_mib )) swap_end=$(( root_end + swap_mib)) @@ -96,7 +96,15 @@ mkdir -p /tmp/fai shopt -s nullglob if $partition; then for dev in ${devs[@]}; do - for x in $dev[0-9]; do wipefs -a $x; done + for x in $dev[0-9]; do + count_down=10 + # wipefs has failed, manual run works, google suggests timing issue + while ! wipefs -a $x; do + sleep 2 + count_down=$((count_down - 1)) + (( count_down > 0 )) || exit 1 + done + done done for dev in ${devs[@]}; do parted -s $dev mklabel gpt -- 2.30.2