X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=fai%2Fconfig%2Fhooks%2Fpartition.DEFAULT;h=9a8c8363f48defc58293384b7e5c4e552fc35cd8;hb=1a5548031efc4a1fa88ca94237eac3033cf97ef1;hp=317eb6d3b9b149069fcc3b0f8fce4c94da0ef93c;hpb=d3d495af167adba91b190e8dcb95649c34fa04c7;p=automated-distro-installer diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index 317eb6d..9a8c836 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -1,7 +1,22 @@ #!/bin/bash -x +# Copyright (C) 2016 Ian Kelling + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR # # fai's setup-storage won't do btrfs on luks, # # so we do it ourself :) @@ -168,11 +183,17 @@ bpart() { # btrfs a partition esac } -first_boot_dev=$(bootdev ${devs[0]}) +first_boot_dev=${boot_devs[0]} # keyfiles generated like: # head -c 2048 /dev/urandom | od | s dd of=/q/root/luks/host-demohost luks_dir=${LUKS_DIR:-/var/lib/fai/config/distro-install-common/luks} + +if [[ ! -e $luks_dir/host-$HOSTNAME ]]; then + echo "$0: error: no key for hostname at $luks_dir/host-$HOSTNAME" >&2 + exit 1 +fi + if ifclass tp; then lukspw=$(cat $luks_dir/traci) else @@ -191,6 +212,10 @@ swap_mib=$(( $(grep ^MemTotal: /proc/meminfo | \ awk '{print $2}') * 3/(${#devs[@]} * 2 ) / 1024 )) mkdir -p /tmp/fai +root_devs=() +for dev in ${devs[@]}; do + root_devs+=(`rootdev`) +done shopt -s nullglob if $partition; then for dev in ${devs[@]}; do @@ -277,17 +302,14 @@ for subvol in ${s[@]}; do btrfs subvolume delete /mnt/$subvol; done btrfs subvolume set-default 0 /mnt [[ ! -e /mnt/root_$DISTRO ]] || btrfs subvolume delete /mnt/root_$DISTRO - ## create subvols ## cd /mnt -for x in q home_$DISTRO root_$DISTRO; do - btrfs subvolume list . | grep "$x$" >/dev/null || btrfs subvolume create $x -done +btrfs subvolume create root_$DISTRO +[[ -e q ]] || btrfs subvolume create q chown root:1000 q - mkdir -p /mnt/root_$DISTRO/boot -for x in root/a q/a; do +for x in q/a q/i; do mkdir -p $x chown 1000:1000 $x chmod 755 $x @@ -308,15 +330,27 @@ umount /mnt ## end create subvols ## - +# note, the mount point /a seems to get automatically created somewhere cat > /tmp/fai/fstab <> /tmp/fai/fstab <<'EOF' +UUID=3f7b31cd-f299-40b4-a86b-7604282e2715 /i btrfs noatime 0 2 +EOF +fi + +if ifclass frodo; then + cat >> /tmp/fai/fstab <<'EOF' +/q/i /i none bind 0 0 +EOF +fi + swaps=() for dev in ${devs[@]}; do swaps+=(`swap-cryptname`) @@ -333,7 +367,10 @@ done #BOOT_DEVICE=\${BOOT_DEVICE:-"${devs[0]}"} # swaplist seems to do nothing. + cat >/tmp/fai/disk_var.sh <