-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharch-base-install.sh
145 lines (115 loc) · 3.32 KB
/
arch-base-install.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh
set -e
partition() {
# partitioning for EFI system
## label as gpt
parted /dev/sda mklabel gpt
## make an EFI system partition (ESP)
parted /dev/sda mkpart primary fat32 0% 300MiB
## make it the boot partition
parted /dev/sda set 1 boot on
## make the main partition fill the remaining disk space
parted /dev/sda mkpart primary xfs 300MiB 100%
# format the partitions
mkfs -t fat /dev/sda1
mkfs -t xfs /dev/sda2
}
mount_drives() {
# mount sda2
mount /dev/sda2 /mnt
# create /boot on sda2
mkdir -p /mnt/boot
# mount esp in /boot, since I boot direclty from an EFI Stub
mount /dev/sda1 /mnt/boot/
}
unmount_drives() {
umount /dev/sda1
}
base_install() {
pacman -Sy --noconfirm reflector
# take the 20 most recently updated servers and select the 10 fastest as the new mirrorlist
reflector -c DE -c CH -c AT -l 20 --fastest 10 --save /etc/pacman.d/mirrorlist
mount_drives
# install the base system
pacstrap /mnt base
# persist the fstab
genfstab -U -p /mnt > /mnt/etc/fstab
}
setup_systemd-boot() {
# setup bootloader
bootctl --path=/boot install
#create entry for bootctl
cat <<BOOTENTRY > /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=/dev/sda2 rw
BOOTENTRY
# adjust loader.cong
cat <<LOADERCONF > /boot/loader/loader.conf
default arch
timeout 4
console-mode max
editor no
LOADERCONF
}
base_setup() {
# switch into the installed system
arch-chroot /mnt
if [ -z ${new_hostname+x} ] ; then
echo "new_hostname is unset"
echo -n "enter a hostname: "
read new_hostname
fi
if [ -z ${new_default_user+x} ] ; then
echo "new_default_user is unset"
echo -n "enter the default user: "
read new_default_user
fi
# set time zone
# is that still needed? ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
# what about this? # hwclock --systohc
timedatectl set-timezone Europe/Berlin
# TODO setup eth0 network interface
# systemctl enable [email protected]
# enable de_DE.UTF-8 UFT8 locale
sed -i '/de_DE.UTF-8/s/^#//g' /etc/locale.gen
# enable en_US.UTF-8 UFT8 locale
sed -i '/en_US.UTF-8/s/^#//g' /etc/locale.gen
#generate locales
locale-gen
#set locale
localectl set-locale LANG=en_US.UTF-8
# TODO set keyboard layout to AltGr Intl?
hostnamectl set-hostname $new_hostname
cat <<HOSTSENTRIES > /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 ipv6-localhost ipv6-localhost
HOSTSENTRIES
# Set the root password:
passwd
# create default user
echo "creating user '$new_default_user'"
useradd -m -g users -G wheel -s /bin/zsh $new_default_user
passwd $new_default_user
# install sudo and zsh (as dependency, so they get "adopted" later by a metapackage)
pacman -S --noconfirm --asdeps sudo zsh
# allow members of wheel to invoke sudo
sed -i '/wheel ALL=(ALL) ALL/s/^#//g' /etc/sudoers
setup_systemd-boot
# switch to the new user
su $new_default_user
# clone this repo
git clone https://github.com/benjaminbauer/arch-install $HOME/arch-install
# install everything else
sh $HOME/arch-install/install
# exit back to root
exit
# leave chroot environment
exit
}
finish_install() {
# TODO in case of virtualbox: Change the boot order and unmount arch.iso
umount_drives
reboot
}