archinstall/prep-BTRFS-UEFI-Encrypted.sh

73 lines
2.3 KiB
Bash

#!/bin/bash
# iwctl station wlan0 get-networks
# iwctl station wlan0 connect"<SSID>"
# ip addr
# curl -O https://git.sp-codes.de/eichehome/archinstall/raw/branch/main/prep-BTRFS-UEFI-Encrypted.sh
localectl set-keymap de-latin1-nodeadkeys
timedatectl set-timezone Europe/Berlin
timedatectl set-ntp yes
lsblk
echo "-------------------------------------"
echo "Choose Device (Defaults to /dev/sda):"
echo "1) /dev/sda 2) /dev/vda 3) Other Path"
read -r choise
: "${choise:=1}"
if [ "$choise" == 1 ];then
path="/dev/sda"
elif [ "$choise" == 2 ];then
path="/dev/vda"
elif [ "$choise" == 3 ];then
read -r -p "Enter Device-Path: " path
else
echo "Path not recognized, aborting"
exit 1
fi
echo "Install Device: ${path}"
part1="${path}"1
part2="${path}"2
read -r -p "Name for the cryptrootdevice (defaults to cryptroot): " cryptrootname
: "${cryptrootname:=cryptroot}"
echo "The cryptrootdevice will be named: ${cryptrootname}"
parted --script "${path}" \
mklabel gpt \
mkpart "efi" fat32 1MiB 501MiB \
set 1 esp on \
mkpart "root" btrfs 501MiB 100%
mkfs.vfat "${part1}" -n EFI
cryptsetup --cipher aes-xts-plain64 --hash sha512 --use-random --verify-passphrase luksFormat "${part2}"
cryptsetup luksOpen "${part2}" "${cryptrootname}"
mkfs.btrfs "/dev/mapper/${cryptrootname}" -L arch
mount "/dev/mapper/${cryptrootname}" /mnt
cd /mnt || exit 1
btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @var
btrfs subvolume create @log
btrfs subvolume create @cache
cd ~ || exit 1
umount -R /mnt
mount -o noatime,compress=zstd,space_cache=v2,discard=async,subvol=@ "/dev/mapper/${cryptrootname}" /mnt
mkdir -p /mnt/{home,boot,var}
mount -o noatime,compress=zstd,space_cache=v2,discard=async,subvol=@home "/dev/mapper/${cryptrootname}" /mnt/home
mount -o noatime,compress=zstd,space_cache=v2,discard=async,subvol=@var "/dev/mapper/${cryptrootname}" /mnt/var
mkdir -p /mnt/var/{cache,log}
mount -o noatime,compress=zstd,space_cache=v2,discard=async,subvol=@log "/dev/mapper/${cryptrootname}" /mnt/var/log
mount -o noatime,compress=zstd,space_cache=v2,discard=async,subvol=@cache "/dev/mapper/${cryptrootname}" /mnt/var/cache
mount "${part1}" /mnt/boot
pacstrap /mnt base linux-firmware vim git btrfs-progs
genfstab -U /mnt >> /mnt/etc/fstab
ln -sf /run/systemd/resolve/stub-resolv.conf /mnt/etc/resolv.conf
arch-chroot /mnt