-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
157 lines (122 loc) · 4.63 KB
/
Copy pathinstall.sh
File metadata and controls
157 lines (122 loc) · 4.63 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env bash
set -euo pipefail
echo "=== Arch Linux Automated Installer (LUKS2 + BTRFS + Limine) ==="
lsblk -f
# ========= USER INPUT =========
read -rp "Enter target disk (e.g. /dev/nvme0n1): " DISK
read -rp "Enter username: " USERNAME
read -srp "Enter user password: " USER_PASS
echo
read -srp "Enter root password: " ROOT_PASS
echo
read -srp "Enter LUKS encryption password: " LUKS_PASS
echo
# ========= GEO-LOCATION TIMEZONE =========
echo "Detecting timezone..."
TIMEZONE=$(curl -s https://ipapi.co/timezone || echo "UTC")
echo "Using timezone: $TIMEZONE"
# ========= PARTITIONING =========
echo "--- Partitioning $DISK ---"
sgdisk --zap-all "$DISK"
parted --script "$DISK" \
mklabel gpt \
mkpart ESP fat32 1MiB 2049MiB \
set 1 esp on \
mkpart Linux btrfs 2050MiB 100%
if [[ "$DISK" =~ nvme ]]; then
BOOT="${DISK}p1"
ROOT="${DISK}p2"
else
BOOT="${DISK}1"
ROOT="${DISK}2"
fi
ESP="$BOOT"
# ========= FORMAT ESP =========
mkfs.fat -F 32 "$ESP"
# ========= ENCRYPT + BTRFS =========
echo "--- Setting up LUKS2 encrypted BTRFS partition ---"
echo -n "$LUKS_PASS" | cryptsetup luksFormat --type luks2 "$ROOT" -
echo -n "$LUKS_PASS" | cryptsetup open "$ROOT" root -
mkfs.btrfs /dev/mapper/root
mount /dev/mapper/root /mnt
for sub in @ @home @var_log @pkg; do
btrfs subvolume create "/mnt/$sub"
done
umount /mnt
# do not use mount --mkdir -o compress=zstd:1,noatime,subvol=@snapshots /dev/mapper/root /mnt/.snapshots
mount -o compress=zstd:1,noatime,subvol=@ /dev/mapper/root /mnt
mount --mkdir -o compress=zstd:1,noatime,subvol=@home /dev/mapper/root /mnt/home
mount --mkdir -o compress=zstd:1,noatime,subvol=@var_log /dev/mapper/root /mnt/var/log
mount --mkdir -o compress=zstd:1,noatime,subvol=@pkg /dev/mapper/root /mnt/var/cache/pacman/pkg
# mount --mkdir -o compress=zstd:1,noatime,subvol=@snapshots /dev/mapper/root /mnt/.snapshots
mount --mkdir "$ESP" /mnt/boot
# ========= INSTALL BASE SYSTEM =========
echo "--- Installing base system ---"
pacman -Sy --needed --noconfirm archlinux-keyring reflector
reflector --latest 20 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
pacstrap -K /mnt base base-devel linux linux-firmware btrfs-progs efibootmgr \
limine cryptsetup networkmanager reflector sudo vim intel-ucode \
dhcpcd iwd firewalld bluez bluez-utils acpid avahi rsync bash-completion \
pipewire pipewire-alsa pipewire-pulse wireplumber sof-firmware git duf
genfstab -U /mnt >>/mnt/etc/fstab
sleep 5
echo ""
echo ""
echo "CHROOT"
# ========= CHROOT CONFIGURATION =========
arch-chroot /mnt /bin/bash -e <<EOF
# --- TIMEZONE ---
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
hwclock --systohc
# --- LOCALE ---
sed -i 's/^#es_AR.UTF-8 UTF-8/es_AR.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
echo "LANG=es_AR.UTF-8" > /etc/locale.conf
echo "KEYMAP=es" > /etc/vconsole.conf
# --- HOSTNAME ---
echo "arch" > /etc/hostname
# --- ROOT PASSWORD ---
echo "root:$ROOT_PASS" | chpasswd
# --- USER SETUP ---
useradd -mG wheel $USERNAME
echo "$USERNAME:$USER_PASS" | chpasswd
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
# --- MKINITCPIO CONFIG ---
sed -i 's/^MODULES=.*/MODULES=(btrfs)/' /etc/mkinitcpio.conf
sed -i 's|^#BINARIES=.*|BINARIES=(/usr/bin/btrfs)|' /etc/mkinitcpio.conf
sed -i 's/^HOOKS=.*/HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block encrypt filesystems fsck)/' /etc/mkinitcpio.conf
mkinitcpio -P
# --- LIMINE SETUP ---
mkdir -p /boot/EFI/limine
cp /usr/share/limine/BOOTX64.EFI /boot/EFI/limine/
efibootmgr --create --disk $DISK --part 1 \
--label "Arch Linux Limine Bootloader" \
--loader '\\EFI\\limine\\BOOTX64.EFI' \
--unicode
LUKS_UUID=\$(cryptsetup luksUUID $ROOT)
cat <<LIMINECONF > /boot/EFI/limine/limine.conf
timeout: 3
/Arch Linux
protocol: linux
path: boot():/vmlinuz-linux
cmdline: quiet cryptdevice=UUID=\$LUKS_UUID:root root=/dev/mapper/root rw rootflags=subvol=@ rootfstype=btrfs
module_path: boot():/initramfs-linux.img
/Arch Linux (fallback)
protocol: linux
path: boot():/vmlinuz-linux
cmdline: quiet cryptdevice=UUID=\$LUKS_UUID:root root=/dev/mapper/root rw rootflags=subvol=@ rootfstype=btrfs
module_path: boot():/initramfs-linux-fallback.img
LIMINECONF
sleep 4
# --- ENABLE SERVICES ---
for s in NetworkManager dhcpcd iwd systemd-networkd systemd-resolved bluetooth avahi-daemon firewalld acpid reflector.timer; do
systemctl enable \$s
done
EOF
# ========= FINAL CLEANUP =========
echo "--- Cleaning up ---"
sync
sleep 2
umount -R /mnt || echo "Some mounts could not be unmounted, continuing..."
cryptsetup close root
echo "=== Installation complete! Reboot now and remove installation media. ==="