Last active
July 22, 2023 13:56
-
-
Save sawntoe/fe154871391b8d3a00cba017a39eb04f to your computer and use it in GitHub Desktop.
Install Arch without ArchInstall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Arch installation script | |
# Author: sawntoe | |
# This script is intended for quick VM installation without ArchInstall. Thus, it does not create swap, and should be scripted in by the user should they want this functionality. | |
# The user should read through the script and modify it to his needs. The user should not attempt to blindly run the script. | |
# This script is also intended to be a learning tool for newbies, as it is heavily documented. This gives it an edge over archinstall, which is like a magic black box that the user doesn't understand. | |
# exit on error | |
set -e | |
# check if there is internet connection | |
ping -q -w 1 -c 1 8.8.8.8 > /dev/null | |
device=$1 # Device to install on (e.g /dev/sda) | |
hostname=$2 # Hostname of install | |
region=$3 # Region to link to /etc/localtime (e.g. Asia/Singapore) | |
locale=$4 # UTF-8 locale to set as language (e.g. en_SG.UTF-8) | |
read -s -p "Enter password: " password # Prompt user for password for root | |
# ensure device exists | |
ls $device > /dev/null | |
# deletes all partitions on device | |
wipefs -a $device | |
# partition device | |
parted $device --script mklabel gpt | |
parted $device --script mkpart primary 1MiB 128MiB | |
parted $device --script mkpart primary 128MiB 100% | |
lsblk | |
# Note: THIS WILL NOT WORK IF YOU HAVE A DEVICE LIKE nvme0n1 WHERE PARTITIONS ARE LIKE nvme0n1p1. COMMENT THESE LINES AND UNCOMMENT THE OTHER TWO | |
boot_partition=${device}1 | |
root_partition=${device}2 | |
# boot_partition=${device}p1 | |
# root_partition=${device}p2 | |
# Format partitions | |
mkfs.fat -F 32 $boot_partition | |
mkfs.ext4 $root_partition | |
# Mount partitions | |
mount $root_partition /mnt | |
mount --mkdir $boot_partition /mnt/boot/efi | |
# Rank mirrors | |
pacman -Sy --noconfirm pacman-contrib | |
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak | |
rankmirrors -n 6 /etc/pacman.d/mirrorlist.bak > /etc/pacman.d/mirrorlist | |
# bootstrap system. This can be modified | |
pacstrap -K /mnt base base-devel linux linux-firmware sof-firmware sof-tools grub efibootmgr net-tools networkmanager | |
# Generate fstab | |
genfstab -U /mnt >> /mnt/etc/fstab | |
# Chroot into system | |
arch-chroot /mnt <<EOT | |
# setup localtime and locales | |
ln -sf /usr/share/zoneinfo/$region /etc/localtime | |
hwclock --systohc | |
locale-gen | |
echo "$locale UTF8" >> /etc/locale.gen | |
echo "LANG=$locale" > /etc/locale.conf | |
locale-gen | |
# set hostname | |
echo "$hostname" > /etc/hostname | |
# set root password | |
echo "root:$password" | chpasswd | |
# allow all users of group "wheel" to execute commands as root | |
printf "\n%%wheel ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers | |
# enable NetworkManager | |
systemctl enable NetworkManager | |
# install grub | |
grub-install $boot_partition --target=x86_64-efi | |
grub-mkconfig -o /boot/grub/grub.cfg | |
# install yay | |
pacman -S --needed --noconfirm git base-devel && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si | |
exit | |
EOT | |
echo 'You are free to unmount and reboot!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment