-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPre-Installation.sh
69 lines (54 loc) · 1.91 KB
/
Pre-Installation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
{
echo "Pre-Installation"
# Update the system clock
timedatectl set-ntp true
# Partition the disks
parted /dev/sdb mklabel gpt
echo "mkpart ESP fat32 0% 200MiB
set 1 boot on
mkpart primary linux-swap 200MiB 4GiB
mkpart primary ext4 4GiB 100%
quit
" | parted /dev/sdb
# Set up encryption with dm-crypt and LUKS
cryptsetup luksFormat -c aes-xts-plain64 -s 512 -h sha512 -y /dev/sdb3
# Open encrypted partitions
cryptsetup luksOpen /dev/sdb3 root
# Format the partitions
mkfs.fat -F32 /dev/sdb1
mkfs.ext4 /dev/mapper/root
# Mount the partitions
mount /dev/mapper/root /mnt
mkdir /mnt/boot && mount /dev/sdb1 /mnt/boot
# Select the mirrors
pacman -Sy pacman-contrib
cp mirrorlist /etc/pacman.d/mirrorlist
# Install the base packages
pacstrap /mnt base base-devel
# Configure crypttab
SWAP="$(find -L /dev/disk/by-partuuid -samefile /dev/sdb2 | cut -d/ -f5)"
echo "swap PARTUUID=$SWAP /dev/urandom swap,noearly,cipher=aes-xts-plain64,hash=sha512,size=512" >> /mnt/etc/crypttab
# Configure fstab
SDB1="$(lsblk -rno UUID /dev/sdb1)"
cat << EOF > /mnt/etc/fstab
# <device> <dir> <type> <options> <dump> <fsck>
UUID=${SDB1} /boot vfat defaults,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 2
/dev/mapper/swap none swap defaults 0 0
/dev/mapper/root / ext4 defaults,noatime,data=ordered 0 1
tmpfs /tmp tmpfs size=4G 0 0
EOF
# Copy the setup folder to the new system
DIR="$(dirname ${BASH_SOURCE[0]})"
cp -R $DIR /mnt/arch-setup
# Change root into the new system and run Installation.sh
arch-chroot /mnt /arch-setup/Installation.sh
# Pipe all output into log file
} |& tee -a /root/Arch-Installation.log
mv /root/Arch-Installation.log /mnt/home/$(ls /mnt/home/)/
# Reboot because systemctl & localectl are not available while chroot
umount -R /mnt
cryptsetup luksClose root
echo "Reboot, login as root and run: /arch-setup/Final-Installation.sh"
read -p "Press enter to reboot..."
reboot