#!/bin/bash # Set mount options for disks export MNTOPTIONS ="noatime,compress=zstd,ssd,commit=120" echo "We just need to ask some questions before installing" # Get drive values for installation lsblk read -p 'Please enter the drive value for the root partition, this partition will be wiped and formatted: ' rootpar read -p 'Please enter the drive value for the EFI partition: ' efipar # Format the root partition to ext4 mkfs.ext4 /dev/$rootpar # Mount root partition mount -o ${MNTOPTIONS},/dev/$rootpar /mnt # Ask if the EFI partition should be wiped before mounting read -p "Do you wish to wipe the EFI partition? If you already have an existing OS installed, say No. " yesno case $yesno in [yesYesYy]* ) mkfs.fat -F32 /dev/$efipar ;; [noNoNn]* ) echo "The EFI partition will not be wiped" ;; * ) echo "Please answer yes (Yes, y, Y) or no (No, n, N)";; esac # Ask if a home partition should be created read -p "Do you wish to set a home partition? " yesno case $yesno in [yesYesYy]* ) read -p 'Please enter the drive value for the home partition, this partition will be wiped: ' homepar mkfs.ext4 /dev/$homepar ;; [noNoNn]* ) echo "A home partition will not be used in this installation" ;; * ) echo "Please answer yes (Yes, y, Y) or no (No, n, N)";; esac # Get user credentials read -p "Please enter a username " username read -rsp "Please enter a password " password echo -ne "\n" read -rsp "Please re-enter the password " passwordconfirm if [[ "$password" == "$password2" ]]; then export USERNAME = $username export PASSWORD = $password echo "Credentials saved" fi # Run pacstrap and install base packages pacstrap -i /mnt base base-devel linux linux-firmware rsync networkmanager grub efibootmgr dosfstools os-prober nano dkms dbus-broker-units mkinitcpio iptables-nft --noconfirm --needed # Create the /boot/efi directory, then mount the EFI partition (and the home partition if selected) mkdir /mnt/boot/efi mount /dev/$efipar /mnt/boot/efi if test -z "$homepar"; then mount -o ${MNTOPTIONS},/dev/$homepar /mnt/home fi # Generate a fstab file genfstab -U /mnt >> /mnt/etc/fstab # Chroot into the new system and setup arch-chroot /mnt /bin/bash < /etc/locale.conf echo "KEYMAP=uk" > /etc/vconsole.conf echo archlinux > /etc/hostname echo -e "\n127.0.0.1 localhost\n::1 localhost\n127.0.0.1 archlinux" >> /etc/hosts echo -e "\n# Set terminal editor to Nano\nEDITOR=nano" >> /etc/environment # Add "chaotic-aur" as a Pacman repository pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com pacman-key --lsign-key 3056513887B78AEB pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' # Amend pacman.conf and run full sync to enable extra repos sed -i 's/^#Color/Color\nILoveCandy/' /etc/pacman.conf sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf echo -e "\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist" >> /etc/pacman.conf pacman -Syu # Enable NetworkManager systemctl enable NetworkManager # Install GRUB echo "Installing bootloader" grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB grub-mkconfig -o /boot/grub/grub.cfg # Create the standard user, add it to all neccesary groups and disable the root account useradd -mG power,storage,wheel $username echo "$username:$password" | chpasswd passwd --lock root # Set up sudo sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers # Required to enable network changes sysctl --system # Prompt the user to reboot echo "Install complete, please reboot"