#### begin configuration
-if ifclass VM; then
- d=vd
-else
- d=sd
-fi
-
-if ifclass TWO_DISK; then
+if ifclass TWO_DISK || ifclass demohost; then
letters=(a b)
elif ifclass ONE_DISK; then
letters=(a)
else
- exit
+ exit 1
fi
##### end configuration
-skiptask partition
+
+if ifclass VM; then
+ d=vd
+else
+ d=sd
+fi
+
+
+
+skiptask partition ||: # for running out of fai
devs=(${letters[@]/#//dev/${d}})
crypt_devs=(${letters[@]/#//dev/mapper/crypt_dev_${d}})
# keyfiles generated like:
# head -c 2048 /dev/urandom | od | s dd of=/q/root/luks/host-demohost
-luks_dir=/var/lib/fai/config/distro-install-common/luks
+luks_dir=${LUKS_DIR:-/var/lib/fai/config/distro-install-common/luks}
if ifclass tp; then
lukspw=$(cat $luks_dir/traci)
else
create_subvols() {
cd /mnt
- for x in a home root; do
+ for x in q home root; do
btrfs subvolume list . | grep "$x$" >/dev/null || btrfs subvolume create $x
done
btrfs subvolume set-default \
$(btrfs subvolume list . | grep 'root$' | awk '{print $2}') .
+ chattr -Rf +C root
cd /
umount /mnt
}
+mkdir -p /tmp/fai
shopt -s nullglob
if $partition; then
- mkdir -p /tmp/fai
for dev in ${devs[@]}; do
for x in $dev[0-9]; do wipefs -a $x; done
parted -s $dev mklabel gpt
fi
-for dev in ${devs[@]}; do
- cat >>/tmp/fai/crypttab <<EOF
-crypt_dev_${dev##/dev/}3 ${dev}3 none keyscript=/root/keyscript,discard,luks
-EOF
-done
-
-for dev in ${devs[@]}; do
- cat >>/tmp/fai/crypttab <<EOF
-swap ${dev}2 /dev/urandom swap,cipher=aes-xts-plain64,size=256,hash=ripemd160
-EOF
-done
-# this is duplicated in arch-init
cat > /tmp/fai/fstab <<EOF
$crypt / btrfs noatime,subvol=/root 0 0
-$crypt /a btrfs noatime,subvol=/a 0 0
+$crypt /q btrfs noatime,subvol=/q 0 0
$crypt /home btrfs noatime,subvol=/home 0 0
${devs[0]}1 /boot ext4 noatime 0 2
EOF
+swaps=()
+for dev in ${devs[@]}; do
+ s=crypt_swap_${dev##/dev/}2
+ swaps+=(/dev/mapper/$s)
+ cat >>/tmp/fai/crypttab <<EOF
+crypt_dev_${dev##/dev/}3 ${dev}3 none keyscript=/root/keyscript,discard,luks
+$s ${dev}2 /dev/urandom swap,cipher=aes-xts-plain64,size=256,hash=ripemd160
+EOF
+ cat >> /tmp/fai/fstab <<EOF
+/dev/mapper/$s none swap sw 0 0
+EOF
+done
+
+
+# swaplist seems to do nothing.
cat >/tmp/fai/disk_var.sh <<EOF
ROOT_PARTITION=\${ROOT_PARTITION:-$crypt}
BOOT_PARTITION=\${BOOT_PARTITION:-${devs[0]}1}
BOOT_DEVICE=\${BOOT_DEVICE:-"${devs[0]}"}
-SWAPLIST=\${SWAPLIST:-"${devs[@]/%/2}"}
+SWAPLIST=\${SWAPLIST:-"${swaps[@]}"}
EOF