#!/usr/bin/env bash # This is an Archlinux installation script for my personal machine. Some notes: # # Nvidia GeForce RTX 3090 # M.2 drive mounted at /dev/nvme0n1 # # We're assuming the bootloader is already setup, so we simply reformat the main # partition. # # PROMPT FOR USERNAME AND PASSWORDS # username="" username_confirm="" password="" password_confirm="" root_password="" root_password_confirm="" while [[ $username == "" || $username != $username_confirm ]] do printf "Enter a username:\n> " read username printf "Confirm the username:\n> " read username_confirm if [[ $username != $username_confirm ]]; then printf "Those usernames don't match. " fi done while [[ $password == "" || $password != $password_confirm ]] do printf "\nEnter a password for that user:\n> " read -s password printf "\nConfirm the password:\n> " read -s password_confirm printf "\n" if [[ $password != $password_confirm ]]; then printf "Those passwords don't match. " fi done while [[ $root_password == "" || $root_password != $root_password_confirm ]] do printf "\nFinally, enter a root password:\n> " read -s root_password printf "\nConfirm the root password:\n> " read -s root_password_confirm printf "\n" if [[ $root_password != $root_password_confirm ]]; then printf "Those passwords don't match. " fi done set -x # # BASE SETUP # timedatectl set-ntp true bootPartition=/dev/nvme0n1p1 dataPartition=/dev/nvme0n1p2 # Reformat data partition mkfs.btrfs -f $dataPartition # Mount partitions mount $dataPartition /mnt mkdir /mnt/boot mount $bootPartition /mnt/boot # Get some base packages pacstrap /mnt \ base linux linux-headers \ dhcpcd bluez bluez-utils \ base-devel git gnupg openssh \ go nodejs npm cmake ctags yarn jq bash-completion \ vim wget z ripgrep \ ttf-ubuntu-font-family ttf-dejavu ttf-jetbrains-mono inter-font \ noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra \ rxvt-unicode kitty \ nvidia ffnvcodec-headers libxnvctrl nvidia-settings opencl-nvidia \ cuda cuda-tools nvtop \ xorg sx \ xfwm4 xfce4-settings picom \ i3-gaps i3lock i3status \ firefox \ # Generate fstab genfstab -U /mnt > /mnt/etc/fstab # # CHROOT SETUP # arch-chroot /mnt <<-EOS # Timezone and clock #ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime timedatectl set-timezone America/New_York hwclock --systohc # Locale sed -i '/^#en_US.UTF-8 UTF-8/s/^#//' /etc/locale.gen locale-gen echo LANG=en_US.UTF-8 > /etc/locale.conf # Hostname echo cleo > /etc/hostname # Visudo echo '%wheel ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo # Root password echo "root:$root_password" | chpasswd # Main user useradd -m -g users -G wheel $username echo "$username:$password" | chpasswd # Enable services sudo systemctl enable dhcpcd bluetooth cat <<- EOF > /boot/loader/loader.conf default arch timeout 5 editor 0 EOF # We also need to setup the entry for Arch, but we'll do it outside of this # heredoc where it's easier to do non-interactively. EOS # Get UUID of the main partition. This is the part that would be really hard # to do in a heredoc. uuid=$(grep -ioP '[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}' /mnt/etc/fstab) # Reset the main bootloader entry cat <<- EOF > /mnt/boot/loader/entries/arch.conf title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options root=UUID=$uuid rw EOF echo -e "\nWell, that went well. Remove the installation media and reboot."