This repository was archived by the owner on Jun 12, 2025. It is now read-only.
forked from gjpin/arch-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_arch_install.sh
More file actions
144 lines (110 loc) · 3.85 KB
/
1_arch_install.sh
File metadata and controls
144 lines (110 loc) · 3.85 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
#!/bin/bash
root_password=""
hostname=""
user_name=""
user_password=""
continent_city="" #Europe/Rome
keymap="" #it
#swap_size="16" #add swap file creation
echo "Updating system clock"
timedatectl set-ntp true
echo "Creating partition tables"
printf "n\n1\n2048\n+512M\nef00\nw\ny\n" | gdisk /dev/nvme0n1 # /boot EFI (512 MB)
printf "n\n2\n\n+100G\n8300\nw\ny\n" | gdisk /dev/nvme0n1 # / LINUX FILESYSTEM (100 GB)
printf "n\n3\n\n\n8300\nw\ny\n" | gdisk /dev/nvme0n1 # /home LINUX FILESYSTEM (remaining space)
echo "Building EFI filesystem"
yes | mkfs.fat -F32 /dev/nvme0n1p1
yes | mkfs.ext4 /dev/nvme0n1p2
yes | mkfs.ext4 /dev/nvme0n1p3
echo "Mounting partitions"
mount /dev/nvme0n1p2 /mnt
mkdir /mnt/boot
mkdir /mnt/home
mount /dev/nvme0n1p1 /mnt/boot
mount /dev/nvme0n1p3 /mnt/home
echo "Installing Arch Linux"
yes '' | pacstrap /mnt base base-devel linux linux-headers linux-firmware amd-ucode mesa networkmanager wget reflector
echo "Generating fstab"
genfstab -U /mnt >> /mnt/etc/fstab
echo "Configuring new system"
arch-chroot /mnt /bin/bash <<EOF
echo "Setting system clock"
ln -fs /usr/share/zoneinfo/$continent_city /etc/localtime
hwclock --systohc --localtime
echo "Setting locales"
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
locale-gen
echo "Setting keyboard layout"
echo "KEYMAP=$keymap" >> /etc/vconsole.conf
echo "Setting hostname"
echo $hostname > /etc/hostname
echo "Setting root password"
echo -en "$root_password\n$root_password" | passwd
echo "Creating new user"
useradd -m -G wheel -s /bin/bash $user_name
usermod -a -G video $user_name
echo -en "$user_password\n$user_password" | passwd $user_name
echo "Generating initramfs"
sed -i 's/^HOOKS.*/HOOKS=(base udev keyboard autodetect modconf block keymap resume filesystems fsck)/' /etc/mkinitcpio.conf
sed -i 's/^MODULES.*/MODULES=(amdgpu)/' /etc/mkinitcpio.conf
mkinitcpio -p linux
echo "Setting up systemd-boot"
bootctl --path=/boot install
mkdir -p /boot/loader/
touch /boot/loader/loader.conf
tee -a /boot/loader/loader.conf << END
default arch
timeout 1
editor 0
END
mkdir -p /boot/loader/entries/
touch /boot/loader/entries/arch.conf
tee -a /boot/loader/entries/arch.conf << END
title ArchLinux
linux /vmlinuz-linux
initrd /amd-ucode.img
initrd /initramfs-linux.img
options root=/dev/nvme0n1p2 vga=current ivrs_ioapic[4]=00:14.0 ivrs_ioapic[5]=00:00.2 iommu=pt idle=nomwait acpi_enforce_resources=lax scsi_mod.use_blk_mq=1 amdgpu.gpu_recovery=1 quiet rw
END
echo "Setting up Pacman hook for automatic systemd-boot updates"
mkdir -p /etc/pacman.d/hooks/
touch /etc/pacman.d/hooks/systemd-boot.hook
tee -a /etc/pacman.d/hooks/systemd-boot.hook << END
[Trigger]
Type = Package
Operation = Upgrade
Target = systemd
[Action]
Description = Updating systemd-boot
When = PostTransaction
Exec = /usr/bin/bootctl update
END
echo "Updating mirrors list"
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.BAK
reflector --latest 200 --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
touch /etc/pacman.d/hooks/mirrors-update.hook
tee -a /etc/pacman.d/hooks/mirrors-update.hook << END
[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist
[Action]
Description = Updating pacman-mirrorlist with reflector
When = PostTransaction
Depends = reflector
Exec = /bin/sh -c "reflector --latest 200 --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist"
END
echo "Enabling periodic TRIM"
systemctl enable fstrim.timer
echo "Enabling NetworkManager"
systemctl enable NetworkManager
echo "Enabling suspend and hibernate"
sed -i 's/#HandlePowerKey=poweroff/HandlePowerKey=hibernate/g' /etc/systemd/logind.conf
sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=suspend/g' /etc/systemd/logind.conf
echo "Adding user as a sudoer"
echo '%wheel ALL=(ALL) ALL' | EDITOR='tee -a' visudo
EOF
umount -R /mnt
swapoff -a
echo "ArchLinux is ready. You can reboot now!"