#!/bin/bash # install parameters # the storage device on which arch linux shall be installed storage_device='/dev/sda' # boot mode: efi or bios, default=None the install script will determine the boot mode # boot_mode='efi' # encryption password encryption_password='barfoo' # additional packages to install base='grub efibootmgr stow tmux git vim python3 wpa_supplicant' # make command silent s() { $* >/dev/null 2>&1 } echo "checking internet connection" s ping -c1 archlinux.org if [[ "$?" -ne 0 ]]; then echo "internet connection needed" exit 1 fi echo "determining boot mode" if [[ ! "$boot_mode" ]]; then s ls /sys/firmware/efi/efivars if [[ "$?" -eq 0 ]]; then boot_mode='efi' else boot_mode='bios' fi fi echo "updating system clock" s timedatectl set-ntp true echo "creating partitions" s wipefs -af "$storage_device" if [[ "$boot_mode" == "efi" ]]; then sgdisk -n "1:2048:+1G" -t "1:EF00" "$storage_device" else sgdisk -n "1:2048:+1G" -t "1:EF02" "$storage_device" fi sgdisk -n "2:0:0" -t "2:8309" "$storage_device" echo "$encryption_password" | cryptsetup -q luksFormat --type luks1 "${storage_device}2" echo "$encryption_password" | cryptsetup -q open "${storage_device}2" lvm echo "creating lvm" s pvcreate /dev/mapper/lvm s vgcreate vg /dev/mapper/lvm s lvcreate -L 8G vg -n swap s lvcreate -l 100%FREE vg -n root echo "formatting filesystems" if [[ "$boot_mode" == "efi" ]]; then s mkfs.vfat -F32 "${storage_device}1" else s mkfs.vfat "${storage_device}1" fi s mkfs.ext4 /dev/vg/root s mkswap /dev/cg/swap echo "mounting filesystems" s mount /dev/vg/root /mnt if [[ "$boot_mode" == "efi" ]]; then s mkdir /mnt/efi s mount "${storage_device}1" /mnt/efi else s mkdir /mnt/boot s mount "${storage_device}1" /mnt/boot fi echo "installing base system" pacstrap /mnt base echo "generating fstab" s genfstab -U /mnt >> /mnt/etc/fstab