75 lines
1.6 KiB
Bash
Executable File
75 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
source install.conf
|
|
|
|
# make command silent
|
|
s() {
|
|
$* >/dev/null 2>&1
|
|
}
|
|
|
|
# check for internet
|
|
s ping -c1 archlinux.org
|
|
if [[ "$?" -ne 0 ]]; then
|
|
echo "internet connection needed"
|
|
exit 1
|
|
fi
|
|
|
|
# determine efi or bios boot mode
|
|
if [[ ! "$boot_mode" ]]; then
|
|
s ls /sys/firmware/efi/efivars
|
|
if [[ "$?" -eq 0 ]]; then
|
|
echo "selected efi boot mode"
|
|
boot_mode='efi'
|
|
else
|
|
echo "selected bios boot mode"
|
|
boot_mode='bios'
|
|
fi
|
|
fi
|
|
|
|
echo "update system clock"
|
|
s timedatectl set-ntp true
|
|
|
|
echo "create 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 "creating luks partition"
|
|
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
|