The Complete Guide to Installing and Configuring Arch Linux: From Bare Metal to Desktop

Introduction

Arch Linux represents the pinnacle of DIY Linux distributions, offering users complete control over their system at the cost of requiring hands-on configuration. This comprehensive guide will walk you through the entire process, from creating installation media to building a fully functional desktop environment.

Why Choose Arch Linux?

Arch Linux follows a rolling release model and the KISS (Keep It Simple, Stupid) principle. Unlike other distributions that come pre-configured, Arch gives you a minimal base system that you build upon. This approach offers several advantages:

  • Complete Control: You decide exactly what gets installed
  • Learning Experience: Understanding how Linux systems work at a fundamental level
  • Cutting-Edge Software: Access to the latest packages through rolling releases
  • Excellent Documentation: The Arch Wiki is legendary for its thoroughness
  • AUR Support: Access to the Arch User Repository with thousands of additional packages

Prerequisites and Preparation

Before diving into the installation, ensure you have:

  • A computer with UEFI firmware (recommended) or legacy BIOS
  • At least 2GB RAM (4GB+ recommended)
  • 20GB+ storage space
  • Stable internet connection
  • USB drive (4GB minimum) for installation media
  • Another computer for reference (optional but helpful)

Lab 1: Creating Installation Media

Objective: Create a bootable Arch Linux USB drive

Steps:

  1. Download the ISO: # Visit https://archlinux.org/download/ # Download the latest ISO (approximately 800MB) # Verify the integrity using provided checksums
  2. Create bootable USB (Linux/macOS): # Find your USB device lsblk # Replace /dev/sdX with your USB device sudo dd if=archlinux-2024.01.01-x86_64.iso of=/dev/sdX bs=4M status=progress sync
  3. Create bootable USB (Windows):
    • Use Rufus or Etcher
    • Select the Arch ISO
    • Choose your USB drive
    • Use DD mode for compatibility

Verification: Boot from the USB to see the Arch Linux boot menu.

Part I: Base System Installation

Lab 2: Booting and Initial Setup

Objective: Boot into the Arch installation environment and prepare for installation

Steps:

  1. Boot from USB:
    • Enter BIOS/UEFI settings
    • Disable Secure Boot (if present)
    • Set USB as first boot device
    • Boot from the USB drive
  2. Verify boot mode: # Check if booted in UEFI mode ls /sys/firmware/efi/efivars # If this directory exists, you're in UEFI mode
  3. Set keyboard layout (if needed): # List available layouts localectl list-keymaps # Load your layout (example for German) loadkeys de-latin1
  4. Connect to internet: # For wired connection, it should work automatically ping -c 3 archlinux.org # For WiFi iwctl station wlan0 scan station wlan0 get-networks station wlan0 connect "YourNetworkName" exit

Expected Result: Successfully connected to the internet with ping working.

Lab 3: Disk Partitioning

Objective: Create appropriate partitions for Arch Linux installation

Understanding Partition Schemes:

For UEFI systems, we need:

  • EFI System Partition (ESP): 512MB, FAT32
  • Root partition: Remaining space, ext4
  • Swap partition: Optional, typically 1-2x RAM size

Steps:

  1. Identify your disk: lsblk # Look for your target disk (usually /dev/sda or /dev/nvme0n1)
  2. Partition the disk: # Use gdisk for GPT partitioning (UEFI) gdisk /dev/sda # Commands within gdisk: # o - create new GPT partition table # n - create new partition # # Partition 1: EFI System Partition # First sector: (default) # Last sector: +512M # Type: ef00 # # Partition 2: Root partition # First sector: (default) # Last sector: (default, use remaining space) # Type: 8300 # # w - write changes and exit
  3. Format partitions: # Format EFI partition mkfs.fat -F32 /dev/sda1 # Format root partition mkfs.ext4 /dev/sda2 # Optional: Create and enable swap # mkswap /dev/sda3 # swapon /dev/sda3
  4. Mount filesystems: # Mount root partition mount /dev/sda2 /mnt # Create and mount EFI directory mkdir /mnt/boot mount /dev/sda1 /mnt/boot

Verification: Run lsblk to confirm proper mounting.

Lab 4: Installing the Base System

Objective: Install essential Arch Linux packages

Steps:

  1. Update package database: pacman -Sy
  2. Install base packages: # Install base system, kernel, and essential packages pacstrap /mnt base linux linux-firmware base-devel vim nano networkmanager grub efibootmgrPackage Explanations:
    • base: Minimal package set for Arch Linux
    • linux: Latest Linux kernel
    • linux-firmware: Firmware files for hardware
    • base-devel: Development tools including make, gcc
    • vim/nano: Text editors
    • networkmanager: Network management daemon
    • grub: Bootloader
    • efibootmgr: UEFI boot manager
  3. Generate filesystem table: genfstab -U /mnt >> /mnt/etc/fstab # Verify the generated fstab cat /mnt/etc/fstab

Expected Result: Base system installed in /mnt with proper fstab entries.

Lab 5: System Configuration

Objective: Configure the newly installed system

Steps:

  1. Change root into new system: arch-chroot /mnt
  2. Set timezone: # List available timezones timedatectl list-timezones | grep -i your_region # Set timezone (example) ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime # Generate hardware clock hwclock --systohc
  3. Configure localization: # Edit locale.gen vim /etc/locale.gen # Uncomment your locale (e.g., en_US.UTF-8 UTF-8) # Generate locales locale-gen # Set system locale echo "LANG=en_US.UTF-8" > /etc/locale.conf # Set keyboard layout permanently (if changed earlier) echo "KEYMAP=de-latin1" > /etc/vconsole.conf
  4. Configure hostname: echo "myarch" > /etc/hostname # Edit hosts file vim /etc/hosts # Add these lines: # 127.0.0.1 localhost # ::1 localhost # 127.0.1.1 myarch.localdomain myarch
  5. Set root password: passwd # Enter a strong password

Expected Result: System timezone, locale, hostname, and root password configured.

Lab 6: Bootloader Installation

Objective: Install and configure GRUB bootloader

Steps:

  1. Install GRUB: # For UEFI systems grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB # For BIOS systems (use this instead) # grub-install --target=i386-pc /dev/sda
  2. Generate GRUB configuration: grub-mkconfig -o /boot/grub/grub.cfg
  3. Enable NetworkManager: systemctl enable NetworkManager
  4. Exit chroot and reboot: exit umount -R /mnt reboot

Expected Result: System boots into Arch Linux and you can log in as root.

Part II: Post-Installation Configuration

Lab 7: User Management and Basic Security

Objective: Create a regular user account and configure sudo access

Steps:

  1. Create a user account: # Create user with home directory useradd -m -G wheel -s /bin/bash username # Set password for the user passwd username
  2. Configure sudo access: # Edit sudoers file EDITOR=vim visudo # Uncomment this line: %wheel ALL=(ALL:ALL) ALL
  3. Test sudo access: # Switch to your user su - username # Test sudo sudo pacman -Syu

Security Best Practices:

  • Never use root for daily tasks
  • Use strong passwords
  • Consider setting up SSH key authentication
  • Keep the system updated regularly

Lab 8: Installing a Desktop Environment

Objective: Install and configure a desktop environment (using GNOME as example)

Understanding Desktop Environments:

  • GNOME: Modern, user-friendly, resource-intensive
  • KDE Plasma: Feature-rich, customizable, moderate resources
  • XFCE: Lightweight, traditional, low resources
  • i3/Sway: Tiling window managers, minimal, keyboard-driven

Steps for GNOME:

  1. Install Xorg display server: sudo pacman -S xorg-server xorg-xinit
  2. Install GNOME: # Full GNOME installation sudo pacman -S gnome gnome-extra # Minimal GNOME (alternative) # sudo pacman -S gnome-shell gdm gnome-control-center gnome-terminal nautilus
  3. Enable display manager: sudo systemctl enable gdm
  4. Install graphics drivers: # For Intel graphics sudo pacman -S xf86-video-intel # For AMD graphics sudo pacman -S xf86-video-amdgpu # For NVIDIA (proprietary) sudo pacman -S nvidia nvidia-utils # For generic/virtual machines sudo pacman -S xf86-video-vesa
  5. Reboot to start desktop: sudo reboot

Expected Result: GNOME desktop environment loads after reboot.

Lab 9: Essential Software Installation

Objective: Install commonly needed applications and utilities

Categories of Software:

  1. System Utilities: sudo pacman -S htop neofetch tree unzip wget curl git
  2. Development Tools: sudo pacman -S code python python-pip nodejs npm docker docker-compose
  3. Multimedia: sudo pacman -S vlc gimp firefox thunderbird
  4. Office and Productivity: sudo pacman -S libreoffice-fresh

Understanding Package Management:

  • pacman -S package: Install package
  • pacman -Syu: Update system
  • pacman -R package: Remove package
  • pacman -Rs package: Remove package and dependencies
  • pacman -Ss keyword: Search for packages
  • pacman -Q: List installed packages

Lab 10: AUR (Arch User Repository) Setup

Objective: Install an AUR helper and use it to install AUR packages

What is AUR? The Arch User Repository is a community-driven repository containing package scripts (PKGBUILDs) that allow users to compile and install software not available in official repositories.

Steps:

  1. Install an AUR helper (yay): # Clone yay repository cd /tmp git clone https://aur.archlinux.org/yay.git cd yay makepkg -si
  2. Using yay: # Update system including AUR packages yay -Syu # Install AUR package yay -S visual-studio-code-bin # Search AUR yay -Ss keyword
  3. Popular AUR packages: # Google Chrome yay -S google-chrome # Spotify yay -S spotify # Discord yay -S discord

AUR Safety Tips:

  • Always review PKGBUILDs before installation
  • Check package popularity and maintenance
  • Be cautious with packages from unknown maintainers

Part III: Advanced Configuration

Lab 11: System Optimization and Tweaks

Objective: Optimize system performance and apply useful tweaks

Performance Optimizations:

  1. SSD Optimization (if using SSD): # Enable TRIM support sudo systemctl enable fstrim.timer # Check TRIM support lsblk -D
  2. Optimize pacman: sudo vim /etc/pacman.conf # Uncomment these lines: # Color # ParallelDownloads = 5 # VerbosePkgLists
  3. Configure swappiness (for better responsiveness): echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf
  4. Enable microcode updates: # For Intel CPUs sudo pacman -S intel-ucode # For AMD CPUs sudo pacman -S amd-ucode # Regenerate GRUB config sudo grub-mkconfig -o /boot/grub/grub.cfg

Lab 12: Customization and Theming

Objective: Customize the appearance and behavior of your desktop

GNOME Customization:

  1. Install GNOME Tweaks: sudo pacman -S gnome-tweaks
  2. Install extensions: # Install extension manager sudo pacman -S gnome-browser-connector # Visit extensions.gnome.org in Firefox # Popular extensions: Dash to Dock, User Themes, GSConnect
  3. Install themes and icons: # Popular theme yay -S arc-gtk-theme # Popular icons sudo pacman -S papirus-icon-theme

Lab 13: Backup and Maintenance

Objective: Set up system backup and maintenance routines

Backup Strategies:

  1. System configuration backup: # Create backup script vim ~/backup-system.sh #!/bin/bash # System backup script BACKUP_DIR="/home/$USER/backups/$(date +%Y%m%d)" mkdir -p "$BACKUP_DIR" # Backup important directories cp -r ~/.config "$BACKUP_DIR/" cp /etc/fstab "$BACKUP_DIR/" cp /etc/hostname "$BACKUP_DIR/" # List installed packages pacman -Qe > "$BACKUP_DIR/pkglist.txt" yay -Qm > "$BACKUP_DIR/aurlist.txt" echo "Backup completed: $BACKUP_DIR"
  2. Make backup script executable: chmod +x ~/backup-system.sh
  3. System maintenance script: vim ~/maintain-system.sh #!/bin/bash # System maintenance script echo "Updating system..." yay -Syu echo "Cleaning package cache..." sudo pacman -Sc echo "Removing orphaned packages..." sudo pacman -Rns $(pacman -Qtdq) 2>/dev/null || echo "No orphaned packages" echo "Updating locate database..." sudo updatedb echo "Maintenance completed!"

Troubleshooting Common Issues

Boot Problems

Issue: System won’t boot after installation Solutions:

  • Check BIOS/UEFI boot order
  • Verify GRUB installation: grub-install --recheck
  • Regenerate GRUB config: grub-mkconfig -o /boot/grub/grub.cfg

Network Issues

Issue: No internet connection after reboot Solutions:

# Start NetworkManager
sudo systemctl start NetworkManager
sudo systemctl enable NetworkManager

# For WiFi issues
sudo systemctl restart NetworkManager
nmcli device wifi list
nmcli device wifi connect "SSID" password "password"

Graphics Issues

Issue: Poor graphics performance or no display Solutions:

  • Install appropriate graphics drivers
  • Check Xorg logs: journalctl -u gdm
  • Fall back to generic drivers: sudo pacman -S xf86-video-vesa

Package Management Issues

Issue: Conflicting packages or dependency problems Solutions:

# Force refresh package databases
sudo pacman -Syy

# Clear package cache
sudo pacman -Scc

# Fix corrupted database
sudo pacman -Syu

Best Practices and Tips

Security Hardening

  1. Configure firewall: sudo ufw enable sudo ufw default deny incoming sudo ufw default allow outgoing
  2. Regular updates: # Create update alias echo "alias update='yay -Syu'" >> ~/.bashrc
  3. Monitor system logs: # Check system status journalctl -p 3 -xb

Performance Monitoring

  1. Install monitoring tools: sudo pacman -S htop iotop nethogs
  2. Check system resources: # CPU and memory usage htop # Disk I/O iotop # Network usage nethogs

Useful Aliases and Functions

Add these to your ~/.bashrc:

# Useful aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ../..'
alias grep='grep --color=auto'
alias update='yay -Syu'
alias install='yay -S'
alias search='yay -Ss'
alias remove='yay -R'

# Functions
# Extract various archive formats
extract() {
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)   tar xjf $1     ;;
            *.tar.gz)    tar xzf $1     ;;
            *.bz2)       bunzip2 $1     ;;
            *.rar)       unrar x $1     ;;
            *.gz)        gunzip $1      ;;
            *.tar)       tar xf $1      ;;
            *.tbz2)      tar xjf $1     ;;
            *.tgz)       tar xzf $1     ;;
            *.zip)       unzip $1       ;;
            *.Z)         uncompress $1  ;;
            *.7z)        7z x $1        ;;
            *)           echo "'$1' cannot be extracted via extract()" ;;
        esac
    else
        echo "'$1' is not a valid file"
    fi
}

Conclusion

Congratulations! You’ve successfully installed and configured Arch Linux from scratch. This journey has given you deep insights into how Linux systems work and provided you with a highly customized, efficient operating system.

Key Takeaways

  • Foundation Knowledge: You understand partitioning, bootloaders, and system configuration
  • Package Management: You can efficiently manage software using pacman and AUR helpers
  • Customization Skills: Your system is tailored to your specific needs and preferences
  • Troubleshooting Abilities: You have the tools and knowledge to diagnose and fix issues

Next Steps

Consider exploring these advanced topics:

  1. Window Managers: Try i3, dwm, or awesome for more control
  2. Containerization: Learn Docker and Podman for development
  3. Virtualization: Set up KVM/QEMU for virtual machines
  4. Server Applications: Transform your system into a web server or NAS
  5. Kernel Compilation: Build custom kernels for specific hardware
  6. System Administration: Learn systemd, networking, and security hardening

Resources for Continued Learning

  • Arch Wiki: Your primary reference for all things Arch Linux
  • Arch Forums: Community support and discussions
  • Reddit: r/archlinux for tips, screenshots, and help
  • YouTube: Various Arch Linux tutorial channels
  • Books: “The Linux Command Line” and “Linux System Administration”

Remember, the Arch Linux journey is about continuous learning and improvement. Keep your system updated, experiment with new software, and don’t be afraid to break things – that’s how you learn!

The philosophy of Arch Linux – simplicity, minimalism, and user-centricity – will serve you well in your Linux journey. You now have the foundation to build upon and the confidence to tackle any Linux-related challenge that comes your way.

Happy computing with your new Arch Linux system!

Share: