# Arch Linux Setup This documentation assumes you've booted in to the arch ISO using a USB drive or some other method. ### Connect to Wi-Fi (if needed) ```bash # Verify no internet access ping -c 2 google.com # Connect to wifi using iwctl iwctl device list station wlan0 scan station wlan0 get-networks station wlan0 connect <ssid> station wlan0 show exit # Verify internet access ping -c 2 google.com ``` ### Partitioning / Install ```bash # Verify you have EFI ls /sys/firmware/efi/efivars # Use fdisk to create partitions # # EXISTING: # /dev/nvme0n1p1 (windows EFI) vfat # # CREATE: # /dev/nvme0n1p5 (~50% of RAM) swap # /dev/nvme0n1p6 (40GB for linux) ext4 # /dev/nvme0n1p7 (Remaining for /home) ext4 # Final product lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS nvme0n1 259:0 0 476.9G 0 disk ├─nvme0n1p1 259:1 0 260M 0 part /boot ├─nvme0n1p2 259:2 0 16M 0 part ├─nvme0n1p3 259:3 0 114.6G 0 part ├─nvme0n1p4 259:4 0 1000M 0 part ├─nvme0n1p5 259:5 0 8G 0 part [SWAP] ├─nvme0n1p6 259:6 0 40G 0 part / └─nvme0n1p7 259:7 0 313.1G 0 part /home # Setup swap and filesystems mkswap /dev/nvme0n1p5 mkfs.ext4 /dev/nvme0n1p6 mkfs.ext4 /dev/nvme0n1p7 # Enable swap and mount partitions swapon /dev/nvme0n1p5 mount /dev/nvme0n1p6 /mnt mkdir /mnt/boot mount /dev/nvme0n1p1 /mnt/boot mkdir /mnt/home mount /dev/nvme0n1p7 /mnt/home # Install arch along with some important packages pacstrap /mnt base base-devel linux linux-firmware vim # Save mounted drives to automate on boot genfstab -U -p /mnt >> /mnt/etc/fstab ``` ### Boot Loader Install `bootctl` along-side EFI in `/boot`: ```bash arch-chroot /mnt bootctl install ``` You'll need the UUID for the root linux partition. For example, if the root linux partition is `/dev/sda2`, you can acquire the UUID by running `blkid /dev/sda2`. Place the UUID in a boot loader entry file like so: ```ini # /boot/loader/entries/arch.conf title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options root="UUID=<uuid_without_brackets>" rw ``` Lastly, create a loader config file to set the new entry to the default: ```ini # /boot/loader/loader.conf timeout 3 default arch.conf ``` NOTE: You might need to reinstall the kernel `pacman -S linux` if you've installed to the `/boot` mount before: https://bbs.archlinux.org/viewtopic.php?id=235590 ### General Setup ```bash # If not already: arch-chroot /mnt # Set root password passwd # Auto-detect network devices pacman -S networkmanager systemctl enable NetworkManager # Set a hostname vim /etc/hostname # Setup locales by uncommenting "en_US.UTF-8 UTF-8" vim /etc/locale.gen # Generate locales and configure its use locale-gen echo "LANG=en_US.UTF-8" > /etc/locale.conf # Set timezone ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime exit reboot ``` ### Setup user account You should now be able to boot in to arch and login as the `root` user. You should setup your own user. For example, to create a user called `chris`: ```bash pacman -S sudo useradd -m chris passwd chris usermod -aG wheel chris vim /etc/sudoers # Uncomment %wheel ALL=(ALL) ALL ``` ### Installing a desktop environment There are several different avenues you can go. This example installs the `cinnamon` desktop environment and uses the GNOME Display Manager (`gdm`): ```bash # Install cinnamon and a file browser like nemo sudo pacman -S cinnamon nemo-preview # Install a terminal. For example: sudo pacman -S guake # Install / start the display manager sudo pacman -S gdm sudo systemctl enable gdm sudo systemctl start gdm ``` ***NOTE**: For laptops with both a dedicated NVIDIA card and integrated Intel card, you'll want to leverage the [PRIME](https://wiki.archlinux.org/title/PRIME) technology for hybrid graphics to allow simultaneous use of the HDMI output and laptop monitor. As such, you'll want to use a patched version of `gdm` called `gdm-prime`*: ```bash # Uninstall gdm if neccessary sudo pacman -R gdm # For those needing hybrid graphics sudo pacman -S gdm-prime optimus-manager-git optimus-manager-qt-git sudo systemctl enable gdm-prime sudo systemctl start gdm-prime ``` ### Configuring Mirrors ```bash # Install rankmirrors sudo pacman -S pacman-contrib # Backup original mirrorlist cd /etc/pacman.d sudo mv mirrorlist mirrorlist.orig ``` Create a new empty `mirrorlist` with the following content ```bash ## ## Arch Linux repository mirrorlist ## Filtered by mirror score from mirror status page ## Generated on 2022-04-28 ## ## United States ``` Fetch the top 5 up-to-date mirrors in the US using `rankmirrors`: ```bash MIRRORS_URL="https://archlinux.org/mirrorlist/?country=US&protocol=https&use_mirror_status=on" # Append top 5 mirrors sudo sh -c "curl -s '$MIRRORS_URL' | \ sed -e 's/^#Server/Server/' -e '/^#/d' | \ rankmirrors -n 5 - >> mirrorlist" ``` It should look something like this: ```bash cat mirrorlist ## ## Arch Linux repository mirrorlist ## Filtered by mirror score from mirror status page ## Generated on 2022-04-28 ## ## United States Server = https://plug-mirror.rcac.purdue.edu/archlinux/$repo/os/$arch Server = https://mirror.pit.teraswitch.com/archlinux/$repo/os/$arch Server = https://ord.mirror.rackspace.com/archlinux/$repo/os/$arch Server = https://mirror2.sandyriver.net/pub/archlinux/$repo/os/$arch Server = https://mirrors.mit.edu/archlinux/$repo/os/$arch ``` You can force the mirrors to sync and install any updates via: ```bash sudo pacman -Syyu ``` ### Some important packages ```bash # Network cli / gui sudo pacman -S net-tools network-manager-applet # Audio drivers sudo pacman -S pipewire pipewire-pulse # Video player / image editor sudo pacman -S vlc gimp # VSCode sudo pacman -S gnome-keyring visual-studio-code-bin # Fonts sudo pacman -S ttf-ms-fonts ttf-dejavu noto-fonts-emoji noto-fonts-cjk ``` ### Install `yay` for AUR packages https://www.tecmint.com/install-yay-aur-helper-in-arch-linux-and-manjaro Once installed, you can now use `yay` in lieu of `sudo pacman`. All AUR packages will now be available. ### Some useful AUR packages ```bash # Browser yay -S brave-bin # Zoom yay -S zoom # Tool for setting background image on login screen # Also checkout: https://wiki.archlinux.org/title/GDM#Login_screen_background_image yay -S loginized ``` ### Configuring `docker` data root Installing `docker` is the easy part, but you'll probably want to configure it to store resources on the home partition instead of the root partition. If you already have docker resources in the default data root of `/var/lib/docker`, you'll want to stop the service and move them to the home partition to somewhere like `/home/<user>/.docker/data`. The following assumes a username of `chris`: ```bash sudo systemctl stop docker sudo mv /var/lib/docker /home/chris/.docker/data ``` Then to configure docker to use the new location: ```bash # /etc/docker/daemon.json { "data-root": "/home/chris/.docker/data" } ``` Now you can safely restart the service: ```bash sudo systemctl start docker ``` ### Setting up `zsh` ```bash # Install zsh yay -S zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ZSH_CUSTOM=~/.oh-my-zsh/custom # Install plugins git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions # Install theme git clone https://github.com/spaceship-prompt/spaceship-prompt.git $ZSH_CUSTOM/themes/spaceship-prompt --depth=1 ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme" ```