2019-05-27 11:45:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-05-27 17:55:16 +02:00
|
|
|
# install parameters
|
|
|
|
# the storage device on which arch linux shall be installed
|
|
|
|
storage_device='/dev/sda'
|
2019-05-27 14:25:25 +00:00
|
|
|
|
2019-05-27 17:55:16 +02:00
|
|
|
# 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'
|
2019-05-27 14:30:21 +00:00
|
|
|
|
2019-05-27 14:25:25 +00:00
|
|
|
# make command silent
|
|
|
|
s() {
|
|
|
|
$* >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2019-05-27 14:30:21 +00:00
|
|
|
|
|
|
|
echo "checking internet connection"
|
2019-05-27 14:25:25 +00:00
|
|
|
s ping -c1 archlinux.org
|
|
|
|
if [[ "$?" -ne 0 ]]; then
|
|
|
|
echo "internet connection needed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-27 14:30:21 +00:00
|
|
|
echo "determining boot mode"
|
2019-05-27 14:25:25 +00:00
|
|
|
if [[ ! "$boot_mode" ]]; then
|
|
|
|
s ls /sys/firmware/efi/efivars
|
|
|
|
if [[ "$?" -eq 0 ]]; then
|
|
|
|
boot_mode='efi'
|
|
|
|
else
|
|
|
|
boot_mode='bios'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-05-27 14:30:21 +00:00
|
|
|
echo "updating system clock"
|
2019-05-27 14:25:25 +00:00
|
|
|
s timedatectl set-ntp true
|
|
|
|
|
2019-05-27 14:30:21 +00:00
|
|
|
echo "creating partitions"
|
2019-05-27 14:25:25 +00:00
|
|
|
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
|
2019-07-15 18:28:59 +02:00
|
|
|
|
|
|
|
echo "chrooting into arch"
|
|
|
|
s arch-chroot /mnt
|
|
|
|
|
|
|
|
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
|
|
|
|
hwclock --systohc
|
|
|
|
sed -i 's/#de_DE\.UTF-8/de_DE.UTF-8/g' /etc/locale.gen
|
|
|
|
locale-gen
|
|
|
|
echo "LANG=de_DE.UTF-8" > /etc/locale.conf
|
|
|
|
echo "KEYMAP=de-latin1" > /etc/vconsole.conf
|
|
|
|
echo "motop" > /etc/hostname
|
|
|
|
echo "# Static table lookup for hostnames.\n"`
|
|
|
|
`"# See hosts(5) for details.\n"`
|
|
|
|
`"127.0.0.1 motop\n"`
|
|
|
|
`"::1 motop\n"`
|
|
|
|
`"127.0.1.1 motop.localdomain motop" > /etc/hosts
|
|
|
|
sed -i 's/FILES=()/FILES=(\/luks.key)/g' /etc/mkinitcpio.conf
|
|
|
|
|