Skip to content

Install Arch Linux from Scratch

This activity puts into practice the concepts from the Linux Server Planning and Configuration lecture. Where Ubuntu’s installer handles partitioning, bootloader installation, user creation, and networking automatically, Arch Linux makes you do each step by hand. That is precisely the point: by the end of this exercise, you will have directly touched every layer of a Linux system that most distributions hide behind a setup wizard.

  • A laptop with a hypervisor installed (VirtualBox, UTM, or similar)
  • The Arch Linux ISO image, downloaded from archlinux.org or the OSU Open Source Lab mirror
  • About 2 GB of free disk space for the VM
  • An internet connection
  1. Create a new VM with these settings:

    • Type: Linux
    • Version: Arch Linux (64-bit)
    • Memory: 1024 MB (1 GB)
    • Hard disk: Create a virtual hard disk, VDI format, dynamically allocated, 8 GB
  2. Before booting, open Settings and adjust:

    • System > Motherboard: Uncheck Floppy from boot order. Check Enable EFI (special OSes only).
    • System > Processor: Set to 2 CPUs.
    • Display: Set video memory to 128 MB.
  3. Under Storage, click the empty optical drive and select the Arch Linux ISO.

  1. Start the VM. Select Arch Linux install medium (x86_64, UEFI) from the boot menu. After about 30 seconds you will land at a root shell prompt.

  2. Verify you have an internet connection (the VM’s NAT adapter piggybacks on your host’s network):

    Terminal window
    ping -c 3 archlinux.org

    If this fails, verify that the VM’s network adapter is enabled and set to NAT.

Lecture concept: This section exercises the Filesystem Layout and Disk Management concepts from the lecture. You will create the partition scheme that the lecture describes in the context of /boot/efi, swap, and the root filesystem.

We will create three partitions using GPT: an EFI System Partition, a swap partition, and a root partition.

  1. Launch the partitioning tool:

    Terminal window
    gdisk /dev/sda
  2. Create the EFI System Partition. Type n for a new partition. Accept the default partition number (1) and default first sector. For the last sector, type +300M. When prompted for the hex code, enter ef00 (EFI System Partition).

    Command (? for help): n
    Partition number (1-128, default 1):
    First sector (34-16777182, default = 2048) or {+-}size{KMGTP}:
    Last sector (...) or {+-}size{KMGTP}: +300M
    Hex code or GUID (L to show codes, Enter = 8300): ef00
  3. Create the swap partition. Type n again. Accept defaults for partition number (2) and first sector. For the last sector, type +400M. Hex code: 8200 (Linux swap).

  4. Create the root partition. Type n again. Accept all defaults (partition 3, default first sector, default last sector to use all remaining space). Accept the default hex code 8300 (Linux filesystem).

  5. Verify your work. Type p to print the partition table. You should see something like:

    Number Start (sector) End (sector) Size Code Name
    1 2048 616447 300.0 MiB EF00 EFI system partition
    2 616448 1435647 400.0 MiB 8200 Linux swap
    3 1435648 16777182 7.3 GiB 8300 Linux filesystem
  6. Write the partition table. Type w and confirm with y.

Each partition needs a filesystem before it can hold data. This is what mkfs does, and it is the same concept as the mkfs.ext4 example from the lecture’s disk management section.

Terminal window
# FAT32 on the EFI partition (required by the UEFI specification)
mkfs.fat -F32 /dev/sda1
# ext4 on the root partition
mkfs.ext4 -F /dev/sda3
# Initialize and activate swap
mkswap /dev/sda2
swapon /dev/sda2

Lecture concept: This mirrors the lecture’s discussion of mount points and /etc/fstab. You are manually doing what the “Mount Points” section describes.

Terminal window
# Mount the root partition
mount /dev/sda3 /mnt
# Create and mount the EFI partition
mkdir -p /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi

This step downloads and installs the core Arch Linux packages into your mounted root partition. The pacstrap tool is Arch’s equivalent of running an installer, but it is transparent: you can see exactly which packages it installs.

Terminal window
pacstrap /mnt base linux vim

This installs about 120 packages including the Linux kernel itself. It will take a few minutes depending on your internet speed.

While it runs, generate the filesystem table so the installed system knows how to mount its own partitions at boot:

Terminal window
genfstab -U /mnt > /mnt/etc/fstab

To configure the installed system, you need to “pivot” into it using chroot (change root). This makes /mnt appear as / so that every command you run applies to the installed system, not the live environment.

Terminal window
arch-chroot /mnt

Verify you are inside the chroot:

Terminal window
pwd
# Should output: /
  1. Set the timezone (adjust if you are not on the US West Coast):

    Terminal window
    cp /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
    date
  2. Configure the locale. Open the locale configuration file:

    Terminal window
    vim /etc/locale.gen

    Find and uncomment these two lines (remove the leading #):

    en_US.UTF-8 UTF-8
    en_US ISO-8859-1
  3. Generate the locale and set it as default:

    Terminal window
    locale-gen
    echo LANG=en_US.UTF-8 > /etc/locale.conf
    export LANG=en_US.UTF-8

Lecture concept: This section directly exercises the Boot Process section from the lecture. You are installing GRUB2 (the bootloader the lecture describes) and configuring it to chainload from UEFI firmware.

  1. Install GRUB and supporting EFI tools:

    Terminal window
    pacman -S grub efibootmgr dosfstools mtools
  2. Install GRUB to the EFI partition:

    Terminal window
    grub-install --target=x86_64-efi --bootloader-id=arch --recheck
  3. Generate the GRUB configuration:

    Terminal window
    grub-mkconfig -o /boot/grub/grub.cfg

Lecture concept: This section exercises the User and Group Management section from the lecture. You will use useradd, configure the wheel group via visudo, and see the same -m, -G, and -s flags the lecture demonstrates.

  1. Install sudo:

    Terminal window
    pacman -S sudo
  2. Open the sudoers file (never edit it directly, always use visudo):

    Terminal window
    visudo

    Find and uncomment this line:

    %wheel ALL=(ALL) ALL

    This grants sudo access to all members of the wheel group, the same concept as Ubuntu’s sudo group that the lecture describes.

  3. Create a regular user with a home directory, bash shell, and wheel group membership:

    Terminal window
    useradd -m -G wheel -s /bin/bash archuser
  4. Set the password:

    Terminal window
    passwd archuser
  1. Exit the chroot:

    Terminal window
    exit
  2. Eject the ISO from the VM’s virtual optical drive (use your hypervisor’s UI).

  3. Reboot:

    Terminal window
    reboot

After a few seconds, GRUB should appear, select Arch Linux, and drop you at a login prompt. Log in as archuser with the password you set.

Lecture concept: This section exercises the Network Configuration Basics section from the lecture. Where the lecture uses Netplan (Ubuntu’s tool), Arch uses systemd-networkd directly. The underlying concepts are the same: identify the interface, configure an address source (DHCP or static), enable the service.

  1. Set a hostname (the lecture covers this with hostnamectl):

    Terminal window
    sudo vim /etc/hostname

    Type a single word (e.g., archbox) and save the file.

  2. Configure /etc/hosts:

    Terminal window
    sudo vim /etc/hosts

    Add these lines:

    127.0.0.1 localhost
    127.0.1.1 archbox.localdomain archbox
  3. Find your network interface name:

    Terminal window
    ip link

    You will see lo (loopback) and one other interface, likely enp0s3 or similar. Note the name.

  4. Create a systemd-networkd configuration file:

    Terminal window
    sudo vim /etc/systemd/network/20-wired.network

    Add the following (substitute your interface name if it differs):

    [Match]
    Name=enp0s3
    [Network]
    DHCP=yes
  5. Enable and start the network service:

    Terminal window
    sudo systemctl enable --now systemd-networkd
  6. Verify you received an IP address:

    Terminal window
    ip addr show

    Look for an inet address on your interface (e.g., 10.0.2.15/24).

  7. Configure DNS so you can resolve domain names:

    Terminal window
    sudo vim /etc/resolv.conf

    Add:

    nameserver 8.8.8.8
    nameserver 8.8.4.4
  8. Test your connection:

    Terminal window
    ping -c 3 archlinux.org

You have now manually performed every step that an Ubuntu installer does automatically. Take a moment to reflect on these connections:

What you did in this activityLecture section it maps to
Created GPT partitions with gdiskFilesystem Layout and Disk Management
Formatted with mkfs.ext4, mkfs.fatFilesystem Layout and Disk Management
Generated /etc/fstab with genfstabMount Points
Installed GRUB to the EFI partitionThe Boot Process
Created a user with useradd -m -G -sUser and Group Management
Configured wheel group via visudoPrivilege Escalation with sudo
Installed packages with pacmanPackage Management
Enabled services with systemctl enable --nowSystemd Services
Configured hostname and /etc/hostsHostname and /etc/hosts
Set up DHCP via systemd-networkdNetwork Configuration Basics

Consider the following questions:

  1. Partitioning: Why does the EFI System Partition use FAT32 instead of ext4? What would happen if you formatted it as ext4?
  2. Boot process: The lecture describes four stages (firmware, bootloader, kernel, systemd). Which steps in this activity correspond to each stage?
  3. Package management: Arch uses pacman where Ubuntu uses apt. What are the equivalent commands for apt update, apt install, and apt upgrade in pacman?
  4. Users: The lecture warns that forgetting the -a flag with usermod -G replaces all supplementary groups. Why did we not need the -a flag when we used useradd -G to create the user?

When you are finished, shut down the VM:

Terminal window
sudo shutdown -h now

You can delete the VM if you no longer need it, or keep it as a sandbox for experimenting with Linux commands from future lectures.