X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;ds=sidebyside;f=arch-init-chroot;fp=arch-init-chroot;h=53a2b944f72ad2583e8d16f0aa9500f4f8633d21;hb=a4bf1d090bfbb5603bd6f2aa9f67a2e8a702d476;hp=0000000000000000000000000000000000000000;hpb=ce5290b5a6eee95cc59b5c1651d73a224c3d5bbd;p=automated-distro-installer diff --git a/arch-init-chroot b/arch-init-chroot new file mode 100755 index 0000000..53a2b94 --- /dev/null +++ b/arch-init-chroot @@ -0,0 +1,151 @@ +#!/bin/bash -x +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR + +for x in /etc/*.pacorig; do + mv $x ${x%.pacorig} +done + +echo $hostname > /etc/hostname +ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime +l=en_US.UTF-8 +echo "$l UTF-8" > /etc/locale.gen +locale-gen +echo "LANG=$l" > /etc/locale.conf +# if coming from windows, and you had to set the time, do this +# hwclock --systohc --utc + +# A password is required to access the volume: +# Command requires device and ampped name as arguments + +# If we were using btrfs raid, we supposedly would need this. +# # add btrfs as module instead of hook due to +# # https://wiki.archlinux.org/index.php/Btrfs, +# # https://bugs.archlinux.org/task/42884 +# # disabled, as with just the module, startup spammed something about +# # command takes a device name and something else. +# sed -ri '/^ *MODULES *=.*btrfs/!s/^( *MODULES *=.*)"/\1 btrfs"/' /etc/mkinitcpio.conf +# # remove extra space +# sed -ri 's/^( *MODULES *=[^"]*)" */\1"/' /etc/mkinitcpio.conf + +# https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_entire_system#Configuring_mkinitcpio_2 +# used to have lvm2 after encrypt for lvm. +for x in encrypt encrypt1 btrfs; do sed -ri -f - /etc/mkinitcpio.conf < /etc/crypttab <<'EOF' +#tmp /dev/lvm/tmp /dev/urandom tmp,cipher=aes-xts-plain64,size=256 + +# otgherwise ERROR: file not found: `fsck.btrfs' +pacman -S --noconfirm btrfs-progs + +pacman -S --noconfirm grub gptfdisk + +if [[ $hostname == x2 || $hostname == demohost ]]; then + echo "$0: fstab:" + cat /etc/fstab + # https://wiki.archlinux.org/index.php/Dm-crypt/System_configuration#Boot_loader + # if cryptdevice was lvm, it woulde be in this format, + # where x2-vg is from lvdisplay, VG Name field. + # cryptdevice=/dev/disk/by-uuid/585dff23-136f-446f-815f-01053b70c957:x2-vg + # 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_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 + ) + crypt_mapper_devs=(/dev/mapper/crypt_dev_?d[a-z]3) + keyfile_vars=() + for ((i=1; i < ${#crypt_mapper_devs[@]}; i++)); do + ((i!=1)) || dup_keys=(" ") + cp /crypto_keyfile.bin /crypto_keyfile$i.bin + dup_keys+=(/crypto_keyfile$i.bin) + base=/usr/lib/initcpio + cp $base/hooks/encrypt{,$i} + cp $base/install/encrypt{,$i} + sed -i "s/cryptdevice/cryptdevice$i/" $base/hooks/encrypt$i + sed -i "s/cryptkey/cryptkey$i/" $base/hooks/encrypt$i + crypt_name=${crypt_mapper_devs[i]#/dev/mapper/} + crypt_dev=/dev/${crypt_name#crypt_dev_} + k_args+=(cryptdevice$i=$crypt_dev:$crypt_name:allow-discards + cryptkey$i=rootfs:/crypto_keyfile$i.bin) + done + # this is the default file, otherwise you use cryptkey=device:fstype:path + sed -ri -f - /etc/mkinitcpio.conf < /etc/systemd/network/wired.network < /etc/systemd/network/br0.network < /etc/systemd/network/br0.netdev <