How to Setup Arch Linux

How to Setup Arch Linux

Created
Jan 30, 2022
Description
A simple walkthrough on how to setup a minimal arch linux
Featured
Category
Linux
Tags
notion image
In this blog post, I show an example end-to-end instructions for setting up an Arch Linux. The instructions are designed for people who want to who want to do minimal Arch Linux installation (as compared to a more heavy-weight bundled installation). Some steps are not required.
  1. Get a bootable usb
  1. Boot to arch linux installation drive
  1. Check the disks
    1. # fdisk -l
  1. Select the disk we’re going to format and partition
      • Select the drive
        • # fdisk /dev/nvme1n1p5
      • Type ’n’ to create a new partition. Choose default settings.
      • Type ‘F’ to verify free space.
      • Type ’t’ to change partition type to Linux.
      • Type ‘w’ to finish.
      • To format the partition
        • # sudo mkfs.ext4 /dev/nvme1n1p5
  1. Check the network connection
      • LAN: It usually works!
      • WiFi: (Note: may have to use `iwctl`)
        • # wifi-menu # ping www.google.com
  1. Select an appropriate mirror (for speeding things up)
    1. # pacman -Syy # pacman -S reflector # cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak # reflector -c “US” -f 12 -l 10 -n 12 --save /etc/pacman.d/mirrorlist
  1. Install Arch linux
      • Check thee drive again
        • # fdisk -l
      • Mount the partition
        • # mount /dev/nvme1n1p5 /mnt
      • Install necessary packages using pacstrap
        • # pacstrap /mnt base linux linux-firmware vim
  1. Configure the arch linux
      • Generate fstab file for how disk partitions
        • # genfstab -U /mnt >> /mnt/etc/fstab
      • Enter the mounted disk as root
        • # arch-chroot /mnt
      • Setting timezone
        • # timedatectl list-timezones # timedatectl set-timezone US/Pacific
      • Setting up Locale
        • # locale-gen # echo LANG=en_US.UTF-8 > /etc/locale.conf # export LANG=en_US.UTF-8
      • Network configuration (hostname/hosts)
        • # echo arch > /etc/hostname # touch /etc/hosts
          Make sure that /etc/hosts have
          127.0.0.1      localhost
          ::1            localhost
          127.0.1.1      arch
      • Setting up root password
        • # passwd
      • Create a user (UID < 1000 shouldn’t be exposed to public)
        • # useradd  tjenrung # passwd tjenrung
          Note: This is for modifying UID/GID.
          # id tjenrung # usermod -u 1001 tjenrung # groupmoud -g 1001 tjenrung # id tjenrung
  1. Install Grub bootloader
    1. # pacman -S grub efibootmgr # mkdir /boot/efi # mount /dev/nvme1n1p2 /boot/efi # grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi # grub-mkconfig -o /boot/grub/grub.cfg
  1. Install network manager + enable network manager
    1. # pacman -S plasma-nm # systemctl enable/disable NetworkManager
  1. At this point, you can probably boot to the drive (no more usb required).
  1. Install sudo
    1. # pacman -S sudo
      Add <username> to /etc/sudoers with <username> ALL=(ALL) ALL in the user privilege spec
  1. Install desktop environment
    1. # pacman -S xorg # pacman -S plasma-desktop # pacman -S xorg-xinit # echo "exec startkde" > ~.xinitrc
  1. Install display manager
    1. # pacman -S sddm kscreen # systemctl enable/disable sddm
  1. Install audio (PulseAudio)
    1. # pacman -S plasma-pa
  1. Install file manager
    1. # pacman -S dolphin
  1. Install terminal
    1. # pacman -S konsole
  1. Install AUR helper yay
    1. # pacman -S git base-devel # cd opt # sudo git clone https://aur.archlinux.org/yay-git.git # sudo chown -R <user>:<group> ./yay-git # cd yay-git # makepkg -si
      Note:
      yay install: yay -S <program> yay remove: yay -Rns <program> yay update: yay -Syu yay cleanup unwanted dependencies: yay -Yc
  1. [Optional] Install Firefox nightly
    1. # yay -S firefox-nightly
      If failed, clean ~/.cache/yay/firefox-nightly
      # gpg --recv-keys <key>
  1. [Optional] Install Visual Studio Code Insiders
    1. # yay -S visual-studio-code-insiders-bin
  1. Install nvidia driver
    1. # pacman -S nvidia nvidia-utils nvidia-settings
      Reboot and make sure that nvidia-smi works.
  1. Install OpenSSH. This allows others to ssh to this server.
    1. # pacman -S openssh # systemctl enable/disable sshd
      Config the server at /etc/ssh/sshd_config.
      Recommendations:
    2. Adding AllowUsers <username>
    3. Turn on password auth PasswordAuthentication yes
    4. Copy ssh-key by using ssh-copy-id <user>@<ip>
    5. Turn off password auth PasswordAuthentication no
  1. Install wget curl and rsync
    1. # pacman -S wget curl rsync
  1. Install zsh
    1. # echo $SHELL # pacman -S zsh zsh-completions
      This will invoke the first-time settings.
      # zsh
      Change the shell to /bin/zsh
      # chsh # rm ~/.bashrc ~/.bash_history
  1. [Recommended] Install oh-my-zsh + plugins
    1. # sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # rm ~/.zshrc.pre-oh-my-zsh
      Restart the prompt. Install autosuggestions
      # echo $ZSH_CUSTOM # git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting # git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
      Set plugins=(git brew zsh-syntax-highlighting zsh-autosuggestions)
  1. Install node npm
    1. # pacman -S nodejs npm
  1. Install pure terminal theme (https://github.com/sindresorhus/pure)
    1. # sudo npm install --global pure-prompt
      Set ZSH_THEME="" in ~/.zshrc
      Add this to ~/.zshrc
      # Pure prompt
      autoload -U promptinit; promptinit
      prompt pure
  1. Install htop
    1. # pacman -S htop
  1. Install tmux
    1. # pacman -S tmux
  1. Install Miniconda3
    1. # wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh # chmod +x Miniconda3-latest-Linux-x86_64.sh # ./Miniconda3-latest-Linux-x86_64.sh # ~/miniconda3/bin/conda init zsh
  1. [Optional] Install F5VPN
    1. # yay -S f5vpn
  1. Setup for an auto mount drive on start
      • Find the UUID of the drive by running fdisk -l
      • Edit the file /etc/fstab accordingly (Note options=defaults, dump=0, pass=0)
  1. Setup for an auto Login
    1. Add the following to /etc/sddm.conf.d/autologin.conf
      [Autologin]
      User=<username>
      Session=plasma
  1. Set GRUB for dual boot
      • Install windows first, linux after
        • Find the EFI partition using
          # sudo fdisk -l
          Find the UUID of windows using
          # sudo blkid /dev/<partition>
          Set the content to
          menuentry "Windows 10" --class windows --class os {
          insmod ntfs
          search --no-floppy --set=root --fs-uuid <WINDOWS-UUID>
          chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
          }
          Update GRUB
          # grub-mkconfig -o /boot/grub/grub.cfg
      • Install linux first, windows after
        • Usually the steps would be create a partition from Linux. Then, you just install windows in that particular partition. If windows is not recognized by your bootloader, you may have to add it manually.
  1. Install OpenRGB for setting CPU Fan Color
    1. # yay -S openrgb