logo
Back to Blog

Installing Arch Linux

A step-by-step guide to installing Arch Linux on your system.

Installing Arch Linux

This comprehensive guide explains how to install Arch Linux with the btrfs file system, either as a standalone operating system or in a dual-boot setup. It also covers using an ArchScript method for an automated and reproducible installation process.

Prerequisites

  • A USB drive with at least 2GB capacity
  • Download the latest Arch Linux ISO from https://archlinux.org
  • An active internet connection
  • Familiarity with basic Linux commands

Step 1: Create a Bootable USB

  1. Download the Arch Linux ISO file.
  2. Use the following command to create a bootable USB:
# Replace /dev/sdX with your USB device
sudo dd if=archlinux.iso of=/dev/sdX bs=4M status=progress && sync
  1. Boot from the USB drive by selecting it in your system's BIOS/UEFI menu.

Step 2: Setting Up the Environment

Connect to the Internet

To connect to the internet:

    • Use iwctl for wireless connections.
    • Verify the connection with ping.
# Connect to Wi-Fi
iwctl
> station wlan0 connect "SSID"
# Verify connection
ping archlinux.org

Step 3: Partitioning the Disk

For Standalone Installation

  1. Open the partition manager:
fdisk /dev/sdX
  1. Create these partitions:

    • EFI boot partition (512MB)
    • btrfs root partition (remaining space)
  2. Format the partitions:

# Format the EFI partition
mkfs.fat -F32 /dev/sdX1
 
# Format the root partition with btrfs
mkfs.btrfs /dev/sdX2
  1. Mount the partitions:
mount /dev/sdX2 /mnt
mkdir /mnt/boot
mount /dev/sdX1 /mnt/boot

For Dual Boot

  1. Shrink the existing partition (e.g., Windows) using a tool like:
gparted
  1. Create new partitions as described above and format them.

Step 4: Installing the Base System

  1. Install essential packages:
pacstrap /mnt base linux linux-firmware
  1. Generate the file system table:
genfstab -U /mnt >> /mnt/etc/fstab

Step 5: Configure the System

  1. Change root to the new system:
arch-chroot /mnt
  1. Set up the timezone:
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc
  1. Configure locale:
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen
  1. Set the hostname:
echo "archlinux" > /etc/hostname
  1. Configure the hosts file:
cat <<EOF > /etc/hosts
127.0.0.1   localhost
::1         localhost
127.0.1.1   archlinux.localdomain archlinux
EOF
  1. Set the root password:
passwd
  1. Install and configure the bootloader:
pacman -S grub efibootmgr
 
# For EFI systems
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

Step 6: Using ArchScript for Installation

For an automated approach, use ArchScript:

  1. Download the script:
git clone https://github.com/archlinux/archscript.git
cd archscript
  1. Run the script:
./archscript.sh
  1. Follow the on-screen instructions to:
    • Select your desired disk and partitioning scheme.
    • Automatically set up btrfs subvolumes.
    • Install essential packages and configure the system.

Step 7: Post-Installation Setup

Enable and start services:

# Enable NetworkManager
systemctl enable NetworkManager
systemctl start NetworkManager

Update the system:

pacman -Syu

Troubleshooting

If you encounter issues during installation or boot, use a snapshot (if set up) to restore your system:

btrfs subvolume list /
btrfs subvolume delete /@<snapshot_name>

Quote

Installing Arch is not just about the destination; it’s about the journey of learning.

Arch Enthusiast

Enjoy your Arch Linux experience!