Skip to content

Instantly share code, notes, and snippets.

@varunagrawal
Last active September 24, 2023 00:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save varunagrawal/d27eded739f59228eaf3b746907c6a64 to your computer and use it in GitHub Desktop.
Save varunagrawal/d27eded739f59228eaf3b746907c6a64 to your computer and use it in GitHub Desktop.
ArchLinux Installation Guide

Arch Install Guide

Foundation

  • Partition a drive on Windows and delete it so that it's free space. Note the size since we'll need it later.
  • Boot into Arch
  • Run fdisk -l to see the partitions.

Disk Partitioning

  • Run parted.
    • Run print free to see the free space and note the Start and End points.
  • Create the following partitions, keeping in mind to replace the start and end values with the appropriate numbers:
    • Boot: No need for this since we are dual booting and will use the Windows EFI System Partition (ESP) directly.
    • /root: mkpart primary ext4 {Start}GiB {Start+40}GiB
    • /home: mkpart primary ext4 {Start+40}GiB {End}GiB
  • Note that it is recommended to use a swap file since it offers much more flexibility without the loss of performance since Arch treats a swap file the same as a swap partition.
    • Keeping the swap partition command here for completeness: mkpart primary linux-swap {Start+40}GiB {Start+40+SWAP_SIZE}GiB. Note that SWAP_SIZE should be your RAM size plus an additional 2 GB.
  • Check your newly created partitions with fdisk -l and note down their names (e.g. /dev/sda8).
    • Mine are /dev/sda8 for root, and /dev/sda9 for home.
  • Time to create the filesystems. You have only created the parititions, you still need to tell Linux how to lay out your filesystem:
    • mkfs.ext4 /dev/sda8
    • mkfs.ext4 /dev/sda9

Installation

  • Mount the root directory mount /dev/sda8 /mnt
  • Important Mount the ESP:
    • mkdir -p /mnt/boot/
    • With fdisk -l get the device name with type EFI System. Mine is /dev/sda1 (it's usually the first device/sector).
    • mount /dev/sda1 /mnt/boot
  • Mount the home directory:
    • mkdir -p /mnt/home
    • mount /dev/sda9 /mnt/home
  • Set up Wifi to download all the needed packages.
    • Let's use netctl since it is easy and generally works.
    • I previously used wpa_supplicant. Keeping instructions here for future reference.
      • Create a temporary config: /etc/wpa_supplicant/temp.conf
      • Add a network config to it. You may want to google for the config that makes sense for your network. Check notes.
      • Get the network interface with ifconfig. My case was wlp2s0
      • Run wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/temp.conf.
      • Get an IP address with dhcpcd wlp2s0.
      • Check connectivity with ping google.com
  • Set up pacman GPG keys so that the packages download without issues:
    • pacman-key --init && pacman-key --populate archlinux
    • Edit /etc/pacman.d/gnupg/gpg.conf and change the keyserver line to keyserver hkp://pgp.mit.edu:11371.
  • Install the base system with pacstrap -i /mnt base base-devel. Choose the defaults and hit Y to proceed with installation when prompted. Go grab a coffee while it downloads.
  • Generate the fstab file with genfstab -U /mnt > /mnt/etc/fstab
  • Go to your drive arch-chroot /mnt /bin/bash.
  • IMPORTANT Pick a language else your system may not bootup:
    • Open /etc/locale.gen (nano is a good choice).
    • Uncomment en_US.UTF-8 UTF-8 and en_US ISO-8859-1.
    • Save and exit
    • Run locale-gen.
    • Save the env variable: echo LANG=en_US.UTF-8 > /etc/locale.conf
  • Set the timezone.
    • Mine is EST: ln -sf /usr/share/zoneinfo/EST5EDT /etc/localtime
    • Read the system time in UTC but return in local time: hwclock --systohc --utc
  • Let's setup our bootloader. I highly recommend reading this first.
    • Create an initial environment to boot in: mkinitcpio -p linux
    • Get grub since it works for both MBR and EFI boot systems: pacman -S grub efibootmgr os-prober
    • Run grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
    • Create a grub config file: grub-mkconfig -o /boot/grub/grub.cfg. You can ignore any warnings that might come up.
  • Install a Boot Manager (systemd-boot) which will take care of the task of starting bootloaders such as GRUB as well as make it super easy to discover and generate the boot menu.
    • Run bootctl --path=/boot install to install systemd-boot. If it gives an error that loader.conf already exists, then delete the file at /boot/loader/loader.conf.
    • Configure the loader.conf by setting the following values:
      default  arch
      timeout  5
      editor   0
      
    • If you don't see a boot menu on startup, see the Notes.

Configure Network

  • Time to add a hostname:
    • echo <whatever you like> > /etc/hostname
    • Edit the file /etc/hosts and in the line with 127.0.0.1 append the hostname after localhost.
    • Install packages to configure Wifi on reboot: pacman -S dialog iw wpa_supplicant
  • Set the root password with passwd. We initially run as root to make sure things worked as expected.
  • Exit chroot and unmount filesystems: umount -R /mnt
  • Reboot!

NOTE In case Windows does not show in GRUB, you can manually edit the GRUB entry by creating a /boot/grub/custom.cfg custom configuration. See the notes for more details.

If you encounter an error that a PARTUUID could not be found, then do the following:

  1. Get the PARTUUID of your /root partition blkid -s PARTUUID -o value /dev/sdxY. Write the PARTUUDI down as you will need it later.
  2. Open the arch.conf with nano /boot/loader/entries/arch.conf.
  3. Replace the existing PARTUUID with the one you wrote down on the line that says: options root=PARTUUID=the-id-you-just-copied rw.

Notes

  • We create different partitions for root and home since that means our user data is separated from the system files, making it easier to organize, recover and even change OSes without affecting our data (which crappy Ubuntu does not do).

  • Wifi Interface Config for GTwifi

    ctrl_interface=/var/run/wpa_supplicant
    network={
        ssid="GTwifi"
        key_mgmt=WPA-EAP
        eap=PEAP
        identity="vagrawal38"
        password="whatever-the-password-is"
        ca_cert="/etc/ssl/certs/AddTrust_External_Root.pem"
        phase1="peaplabel=0"
    }
    
  • The fstab (pronounced "F S Tab") file tells your system what your filesystems are and what they should be called.

  • I have a weird issue where when I boot my machine I need to press the Spacebar in order to see the boot menu. From my research this seems to be a firmware issue in my laptop. Need to investigate more.

  • The Arch Wiki has a great page on how to create a GRUB entry for Windows. Personally tried it and it worked beautifully. You most probably want to look at the section Windows installed in UEFI-GPT Mode menu entry. Placing a copy of my GRUB entry here for reference:

    grub-probe --target=hints_string /boot/EFI/Microsoft/Boot/bootmgfw.efi  # to get $hints_string
    grub-probe --target=fs_uuid /boot/EFI/Microsoft/Boot/bootmgfw.efi  # to get $fs_uuid
    
    if [ "${grub_platform}" == "efi" ]; then
        menuentry "Microsoft Windows Vista/7/8/8.1 UEFI-GPT" {
            insmod part_gpt
            insmod fat
            insmod search_fs_uuid
            insmod chain
            search --fs-uuid --set=root $hints_string $fs_uuid
            chainloader /EFI/Microsoft/Boot/bootmgfw.efi
        }
    fi

Desktop Environment

Basics

  • We're in root so let's create a user useradd -m -G wheel -s /bin/bash <username>
  • Set the user password passwd <username>
  • Install sudo so we can run with elevated privileges pacman -S sudo
  • Open up the sudoers list nano /etc/sudoers and uncomment the line near the end that allows the wheel group to use sudo.
  • Login as user su - <username>
  • Update all packages in preparation sudo pacman -Syu
  • Install a nicer terminal sudo pacman -S terminator

Display Manager and Desktop

  • Install XOrg Server sudo pacman -S xorg-server xorg-apps
  • Install your environment and display manager. I prefer using KDE with lightdm. We need kio-extras to ensure thumbnails show up. sudo pacman -S plasma-meta plasma kio-extras lightdm
  • Logout of your user account and switch into root (Ctrl+Alt+F2) and run systemctl enable lightgdm.service and systemctl start lightgdm.service

Alternatively if you prefer GNOME

  • Install your environment and display manager sudo pacman -S gnome gdm gnome-extra

  • Logout of your user account into root with logout and run systemctl enable gdm.service and systemctl start gdm.service

  • Login to your account and open a terminal.

  • Install the essentials sudo pacman -S firefox vlc inkscape gimp

KDE Settings

  • Global Theme: Breeze Dark
  • Plasma Style: Breeze Dark

Package Manager

For ease of use with AUR packages, I prefer using yay.

Wifi Configuration

  • If the wifi does not show anything, then you can use the previously used netctl method to get a working connection.
  • We need to install NetworkManager. Note the camel case, this is important since Arch makes a distinction about this. sudo pacman -S networkmanager.
  • Enable and run the NetworkManager: sudo systemctl enable NetworkManager && sudo systemctl start NetworkManager.
  • Check if it the network manager is up with sudo nmcli g.

If the internet is incredibly slow, this could be because of the DNS being set to a bad one (such as the default for Xfinity). Update the DNS to 1.1.1.1 in /etc/resolv.conf and prevent the file from being overwritten by following the instructions for the appropriate network manager here.

Audio

Install

  • pavucontrol
  • pulseaudio
  • alsa-utils

If the HDMI audio does not auto-switch when you plugin the HDMI cable, you will have to configure the udev rule as detailed here.

HDMI Sound with KDE

For setting up HDMI output (especially with KDE Plasma) do the following:

  1. Right click the Audio Icon on the bottom bar and select Configure Audio Volume
  2. From Left list select Audio
  3. Go to Advanced tab
  4. There will be two "Build-in Audio" drop down menu > Switch first one to "Digital Stereo (HDMI) output" and select the 2 checkboxes.
  5. Go to Devices tab and select "Built-in Audio Digital stereo (HDMI)" as default.

Note: If it doesn't work the first time try switching between default output and disable auto switching.

Fonts

You'll want to install fonts packages to ensure your fonts are being rendered correctly:

sudo pacman -S xorg-fonts-misc ttf-dejavu ttf-ancient-fonts ttf-freefont ttf-liberation ttf-droid noto-fonts-emoji ttf-emojione

This article may be useful.

Font Settings

  • General: Titillium Web 12pt Regular
  • Fixed Width: Hack 9pt
  • Small: Titillium Web 12pt Regular
  • Toolbar: Roboto 12pt
  • Menu: Titillium Web 12pt Regular
  • Window Title: Exo 2 12pt Regular
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment