archinstall/prep-BTRFS-UEFI-Encrypted.sh

73 lines
2.3 KiB
Bash
Raw Normal View History

2023-03-29 08:16:21 +00:00
#!/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
2023-03-01 15:19:54 +00:00
localectl set-keymap de-latin1-nodeadkeys
timedatectl set-timezone Europe/Berlin
timedatectl set-ntp yes
2023-04-20 12:20:30 +00:00
lsblk
echo "-------------------------------------"
2023-04-02 18:52:09 +00:00
echo "Choose Device (Defaults to /dev/sda):"
echo "1) /dev/sda 2) /dev/vda 3) Other Path"
2023-03-29 15:25:44 +00:00
read -r choise
2023-04-02 18:52:09 +00:00
: "${choise:=1}"
2023-03-29 15:25:44 +00:00
if [ "$choise" == 1 ];then
2023-03-29 08:16:21 +00:00
path="/dev/sda"
2023-03-29 15:25:44 +00:00
elif [ "$choise" == 2 ];then
2023-03-29 08:16:21 +00:00
path="/dev/vda"
2023-03-29 15:25:44 +00:00
elif [ "$choise" == 3 ];then
read -r -p "Enter Device-Path: " path
2023-03-29 08:16:21 +00:00
else
echo "Path not recognized, aborting"
exit 1
fi
2023-04-02 18:52:09 +00:00
echo "Install Device: ${path}"
part1="${path}"1
part2="${path}"2
2023-03-29 08:16:21 +00:00
2023-04-02 18:52:09 +00:00
read -r -p "Name for the cryptrootdevice (defaults to cryptroot): " cryptrootname
: "${cryptrootname:=cryptroot}"
echo "The cryptrootdevice will be named: ${cryptrootname}"
2023-03-29 08:16:21 +00:00
2023-04-02 18:52:09 +00:00
parted --script "${path}" \
2023-03-29 08:22:36 +00:00
mklabel gpt \
2023-03-01 15:19:54 +00:00
mkpart "efi" fat32 1MiB 501MiB \
set 1 esp on \
mkpart "root" btrfs 501MiB 100%
2023-04-02 18:52:09 +00:00
mkfs.vfat "${part1}" -n EFI
cryptsetup --cipher aes-xts-plain64 --hash sha512 --use-random --verify-passphrase luksFormat "${part2}"
2023-03-01 15:19:54 +00:00
2023-04-02 18:52:09 +00:00
cryptsetup luksOpen "${part2}" "${cryptrootname}"
2023-03-01 15:19:54 +00:00
2023-04-02 18:52:09 +00:00
mkfs.btrfs "/dev/mapper/${cryptrootname}" -L arch
2023-03-01 15:19:54 +00:00
2023-04-02 18:52:09 +00:00
mount "/dev/mapper/${cryptrootname}" /mnt
2023-03-29 15:25:44 +00:00
cd /mnt || exit 1
2023-03-01 15:19:54 +00:00
btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @var
btrfs subvolume create @log
btrfs subvolume create @cache
2023-03-29 15:25:44 +00:00
cd ~ || exit 1
2023-03-01 15:19:54 +00:00
umount -R /mnt
2023-04-02 18:52:09 +00:00
mount -o noatime,compress=zstd,space_cache=v2,discard=async,subvol=@ "/dev/mapper/${cryptrootname}" /mnt
2023-03-01 15:19:54 +00:00
mkdir -p /mnt/{home,boot,var}
2023-04-02 18:52:09 +00:00
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
2023-03-01 15:19:54 +00:00
mkdir -p /mnt/var/{cache,log}
2023-04-02 18:52:09 +00:00
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
2023-03-01 15:19:54 +00:00
2023-04-02 18:52:09 +00:00
mount "${part1}" /mnt/boot
2023-03-01 15:19:54 +00:00
2023-03-29 13:23:40 +00:00
pacstrap /mnt base linux-firmware vim git btrfs-progs
2023-03-01 15:22:19 +00:00
genfstab -U /mnt >> /mnt/etc/fstab
ln -sf /run/systemd/resolve/stub-resolv.conf /mnt/etc/resolv.conf
arch-chroot /mnt