-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patharchlinux-installer.sh
More file actions
executable file
·154 lines (126 loc) · 5.53 KB
/
archlinux-installer.sh
File metadata and controls
executable file
·154 lines (126 loc) · 5.53 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
#!/bin/bash
################################################################################
# Author : David Calvert
# Purpose : Arch Linux custom installer
# GitHub : https://github.com/dotdc/archlinux-installer
################################################################################
set -e
################################################################################
# Source variables
################################################################################
. config-variables.sh
################################################################################
# Installer
################################################################################
# Arch logo from : https://wiki.archlinux.org/title/ASCII_art
# Text generated with : https://textkool.com/en/ascii-art-generator?font=Big&text=Arch%20Installer
echo -e "${B}
-@
.##@
.####@
@#####@
. *######@ ${W} _ _____ _ _ _ ${B}
.##@o@#####@ ${W} /\ | | |_ _| | | | | | ${B}
/############@ ${W} / \ _ __ ___| |__ | | _ __ ___| |_ __ _| | | ___ _ __ ${B}
/##############@ ${W} / /\ \ | '__/ __| '_ \ | | | '_ \/ __| __/ _\` | | |/ _ \ '__|${B}
@######@**%######@ ${W} / ____ \| | | (__| | | | _| |_| | | \__ \ || (_| | | | __/ | ${B}
@######\` %#####o ${W} /_/ \_\_| \___|_| |_| |_____|_| |_|___/\__\__,_|_|_|\___|_| ${B}
@######@ ######%
-@#######h ######@.\`
/#####h**\`\` \`**%@####@
@H@*\` \`*%#@
*\` \`* ${W}"
loadkeys fr
timedatectl set-ntp true
################################################################################
# Disk partition
################################################################################
if [[ "${install_mode}" == "auto" ]] ; then
system_disk=$(sudo parted -l | awk '/Disk \//{ gsub(":","") ; print $2}')
else
echo -e "[${B}INFO${W}] Select destination disk for Arch Linux"
echo "Disk(s) available:"
parted -l | awk '/Disk \//{ gsub(":","") ; print "- \033[93m"$2"\033[0m",$3}' | column -t
read -r -p "Please enter destination disk: " system_disk
echo -e "Disk ${Y}${system_disk}${W} will be ${R}ERASED${W} !"
read -r -p "Are you sure you want to proceed? (y/n)" system_disk_format
if [[ "${system_disk_format}" != "y" ]] ; then
echo "Installation aborted!"
exit 0
fi
fi
# CREATE PARTED GUID + PARTITIONS
echo -e "[${B}INFO${W}] Format ${Y}${system_disk}${W} and create partitions"
parted "${system_disk}" mklabel gpt
parted "${system_disk}" mkpart "EFI" fat32 1MiB 301MiB
parted "${system_disk}" set 1 esp on
parted "${system_disk}" mkpart "${part_name}" ext4 301MiB 100%
# Guess partition names
if [[ "${system_disk}" =~ "/dev/sd" ]] ; then
efi_partition="${system_disk}1"
os_partition="${system_disk}2"
else
efi_partition="${system_disk}p1"
os_partition="${system_disk}p2"
fi
if [[ "${luks}" == "true" ]] ; then
# LUKS configuration
echo -e "[${B}INFO${W}] Create luks partition on ${Y}${os_partition}${W}"
cryptsetup luksFormat "${os_partition}"
echo -e "[${B}INFO${W}] Mount the luks partition as ${Y}${lvm_name}${W}"
cryptsetup open "${os_partition}" "${lvm_name}"
fi
# Create PV/VG
echo -e "[${B}INFO${W}] Create LVM Physical Volume and Volume Group"
if [[ "${luks}" == "true" ]] ; then
pvcreate "/dev/mapper/${lvm_name}"
vgcreate SYSTEM "/dev/mapper/${lvm_name}"
else
pvcreate "${os_partition}"
vgcreate SYSTEM "${os_partition}"
fi
# Create LVs
echo -e "[${B}INFO${W}] Create LVM Logical Volumes"
lvcreate -L "${lv_swap_size}" SYSTEM -n swap
lvcreate -L "${lv_root_size}" SYSTEM -n root
[[ "${create_home_fs}" == "true" ]] && lvcreate -l "${lv_home_size}" SYSTEM -n home
# Format LVs
echo -e "[${B}INFO${W}] Format LVM Logical Volumes"
mkswap /dev/SYSTEM/swap
mkfs.ext4 /dev/SYSTEM/root
[[ "${create_home_fs}" == "true" ]] && mkfs.ext4 /dev/SYSTEM/home
# Mount LVs
echo -e "[${B}INFO${W}] Mount LVM Logical Volumes"
mount /dev/SYSTEM/root /mnt
[[ "${create_home_fs}" == "true" ]] && mkdir /mnt/home
[[ "${create_home_fs}" == "true" ]] && mount /dev/SYSTEM/home /mnt/home
# Mount EFI
echo -e "[${B}INFO${W}] Mount EFI Partition"
mkdir /mnt/boot
mkfs.fat -F 32 "${efi_partition}"
mount "${efi_partition}" /mnt/boot
# Mount swap
swapon /dev/SYSTEM/swap
################################################################################
# Archlinux Installation
################################################################################
echo -e "[${B}INFO${W}] Install Arch Linux"
pacstrap /mnt --color auto base base-devel linux linux-firmware intel-ucode efibootmgr lvm2
# Generate fstab
echo -e "[${B}INFO${W}] Generate fstab"
genfstab -U /mnt >> /mnt/etc/fstab
# Copy postinstall files to /mnt chroot
echo -e "[${B}INFO${W}] Copy installation material for post-install"
cp -v archlinux-postinstall.sh /mnt/opt
cp -v archlinux-postinstall-desktop.sh /mnt/opt
cp -v config-variables.sh /mnt/opt
echo -e "\nos_partition=\"${os_partition}\"" >> /mnt/opt/config-variables.sh
echo -e "[${B}INFO${W}] Installation complete!"
echo -e "[${B}INFO${W}] Running commands from archlinux-postinstall.sh"
echo -e "[${B}INFO${W}] Please run ${Y}cd /opt${W} and ${Y}./archlinux-postinstall.sh${W} to continue"
# Run commands in chroot environment
chroot /mnt /bin/bash <<EOF
cd /opt
./archlinux-postinstall.sh
EOF
reboot