-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-arch-24a.sh
86 lines (64 loc) · 2.66 KB
/
install-arch-24a.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
#!/usr/bin/env bash
# To run the script:
# pacman -Sy git; git clone <url>; cd archstuff; ./<script>
arch_num="24" # Used in partition labeling
dev1="/dev/sdx"
dev1_boot="${dev1}n"
dev1_swap="${dev1}n"
dev1_root="${dev1}n"
btrfs_mops="noatime,discard=async,compress-force=zstd:4"
function handle_error() {
local error_code=$?
local error_line=${BASH_LINENO[0]}
local error_command=$BASH_COMMAND
echo "Error occurred on line $error_line: $error_command (exit code: $error_code)"
exit 1
}
# Set the trap for any error (non-zero exit code)
trap handle_error ERR
# Maybe an if statement that checks if arch-chroot is active, so this part is skipped in arch-chroot?
# Ensure UEFI is 64-bit x64
if [[ $(cat /sys/firmware/efi/fw_platform_size) -eq 64 ]]; then echo "UEFI is 64-bit x64";
else echo "UEFI is not 64-bit x64, checked in line $((LINENO - 1))"; exit 1
fi
ping -c 1 archlinux.org # Ensure internet connection
timedatectl # Ensure the system clock is synchronized
# Set partition types
sfdisk --part-type "$dev1" "${dev1_boot: -1}" EF # uefi
sfdisk --part-type "$dev1" "${dev1_swap: -1}" 82 # swap
sfdisk --part-type "$dev1" "${dev1_root: -1}" 83 # linux
# Format partitions
mkfs.fat -F 32 -n "ARCH${arch_num}B" "$dev1_boot"
mkswap "$dev1_swap"
mkfs.btrfs -L "arch${arch_num}r" "$dev1_root"
swapon "$dev1_swap" # Enable swap
# Make btrfs subvolumes
mount -o "$btrfs_mops" "$dev1_root" "/mnt"
subv1="subv_arch${arch_num}"
btrfs subvolume create "/mnt/${subv1}"
btrfs subvolume create "/mnt/${subv1}_snapshots"
btrfs subvolume create "/mnt/${subv1}_home"
btrfs subvolume create "/mnt/${subv1}_home_snapshots"
btrfs subvolume create "/mnt/${subv1}_var_cache_pacman_pkg"
umount "/mnt"
# Mount btrfs subvolumes
mount --mkdir -o "${btrfs_mops},subvol=${subv1}" "$dev1_root" "/mnt"
mount --mkdir -o "${btrfs_mops},subvol=${subv1}_snapshots" "$dev1_root" "/mnt/.snapshots"
mount --mkdir -o "${btrfs_mops},subvol=${subv1}_home" "$dev1_root" "/mnt/home"
mount --mkdir -o "${btrfs_mops},subvol=${subv1}_home_snapshots" "$dev1_root" "/mnt/home/.snapshots"
mount --mkdir -o "${btrfs_mops},subvol=${subv1}_var_cache_pacman_pkg" "$dev1_root" "/mnt/var/cache/pacman/pkg"
# Mount boot partition
mount --mkdir "$dev1_boot" "/mnt/boot"
# Symlink m2a/var-cache-pacman-pkg to live system's /var/cache/pacman/pkg
# which saves time downloading on repeat installs
# Change pacman.conf to enable parallel downloading
# Install packages
pacstrap -K /mnt base linux linux-firmware amd-ucode networkmanager nano git
# Generate the fstab file
genfstab -U /mnt >> /mnt/etc/fstab
# Change root into the new system
arch-chroot /mnt
ls
# While in chroot
# Enable services
#systemctl enable NetworkManager.service