-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallArchLinuxRoot.sh
More file actions
executable file
·170 lines (148 loc) · 4.15 KB
/
InstallArchLinuxRoot.sh
File metadata and controls
executable file
·170 lines (148 loc) · 4.15 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
158
159
160
161
162
163
164
165
166
167
168
169
170
#! /bin/bash
source Utils.sh
Disk="/dev/sda"
LFS="/mnt/lfs"
# =====================================||===================================== #
# #
# Disk Partioning #
# #
# ===============ft_linux==============||==============©Othello=============== #
CreateNewPartioning()
{
# Quick clear to ensure script functions as expected
FdiskCmd="";
AddToFdiskCmd "o" "n" "p" "" "" "y" "w";
fdisk ${Disk} &> /dev/null <<EOF
${FdiskCmd}
EOF
FdiskCmd="";
# Create a new empty MBR (DOS) partition table
AddToFdiskCmd "o";
# Add new Primary Partitions (max 3)
AddToFdiskCmd "n" "p" "1" "" "+1GB"; # 1 /boot
AddToFdiskCmd "n" "p" "2" "" "+4GB"; # 2 swap
AddToFdiskCmd "n" "p" "3" "" "+30GB"; # 3 ArchLinux /mnt
# Add Extended Partition (max 1, allows for logical partitions)
AddToFdiskCmd "n" "e" "" "";
# Add Logical Partitions
AddToFdiskCmd "n" "" "-250GB"; # 5 /mnt/lfs
AddToFdiskCmd "n" "" "+50GB"; # 6 /mnt/lfs/home
AddToFdiskCmd "n" "" "+50GB"; # 7 /mnt/lfs/usr/src
AddToFdiskCmd "n" "" "+10GB"; # 8 /mnt/lfs/opt
# Make Bootable
AddToFdiskCmd "a" "1"; # 1
# Set Types
AddToFdiskCmd "type" "1" "83"; # 1 Linux
AddToFdiskCmd "type" "2" "82"; # 2 Linux swap / Solaris
AddToFdiskCmd "type" "3" "83"; # 3 Linux
AddToFdiskCmd "type" "5" "83"; # 5 Linux
AddToFdiskCmd "type" "6" "83"; # 6 Linux
AddToFdiskCmd "type" "7" "83"; # 7 Linux
AddToFdiskCmd "type" "8" "83"; # 8 Linux
# Write partitions to disk
AddToFdiskCmd "w";
# Actually execute commands using fdisk
fdisk ${Disk} &> /dev/null <<EOF
${FdiskCmd}
EOF
}
AddToFdiskCmd()
{
for arg in "$@"; do
FdiskCmd="$FdiskCmd$arg
";
done
}
FormatPartitions()
{
mkfs.ext2 "${Disk}1" -L "/boot" 1> /dev/null;
mkswap "${Disk}2" -L "swap" 1> /dev/null;
mkfs.ext4 "${Disk}3" -L "/ [ArchLinux]" 1> /dev/null;
mkfs.ext4 "${Disk}5" -L "/" 1> /dev/null;
mkfs.ext4 "${Disk}6" -L "/home" 1> /dev/null;
mkfs.ext4 "${Disk}7" -L "/usr/src" 1> /dev/null;
mkfs.ext4 "${Disk}8" -L "/opt" 1> /dev/null;
}
MountPartitions()
{
echo "makedir here"
mkdir -p "${LFS}";
echo "makedir done";
MountPartitionTo "/boot" "/boot";
# MountPartitionTo "/boot" "${LFS}/boot";
swapon "${Disk}2" 1> /dev/null;
MountPartitionTo "/ [ArchLinux]" "/mnt";
MountPartitionTo "/" "${LFS}";
MountPartitionTo "/home" "${LFS}/home";
MountPartitionTo "/usr/src" "${LFS}/usr/src";
MountPartitionTo "/opt" "${LFS}/opt";
}
MountPartitionTo()
{
local Label="$1";
local MountPoint="$2";
mkdir -p "${MountPoint}" 1> /dev/null;
if ! mount | grep -q "on ${MountPoint} "; then
mount -L "${Label}" "${MountPoint}";
fi
}
# =====================================||===================================== #
# #
# Binaries #
# #
# ===============ft_linux==============||==============©Othello=============== #
InstallArchLinuxBinaries()
{
pacman -Sy --noconfirm archlinux-keyring
pacstrap /mnt base linux linux-firmware \
bash \
binutils \
bison \
coreutils \
diffutils \
findutils \
gawk \
gcc \
grep \
gzip \
m4 \
make \
patch \
perl \
python \
sed \
tar \
texinfo \
xz \
zsh \
grub \
dhcpcd \
openssh
}
# =====================================||===================================== #
# #
# Execution #
# #
# ===============ft_linux==============||==============©Othello=============== #
# Update System Clock
timedatectl set-ntp true
# Configure Partitions
EchoInfo "Create Partitions";
CreateNewPartioning;
EchoInfo "Format Partitions";
FormatPartitions;
EchoInfo "Mount Partitions";
MountPartitions;
EchoInfo "Partions:";
lsblk -o NAME,MAJ:MIN,FSUSED,SIZE,FSUSE%,TYPE,FSTYPE,LABEL,MOUNTPOINTS;
# Setup ArchLinux
EchoInfo "Installing Binaries for ArchLinux";
InstallArchLinuxBinaries;
# Generate an fstab file
genfstab -U /mnt >> /mnt/etc/fstab
# Setup ArchLinux as arch-chroot
mv InstallArchLinuxChroot.sh /mnt
cp colors.sh Utils.sh /mnt
EchoInfo "Logging in as arch-chroot. Next command needs to be run manually:"
echo "> ./InstallArchLinuxChroot.sh"
arch-chroot /mnt