-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·171 lines (140 loc) · 4.8 KB
/
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# This will install Arch Linux for an EFI system with the gnome desktop environment
# For reference:
# https://wiki.archlinux.org/index.php/installation_guide
# https://www.youtube.com/watch?v=iF7Y8IH5A3M
# User Input ##################################################################
# Internet Connection
if !(ping -c 2 google.com > /dev/null)
then
echo "Please connect to the internet before running this script"
exit
fi
# Inform user
read -p "PLEASE DO NOT MAKE TYPOS BECAUSE THIS SCRIPT ASSUMES ALL USER INPUT IS CORRECT (press enter when understood)" confirm
pacman -Syu --noconfirm pacman-contrib
# Select the drive to install arch on
lsblk
echo -e
read -p "Drive to install arch linux on: " drive
read -p "Is this drive a ssd (y/n): " ssd
export ssd
read -p "Does this machine have an intel cpu (y/n): " intelCPU
export intelCPU
# Swap space size
read -p "Swap space (y/n): " swapChoice
if [ "$swapChoice" == "y" ] || [ "$swapChoice" == "Y" ]
then
read -p "Swap space size in terms of GiB (Ex: 8): " swapSpace
fi
read -p "Does this have intel graphics and nvidia (y/n): " nvidiaCard
export nvidiaCard
# Enter Location
ls /usr/share/zoneinfo
read -p "Enter Location (As listed): " loc1
location=$loc1
if [ -d /usr/share/zoneinfo/$loc ]
then
ls /usr/share/zoneinfo/$loc1
read -p "Enter Location (As listed): " loc2
location=/usr/share/zoneinfo/${loc1}/$loc2
fi
export location
# Enter username
read -p "Username: " username
export username
# Enter hostname
read -p "Hostname: " hostname
export hostname
# Instalation #################################################################
# Disk Partition with LVM on LUKS with dm-crypt #######
# https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_entire_system#LVM_on_LUKS
# First Parition: EFI
# Second Partition: Encrpted partition
# Clear partition table
(
echo "o" # clear
echo "Y" # confirm
echo "w" # write changes
echo "Y" # confirm
) | gdisk /dev/$drive > /dev/null
# EFI
(
echo "n" # new partition
echo # default partition number
echo # default storage start point
echo "+512MiB" # size
echo "EF00" # hex code
echo "w" # write changes
echo "Y" # confirm
) | gdisk /dev/$drive > /dev/null
# Encrypted partition
(
echo "n" # new patition
echo # default partition number
echo # default storage start point
echo # max size
echo # default hex code
echo "w" # write changes
echo "Y" # confirm
) | gdisk /dev/$drive > /dev/null
# Use lsblk to find the partition IDs
bootPartitionID=$(lsblk | grep $drive | sed -n 2p | grep $drive \
| cut -d" " -f1 | sed "s/[^0-9a-zA-Z]//g")
encryptedPartitionID=$(lsblk | grep $drive | sed -n 3p | grep $drive \
| cut -d" " -f1 | sed "s/[^0-9a-zA-Z]//g")
export encryptedPartitionID
# Encrpt it
echo $'\n\n\n\n\n'
echo 'YOU ARE NOW BEING PROMPTED TO SET YOUR PASSWORD FOR THE DISK ENCRYPTION!!!!'
echo
cryptsetup luksFormat --type luks2 /dev/$encryptedPartitionID
echo $'\n\n\n\n\n'
echo 'YOU ARE NOW BEING PROMPTED TO ENTER YOUR PASSWORD FOR THE DISK ENCRYPTION!!!!'
echo
cryptsetup open /dev/$encryptedPartitionID encryptedVol
# Create the root and swap if requested
pvcreate /dev/mapper/encryptedVol
vgcreate vol /dev/mapper/encryptedVol
if [ "$swapChoice" == "y" ] || [ "$swapChoice" == "Y" ]
then
lvcreate -L ${swapSpace}G vol -n swap
mkswap /dev/mapper/vol-swap
fi
lvcreate -l 100%FREE vol -n root
# Format the partitions and mount
mkfs.ext4 /dev/mapper/vol-root
mkfs.fat -F32 /dev/$bootPartitionID
mount /dev/mapper/vol-root /mnt
mkdir /mnt/boot
mount /dev/$bootPartitionID /mnt/boot
# Swap if the user wanted one
if [ "$swapChoice" == "y" ] || [ "$swapChoice" == "Y" ]
then
swapon /dev/mapper/vol-swap
fi
# Set up the mirrors for downloads #######
echo $'\n\n\n\n\n'
echo "THERE MAY BE NO OUTPUT FOR AWHILE DUE TO GENERATING A MIRRORLIST AND THIS TAKES SOME TIME"
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
sed -i 's/^#Server/Server/g' /etc/pacman.d/mirrorlist.backup
rankmirrors -n 10 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
rm /etc/pacman.d/mirrorlist.backup
# Install base system
pacstrap /mnt base base-devel
# Generate fstab for system configuration #######
genfstab -U /mnt >> /mnt/etc/fstab
# Run personalize.sh to share variables collected in this script and download
# necessary files
wget -O rootPersonalize.sh \
https://raw.githubusercontent.com/ThatGuyNamedTim/ArchLinuxInstall/master/rootPersonalize.sh
mv rootPersonalize.sh /mnt
arch-chroot /mnt chmod +x ./rootPersonalize.sh
wget -O powertopUSB.service \
https://raw.githubusercontent.com/ThatGuyNamedTim/ArchLinuxInstall/master/powertopUSB.service
mv powertopUSB.service /mnt
wget -O powertopUSB \
https://raw.githubusercontent.com/ThatGuyNamedTim/ArchLinuxInstall/master/powertopUSB
mv powertopUSB /mnt
arch-chroot /mnt ./rootPersonalize.sh
rm /mnt/rootPersonalize.sh