Skip to content

Instantly share code, notes, and snippets.

@nicholasc
Last active May 20, 2022 20:40
Show Gist options
  • Save nicholasc/02a1150f73af3d0dda4497cfb25de0d1 to your computer and use it in GitHub Desktop.
Save nicholasc/02a1150f73af3d0dda4497cfb25de0d1 to your computer and use it in GitHub Desktop.
A development-centric and minimalist Arch-linux installation script.
#!/usr/bin/env bash
echo -ne "
░█████╗░██╗░░██╗░█████╗░██████╗░██████╗░░██████╗
██╔══██╗██║░░██║██╔══██╗██╔══██╗██╔══██╗██╔════╝
██║░░╚═╝███████║███████║██████╔╝██████╦╝╚█████╗░
██║░░██╗██╔══██║██╔══██║██╔══██╗██╔══██╗░╚═══██╗
╚█████╔╝██║░░██║██║░░██║██║░░██║██████╦╝██████╔╝
░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═════╝░
v0.1.0
"
# prepare the system
pacman -Sy --noconfirm --needed
timedatectl set-ntp true
echo -ne "
+----------------------------------------------+
| Partitioning |
+----------------------------------------------+
"
# unmount all devices
umount -A --recursive /mnt
# wipe the disk & create new partitions
dd if=/dev/zero of=${DISK} bs=512 count=1 conv=notrunc
parted ${DISK} -- mklabel gpt
parted ${DISK} -- mkpart boot 1MiB 100MiB
parted ${DISK} -- mkpart arch 100MiB 100%
parted ${DISK} -- set 1 boot on
# determine the partition names based on the disk type
if [[ "${DISK}" =~ "nvme" ]]; then
p1=${DISK}p1
p2=${DISK}p2
else
p1=${DISK}2
p2=${DISK}3
fi
# format and mount the partitions
mkfs.fat -F 32 ${p1}
mkfs.ext4 ${p2}
mount ${p2} /mnt
mount --mkdir ${p1} /mnt/boot
echo -ne "
+----------------------------------------------+
| Installing base system |
+----------------------------------------------+
"
# install the base system
pacstrap /mnt base base-devel linux linux-firmware refind intel-ucode
pacstrap /mnt git zsh networkmanager dhclient
# define the fstab entries by label
genfstab -L /mnt >> /mnt/etc/fstab
# loggin to the root partition
arch-chroot /mnt
# configure time, language & hostname
ln -sf /usr/share/zoneinfo/America/Montreal /etc/localtime
hwclock --systohc
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "uss-enterprise" > /etc/hostname
# configure bootloader
refind-install
sed -i '1,2d' /boot/refind_linux.conf # remove install iso entries
sed -i 's/"$/ initrd=\\intel-ucode.img initrd=\\initramfs-linux.img"/' /boot/refind_linux.conf # load microcode kernel
mkdir /boot/etc && cp /etc/os-release /boot/etc
# install bootloader team
mkdir /boot/EFI/refind/themes
git clone https://github.com/nicholasc/rEFInd-minimal /boot/EFI/refind/themes/rEFInd-minimal
echo -ne "
include themes/rEFInd-minimal/theme.conf" >> /boot/EFI/refind/refind.conf
pacman -R refind --noconfirm
# enable networking
systemctl enable --now NetworkManager
# add sudo no password rights
sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers
sed -i 's/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers
# enable multilib
sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf
# create user
useradd -m -G wheel -s /bin/zsh $USERNAME
echo "$USERNAME:$PASSWORD" | chpasswd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment