-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharchstrap.sh
75 lines (61 loc) · 2.09 KB
/
archstrap.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
#!/bin/sh
# Arch Linux installer script. EFI only!
# Parcevval @2023.
[ -z "$1" ] && printf "Usage: Provide only the drive to install to (i.e /dev/sda, see lsblk)\n\n./archstrap.sh [DRIVE]\n\n" && exit
[ ! -b "$1" ] && printf "Drive $1 is not a valid block device.\n" && exit
printf "\nThis script will erase all data on $1.\nAre you certain? (y/n): " && read CERTAIN
[ "$CERTAIN" != "y" ] && printf "Abort." && exit
disk=$1
boot=${disk}1
swap=${disk}2
root=${disk}3
home=${disk}4
# Cleanup from previous runs.
swapoff $swap
umount -R /mnt
# Partition 512 MiB for boot, 12G for swap, 50G for root and rest to home.
# Optimal alignment will change the exact size though!
set -xe
parted -s $disk mklabel gpt
parted -sa optimal $disk mkpart primary fat32 0% 512MiB
parted -sa optimal $disk mkpart primary linux-swap 512MiB 15G
parted -sa optimal $disk mkpart primary ext4 15G 70G
parted -sa optimal $disk mkpart primary ext4 70G 100%
parted -s $disk set 1 esp on
# Format the partitions.
mkfs.fat -IF32 $boot
mkswap -f $swap
mkfs.ext4 -F $root
mkfs.ext4 -F $home
# Mount the partitions.
mount $root /mnt
mount -m $boot /mnt/boot
mount -m $home /mnt/home
swapon $swap
# Packages and chroot.
pacstrap /mnt linux linux-firmware networkmanager vim base base-devel git man efibootmgr grub
genfstab -U /mnt > /mnt/etc/fstab
# Enter the system and set up basic locale, passwords and bootloader.
arch-chroot /mnt sh -c 'set -xe;
sed -i "s/^#en_US.UTF-8/en_US.UTF-8/g" /etc/locale.gen;
echo "LANG=en_US.UTF-8" > /etc/locale.conf;
locale-gen;
ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime;
hwclock --systohc;
systemctl enable NetworkManager;
echo root:123 | chpasswd;
echo "archer" > /etc/hostname;
mkdir /boot/grub;
grub-mkconfig -o /boot/grub/grub.cfg;
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB;'
# Finalize.
umount -R /mnt
set +xe
printf "
*--- Installation Complete! ---*
| |
| Username: root |
| Password: 123 |
| |
*------------------------------*
"