Author | Nejat Hakan |
nejat.hakan@outlook.de | |
PayPal Me | https://paypal.me/nejathakan |
Installing Arch Linux
Introduction
Welcome to the comprehensive guide for installing Arch Linux! This installation journey is often considered a rite of passage in the Linux world. Unlike many other distributions that offer graphical installers and pre-configured setups, Arch Linux provides a minimal base system and expects you, the user, to build your environment from the ground up. This approach offers unparalleled flexibility and a deep understanding of how a Linux system works. This guide is designed for university students and enthusiasts who are eager to learn and are not afraid to get their hands dirty with the command line. We will dive deep into each step, explaining the "whys" and "hows" to ensure you not only install Arch Linux but also grasp the underlying concepts.
What is Arch Linux?
Arch Linux is an independently developed, x86-64 general-purpose GNU/Linux distribution that strives to provide the latest stable versions of most software by following a rolling-release model. The development focus is on simplicity, modernity, pragmatism, user centrality, and versatility.
- Simplicity:
Arch Linux defines simplicity as "without unnecessary additions or modifications." It ships software as released by the original developers (upstream) with minimal down-streaming patching. Configuration is achieved through editing plain text files. - Modernity:
Arch aims to maintain the latest stable release versions of its software as long as systemic package breakage can be reasonably avoided. It is based on a rolling-release system, which allows a one-time installation with continuous updates. - Pragmatism:
Arch is a pragmatic distribution rather than an ideological one. The principles are only useful guidelines. Ultimately, design decisions are made on a case-by-case basis through developer consensus. - User-Centrality:
Arch Linux targets competent Linux users by giving them complete control and responsibility over their system. It is intended for users willing to spend time reading documentation and solving their own problems. - Versatility:
Arch Linux is a general-purpose distribution. Upon installation, only a command-line environment is provided. Rather than tearing out unneeded and unwanted packages, users are offered the ability to build a custom system by choosing among thousands of high-quality packages provided in the official repositories for the x86-64 architecture.
Why Choose Arch Linux?
- Understand Linux Internals:
The installation process itself is a learning experience. You will partition disks, configure the kernel, set up networking, and install a bootloader manually. This provides invaluable insight into the components of a Linux system. - Total Customization:
You install only what you need. There's no bloat. You choose your desktop environment (or window manager), your services, and your applications. - Bleeding Edge Software:
Arch's rolling-release model means you get the latest software versions almost as soon as they are released upstream, provided they are deemed stable. - The Arch Wiki
Arch Linux boasts arguably the best and most comprehensive documentation of any Linux distribution, known as the Arch Wiki. It's an incredible resource not just for Arch users, but for Linux users in general. - AUR (Arch User Repository)
The AUR is a vast, community-driven repository for Arch Linux users. It contains package descriptions (PKGBUILDs) that allow you to compile a package from source with a single command and install it via pacman (Arch's package manager).
Prerequisites
- Hardware:
- An x86-64 compatible machine. Arch Linux does not support 32-bit architecture officially anymore.
- At least 512 MB of RAM (more is recommended for a comfortable live environment and graphical interface later).
- At least 2 GB of disk space for a minimal command-line installation. A graphical desktop environment will require significantly more (20GB+ is a good starting point for
/
and/home
). - A USB drive (2GB or larger) to create the bootable installation medium.
- An active internet connection (Ethernet or Wi-Fi) in the target machine.
- Knowledge:
- Familiarity with basic Linux command-line operations (navigating directories, copying files, editing text files).
- Understanding of basic concepts like disk partitions, file systems, and boot processes is helpful, but we will cover them.
- Patience and a willingness to read documentation (especially the Arch Wiki).
- Mindset:
- Problem-solving attitude. You will likely encounter issues; the ability to research and troubleshoot is key.
- Attention to detail. Typos or missed steps can lead to problems.
Overview of the Installation Process
The Arch Linux installation process can be broadly summarized as follows:
- Pre-installation:
Download the Arch ISO, create a bootable USB, boot into the live environment, connect to the internet, update the system clock, and set the keyboard layout. - Disk Partitioning:
Decide on a partitioning scheme (MBR/GPT, standard partitions, LVM, encryption) and create the necessary partitions on your hard drive. - Formatting and Mounting:
Format the partitions with appropriate file systems (e.g., ext4, Btrfs, XFS, FAT32 for EFI) and mount them. - Base System Installation:
Select mirrors for package downloads and install the base Arch Linux packages onto your newly formatted partitions usingpacstrap
. - System Configuration:
Generate anfstab
file,chroot
into your new system, set the time zone, configure locales, set the hostname, configure networking, create an initramfs, and set the root password. - Bootloader Installation:
Install and configure a bootloader (e.g., GRUB, systemd-boot) so your system can boot without the installation media. - Post-installation:
Reboot into your new system, create a user account, set up sudo, install graphics drivers, and optionally install a desktop environment or window manager, sound server, and common applications.
This guide will walk you through each of these stages in detail, with practical workshops to solidify your understanding.
Workshop Preparing for the Installation
This initial workshop will guide you through the essential preparatory steps before you even boot into the Arch Linux live environment.
Goal:
Download the Arch Linux ISO, verify its integrity, and create a bootable USB drive.
Tools you'll need:
- A computer with an internet connection.
- A USB flash drive (at least 2GB, preferably larger). Warning: This USB drive will be erased.
Steps:
-
Download the Arch Linux ISO:
- Open your web browser and navigate to the official Arch Linux download page:
https://archlinux.org/download/
. - You will find a list of mirrors. Choose a mirror geographically close to you for faster download speeds.
- Download the latest ISO file. It will have a name like
archlinux-YYYY.MM.DD-x86_64.iso
. For example,archlinux-2023.11.01-x86_64.iso
.
- Open your web browser and navigate to the official Arch Linux download page:
-
Verify the ISO Integrity (Crucial Step!):
- On the same download page, you will find checksums for the ISO file (usually SHA256 and MD5). Download the
sha256sums.txt
file or note the SHA256 sum for your ISO. - Why verify?
This ensures the ISO file you downloaded is not corrupted and is an authentic copy from the Arch Linux developers, protecting you from potential issues or malicious modifications. - How to verify:
- On Linux:
Open a terminal in the directory where you downloaded the ISO. Run the command: Compare the output hash with the one provided on the Arch Linux website or in thesha256sums.txt
file. They must match exactly. - On macOS:
Open Terminal. Run: Compare the output hash. - On Windows:
You can use PowerShell: Alternatively, tools like 7-Zip can calculate checksums. Right-click the ISO, go toCRC SHA
, thenSHA-256
.
- On Linux:
- If the checksums do not match, your download is corrupted or incomplete. Download the ISO again from a different mirror if necessary.
- On the same download page, you will find checksums for the ISO file (usually SHA256 and MD5). Download the
-
Create a Bootable USB Drive:
- Warning:
This process will erase all data on your USB drive. Back up any important files from it. - Identify your USB drive's device name.
- On Linux:
Insert the USB drive. Open a terminal and runlsblk
orsudo fdisk -l
. Identify your USB drive (e.g.,/dev/sdb
,/dev/sdc
). Be extremely careful not to choose your system's hard drive. Look at the size and existing partitions to confirm. - On macOS:
You can usediskutil list
in Terminal. - On Windows:
Tools like Rufus will list available USB drives.
- On Linux:
- Writing the ISO:
- On Linux (using
dd
):
This is a powerful command; a typo can wipe your hard drive. Double-checkof=/dev/sdX
. ReplacesdX
with your USB drive identifier (e.g.,sdb
, notsdb1
).sudo dd bs=4M if=/path/to/your/archlinux-YYYY.MM.DD-x86_64.iso of=/dev/sdX status=progress conv=fsync
bs=4M
: Sets block size to 4 Megabytes (can speed up the process).if=...
: Input file (your Arch ISO).of=...
: Output file (your USB drive).status=progress
: Shows progress.conv=fsync
: Ensures data is physically written before the command exits.
- On macOS (using
dd
):
Similar to Linux, but the device name might be like/dev/rdiskX
(raw disk, often faster). Be very careful. - On Windows (using Rufus):
- Download Rufus from
https://rufus.ie/
. It's a portable executable. - Run Rufus.
- Select your USB drive under "Device."
- Click "SELECT" and choose your Arch Linux ISO file.
- Partition scheme: Most modern systems use GPT. MBR might be needed for very old systems. Rufus usually auto-detects well.
- Target system: UEFI (non CSM) is typical.
- File system: Large FAT32 (default).
- Click "START."
- A dialog might ask about "ISO Hybrid" image. Select "Write in DD Image mode" when prompted. This is crucial for Arch Linux ISOs.
- Confirm that you understand the USB drive will be formatted.
- Download Rufus from
- Other tools: BalenaEtcher (cross-platform) is another popular and user-friendly option.
- On Linux (using
- Warning:
-
Safely Eject the USB Drive:
Once the writing process is complete, safely eject the USB drive from your operating system.
You now have a bootable Arch Linux installation medium! In the next section, we'll boot from this USB and begin the installation process.
1. Pre-installation Setup
With your bootable Arch Linux USB drive ready, it's time to boot into the live environment and perform some initial configurations. This environment runs entirely from RAM and the USB drive, allowing you to prepare your system for the Arch Linux installation without touching your existing operating system (if any).
Booting the Live Environment
- Insert the USB Drive:
Plug the Arch Linux bootable USB drive into the computer where you intend to install Arch. - Accessing UEFI/BIOS Settings:
- Restart or power on the target computer.
- Immediately after powering on, you need to press a specific key to enter the UEFI/BIOS setup utility. Common keys include
Del
,F2
,F10
,F12
, orEsc
. The key is often displayed briefly on the screen during startup (e.g., "Press DEL to enter Setup"). If you miss it, consult your computer's or motherboard's manual.
- Boot Order:
- Inside the UEFI/BIOS setup, navigate to the "Boot" or "Boot Order" section.
- Change the boot order to prioritize the USB drive. You want the system to attempt to boot from the USB drive before the internal hard drive.
- If your system is UEFI-based, you might see two entries for your USB drive: one prefixed with "UEFI:" and one without. Choose the "UEFI:" entry if you plan to install Arch Linux in UEFI mode (recommended for modern systems).
- Secure Boot:
- Secure Boot is a UEFI feature that helps ensure that your system boots only trusted software. The default Arch Linux ISO kernel and bootloader are not signed with keys that are typically pre-loaded into motherboard firmware by vendors.
- Recommendation:
For the installation process, it's generally easiest to disable Secure Boot in your UEFI settings. You can re-enable it later if you set up a custom Secure Boot environment with your own keys, but that's an advanced topic beyond this initial installation guide. - The Secure Boot option is usually found in the "Security" or "Boot" section of the UEFI setup.
- Save and Exit:
After configuring the boot order and disabling Secure Boot (if necessary), save your changes and exit the UEFI/BIOS setup. The computer will restart.
If everything is configured correctly, the computer should now boot from the Arch Linux USB drive. You'll be greeted by the Arch Linux boot menu. Select "Arch Linux install medium (x86_64, UEFI)" (or the BIOS equivalent if you're on an older system and not using UEFI). After a series of boot messages, you will be dropped into a Zsh shell prompt, looking something like root@archiso ~ #
. This is the Arch Linux live environment.
Verifying Boot Mode (UEFI or BIOS)
It's crucial to know whether you've booted in UEFI mode or legacy BIOS mode, as this will dictate how you partition your disk and install the bootloader.
To verify the boot mode, list the efivars
directory. If the command shows the directory and its contents without error, you are booted in UEFI mode. If the directory does not exist, you are likely in BIOS (or CSM) mode.
- UEFI Mode Output:
You will see a list of files and directories. - BIOS Mode Output:
You will see an error likels: cannot access '/sys/firmware/efi/efivars': No such file or directory
.
Ensure this matches your intended installation mode. If you want a UEFI install but booted in BIOS mode (or vice-versa), reboot and check your UEFI/BIOS settings. You might need to explicitly enable/disable UEFI boot or Legacy/CSM boot options.
Connecting to the Internet
An internet connection is required to download packages.
Wired Connection (Ethernet)
If you have an Ethernet cable connected, the network connection should usually be established automatically via DHCP.
- Verify:
You can check your connection by pinging a reliable server: PressCtrl+C
to stop pinging. If you get replies, you're connected. - Check IP Address:
Look for your Ethernet interface (e.g.,
enpXsY
oreth0
) and see if it has an IP address. - If no connection: The
dhcpcd
client should run automatically. If you suspect it hasn't, you can try to start it manually for your interface (e.g.,dhcpcd enp2s0
).
Wireless Connection (Wi-Fi)
For Wi-Fi, you'll use the iwctl
utility.
-
Start
You'll enter theiwctl
interactive prompt:iwctl
prompt, which might look like[iwd]#
. -
List Wi-Fi devices:
This will show available wireless devices, e.g.,wlan0
. Note your device name. -
Scan for networks (replace
wlan0
with your device name if different): -
List available networks:
This will display a list of SSIDs (network names) with their security types. -
Connect to a network:
Replace"Your_SSID_Name"
with the actual name of your Wi-Fi network. If the network is password-protected (e.g., WPA2/PSK),iwctl
will prompt you to enter the passphrase. Type it carefully. -
Check connection status:
Look forState: connected
and an IP address. -
Exit
iwctl
: -
Verify internet connectivity:
PressCtrl+C
to stop.
If you have trouble, ensure your Wi-Fi adapter is not blocked (rfkill list
) and that you entered the correct SSID and passphrase.
Updating the System Clock
Accurate time is important for secure connections (TLS/SSL certificate validation) and file timestamps.
This command enables Network Time Protocol (NTP) synchronization, which will set your system clock accurately using internet time servers.You can verify the status:
Look forNTP service: active
and check if the time and date are correct.
Keyboard Layout
The default console keyboard layout is US. If you use a different layout (e.g., German, French, UK English), you should set it now to avoid frustration when typing commands or passwords.
-
List available layouts (optional, if you don't know the exact name):
Or for UK English: Common layouts include
Layout files are located in/usr/share/kbd/keymaps/
. You can list them, for example, for German layouts:de-latin1
(German),fr
(French),uk
(United Kingdom),es
(Spanish), etc. -
Set the keyboard layout:
For a UK layout: This setting is temporary for the live environment. We will make it persistent later during system configuration. Test a few special characters to ensure it's working as expected.
Use theloadkeys
command. For example, for a German layout:
Workshop Navigating the Live Environment and Basic Commands
Goal:
Practice navigating the Arch Linux live environment, confirm your boot mode, establish an internet connection, synchronize the system clock, and set your keyboard layout. This workshop reinforces the initial setup steps.
Scenario:
You have just booted into the Arch Linux live environment (root@archiso ~ #
prompt).
Steps:
-
Confirm Your Shell:
- The default shell in the Arch ISO is Zsh. You can confirm this by typing:
- Expected output:
/bin/zsh
or similar.
-
Basic Navigation and Listing Files:
- Check your current directory:
(Should be
/root
) - List files in the current directory:
(
-a
shows hidden files) - Explore the root of the filesystem:
You'll see directories like
bin
,etc
,usr
,sys
, etc. Briefly identify what some of these might contain. (e.g.,sys
for system information,etc
for configuration files).
- Check your current directory:
(Should be
-
Verify Boot Mode:
- Execute the command to check for UEFI:
- Interpret the output:
- If you see a list of files, you are in UEFI mode. Make a note of this.
- If you get "No such file or directory," you are in BIOS mode. Make a note of this.
- This is critical for later steps, especially partitioning and bootloader installation.
-
Network Setup Practice:
- If using Ethernet:
- Check your IP address:
ip addr show
(look for aninet
address on your Ethernet interface, e.g.,enp2s0
). - Test connectivity:
ping -c 3 archlinux.org
(The-c 3
sends 3 packets).
- Check your IP address:
- If using Wi-Fi (even if you connected earlier, practice with
iwctl
):- Enter
iwctl
. - Type
device list
to see your Wi-Fi adapter (e.g.,wlan0
). - If your adapter name is
wlan0
, scan for networks:station wlan0 scan
. Wait a few seconds. - List networks:
station wlan0 get-networks
. - Attempt to connect (re-connect if already connected, or connect to a different one if available):
station wlan0 connect "YOUR_SSID"
(You'll be prompted for a password if it's secured). - Check status:
station wlan0 show
. - Exit
iwctl
:exit
. - Test connectivity:
ping -c 3 google.com
.
- Enter
- If using Ethernet:
-
Update System Clock:
- Enable NTP:
- Check the status and verify the time: Ensure "NTP service: active" is shown and the "Universal time" and "Local time" are correct.
-
Set Keyboard Layout (Practice):
- Let's assume you want to try the Dvorak layout (a common alternative layout, just for practice).
- Try typing a few common keys. For example, on a QWERTY keyboard, typing 'j' should produce 'c', 'k' should produce 't', 'f' should produce 'u'. This demonstrates the layout has changed.
- Now, revert to the US layout (or your preferred one if it's not US): Or, for example, for a German layout:
- Test typing again to confirm it's back to your desired layout.
Reflection:
- Were you able to successfully verify your boot mode? Why is this important?
- Did you manage to connect to the internet? If you faced issues, what steps did you take to troubleshoot?
- Is your system clock now synchronized?
- Could you change and revert the keyboard layout?
This workshop ensures you are comfortable with these fundamental pre-installation steps. Having these sorted out correctly will make the rest of the installation process smoother.
2. Disk Partitioning Strategies
Disk partitioning is one of the most critical steps in installing Arch Linux. It involves dividing your hard drive (or SSD) into separate sections, each of which can be formatted with a file system and used for a specific purpose (e.g., storing the operating system, user data, or swap space). A well-thought-out partitioning scheme can improve organization, performance, and flexibility.
We will primarily focus on UEFI/GPT partitioning, as it is the modern standard. We'll also briefly touch upon BIOS/MBR for older systems.
Understanding Disk Partitioning
-
MBR (Master Boot Record):
- An older partitioning scheme, traditionally used with BIOS-based systems.
- Limitations: Supports a maximum of 4 primary partitions (or 3 primary and 1 extended, which can contain multiple logical partitions).
- Limited to disks up to 2TB in size.
- The boot code and partition table are stored in the first sector of the disk, making it vulnerable.
-
GPT (GUID Partition Table):
- A modern partitioning scheme, part of the UEFI standard. It can also be used with BIOS systems with appropriate bootloaders.
- Advantages: Supports a virtually unlimited number of partitions (Windows limits it to 128).
- Supports disks larger than 2TB (up to Zettabytes).
- Stores multiple copies of the partition table across the disk for redundancy, making it more robust.
- Uses Globally Unique Identifiers (GUIDs) for disks and partitions.
-
Common Partitions and Their Purpose:
- EFI System Partition (ESP):
- Required for UEFI-based systems.
- Formatted with FAT32.
- Stores bootloader files, kernel images, and other boot-related files.
- Typically mounted at
/boot
or/efi
. Recommended size: 260MB to 550MB.
- /boot:
- In BIOS systems, this partition sometimes holds the kernel images and bootloader configuration if the root filesystem uses a type not understood by the bootloader, or if using LVM/encryption for root.
- In UEFI systems, if the ESP is mounted at
/efi
,/boot
can be a separate partition on the main filesystem or part of the root filesystem. If ESP is mounted at/boot
, then/boot
is the ESP. - Recommended size: 512MB to 1GB if separate.
- Root (
/
):- The top-level directory of the filesystem hierarchy.
- Contains the core operating system files, system libraries, and applications.
- Required for any Linux installation.
- Recommended size: At least 20GB for a basic system with a desktop environment. 30-50GB is a safer bet for future growth and package cache.
- Home (
/home
):- Contains user-specific data, documents, and configuration files.
- Highly recommended to have
/home
as a separate partition. This allows you to reinstall the OS (or even switch distributions) without losing your personal files. - Size: Depends on your needs. Allocate the majority of your remaining disk space here if you store large files (videos, photos, virtual machines).
- Swap:
- Used as virtual memory when your physical RAM is full.
- Also used for hibernation (suspend-to-disk), where the contents of RAM are written to swap before powering off.
- Can be a dedicated partition or a swap file.
- Size:
- If not using hibernation: RAM size is a common recommendation, but can be less (e.g., 2-4GB) if you have plenty of RAM (16GB+).
- If using hibernation: Must be at least the size of your RAM, preferably slightly larger (RAM size + sqrt(RAM size) or RAM size + 2GB).
- EFI System Partition (ESP):
Partitioning Tools
Arch Linux live environment provides several command-line partitioning tools:
fdisk
:
A classic, dialog-driven tool for MBR and GPT (basic GPT support). Good for MBR.gdisk
:
Similar tofdisk
but specifically designed for GPT. It's often preferred for GPT partitioning due to its more comprehensive GPT feature set. Its interactive menu is very similar tofdisk
.cfdisk
:
A curses-based (text UI) frontend forfdisk
. It provides a more user-friendly, visual way to manage partitions. It supports both MBR and GPT. Many beginners find this easier to use.parted
:
A very powerful, scriptable partitioning tool. It can be used interactively or non-interactively. It has a steeper learning curve but offers more advanced capabilities.
For this guide, we'll primarily use cfdisk
or gdisk
due to their relative ease of use and suitability for GPT.
Identifying Your Disk:
Before partitioning, you need to identify the target disk. Use lsblk
or fdisk -l
:
/dev/sda
, /dev/sdb
, or /dev/nvme0n1
(for NVMe SSDs). Be absolutely sure you select the correct disk, as partitioning will erase its data.
Scenario 1 Simple UEFI/GPT Setup (Swap File to be configured later)
This is a common and straightforward setup for modern desktops/laptops with UEFI firmware. We will create an EFI System Partition, a root partition, and a home partition. We'll plan for a swap file later, instead of a dedicated swap partition, for simplicity and flexibility in this scenario.
Partitions to create on /dev/sdX
(or /dev/nvme0n1pX
for NVMe):
- EFI System Partition (ESP):
- Size: 512MB (A good general-purpose size, e.g.,
+512M
) - Type: EFI System (GUID:
C12A7328-F81F-11D2-BA4B-00A0C93EC93B
) - Mount point:
/boot
(or/efi
- we'll use/boot
for simplicity here initially)
- Size: 512MB (A good general-purpose size, e.g.,
- Root Partition (
/
):- Size: 30GB-50GB (e.g.,
+30G
or+50G
). Adjust based on your needs. - Type: Linux x86-64 root (GUID:
4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709
if using systemd auto-discovery, otherwise Linux filesystem0FC63DAF-8483-4772-8E79-3D69D8477DE4
is fine) - Mount point:
/
- Size: 30GB-50GB (e.g.,
- Home Partition (
/home
):- Size: Remainder of the disk (or a specific large size if you have other plans for remaining space).
- Type: Linux filesystem (GUID:
0FC63DAF-8483-4772-8E79-3D69D8477DE4
) - Mount point:
/home
Using cfdisk
for UEFI/GPT (Example on /dev/sda
):
- Start
cfdisk
on your target disk: - Select Label Type:
If the disk is new or you want to re-initialize,cfdisk
will ask for a label type. Choosegpt
. - Creating the ESP:
- Select
[ New ]
using arrow keys and press Enter. - Partition size: Enter
512M
and press Enter. - Select
[ Type ]
, press Enter. Scroll through the list or start typing "EFI" to find "EFI System". Select it and press Enter.
- Select
- Creating the Root Partition:
- Ensure the free space below the ESP is selected. Select
[ New ]
. - Partition size: Enter
30G
(or your desired size) and press Enter. - The default type "Linux filesystem" is usually fine for root. If you want to be specific for systemd auto-discovery of root, you'd need
gdisk
to set the GUID4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709
. For now, "Linux filesystem" is acceptable.
- Ensure the free space below the ESP is selected. Select
- Creating the Home Partition:
- Ensure the remaining free space is selected. Select
[ New ]
. - Partition size: Press Enter to use all remaining space (or specify a size).
- The default type "Linux filesystem" is correct for home.
- Ensure the remaining free space is selected. Select
- Write Changes:
- Once all partitions are defined, select
[ Write ]
. - Type
yes
to confirm and press Enter. This action is irreversible and will write the partition table to the disk.
- Once all partitions are defined, select
- Exit
cfdisk
:- Select
[ Quit ]
and press Enter.
- Select
After exiting, verify the partitions:
You should see/dev/sda1
(ESP), /dev/sda2
(root), and /dev/sda3
(home) with their respective sizes.
Scenario 2 UEFI/GPT Setup with a Dedicated Swap Partition (for Hibernation)
This setup is similar to Scenario 1 but includes a dedicated swap partition, which is generally required if you plan to use hibernation.
Partitions to create on /dev/sdX
:
- EFI System Partition (ESP):
- Size: 512MB
- Type: EFI System
- Swap Partition:
- Size: At least your RAM size, e.g., if you have 8GB RAM, use
8G
or10G
. - Type: Linux swap (GUID:
0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
)
- Size: At least your RAM size, e.g., if you have 8GB RAM, use
- Root Partition (
/
):- Size: 30GB-50GB
- Type: Linux filesystem
- Home Partition (
/home
):- Size: Remainder of the disk.
- Type: Linux filesystem
Using gdisk
for UEFI/GPT (Example on /dev/sda
):
gdisk
offers more control over GPT partition types using GUIDs.
- Start
gdisk
on your target disk: - Creating a New GPT (if necessary):
If the disk has an MBR or is blank,gdisk
might warn you. If you want to create a new GPT, it might do so automatically or you might need to use theo
command (be careful, this wipes existing partition tables). - Creating the ESP (
/dev/sda1
):- Command:
n
(new partition) - Partition number:
1
(default) - First sector: (default)
- Last sector or size:
+512M
- Hex code or GUID:
EF00
(this isgdisk
's shorthand for EFI System Partition)
- Command:
- Creating the Swap Partition (
/dev/sda2
):- Command:
n
- Partition number:
2
- First sector: (default)
- Last sector or size:
+8G
(or your desired swap size) - Hex code or GUID:
8200
(Linux swap)
- Command:
- Creating the Root Partition (
/dev/sda3
):- Command:
n
- Partition number:
3
- First sector: (default)
- Last sector or size:
+30G
- Hex code or GUID:
8300
(Linux filesystem) or8304
for Linux x86-64 root (optional detailed type)
- Command:
- Creating the Home Partition (
/dev/sda4
):- Command:
n
- Partition number:
4
- First sector: (default)
- Last sector or size: (default, uses remaining space)
- Hex code or GUID:
8300
(Linux filesystem)
- Command:
- Verify Partitions:
- Command:
p
(print partition table) - Review the list to ensure everything is correct (partition numbers, sizes, types).
- Command:
- Write Changes:
- Command:
w
(write table to disk and exit) - Confirm:
Y
- This step writes the changes. Be sure before confirming.
- Command:
Verify with lsblk /dev/sda
.
Scenario 3 UEFI/GPT with LVM (Logical Volume Management)
LVM adds a layer of abstraction over physical partitions, allowing for more flexible volume management, such as easy resizing of logical volumes, snapshots, and combining multiple disks into a single volume group.
Disk Layout Strategy:
- EFI System Partition (ESP):
- Size: 512MB
- Type: EFI System
- Note:
The ESP cannot be on an LVM volume. It must be a regular partition.
- (Optional but Recommended)
/boot
Partition:- Size: 1GB
- Type: Linux filesystem
- Note:
While GRUB can boot from LVM, having a separate/boot
partition (not on LVM) can simplify recovery and some bootloader configurations, especially for beginners. If you omit this, ensure your bootloader (GRUB) has LVM support compiled in and can access the kernel on the LVM root. For this guide, we'll include it.
- LVM Physical Volume Partition:
- Size: Remainder of the disk.
- Type: Linux LVM (GUID:
E6D6D379-F507-44C2-A23C-238F2A3DF928
, or8E00
ingdisk
) - This partition will house the LVM structures.
Inside LVM (after OS installation and chroot):
- Physical Volume (PV):
Created on the LVM partition (e.g.,/dev/sda3
). - Volume Group (VG):
A pool of storage created from one or more PVs (e.g.,vg0
). - Logical Volumes (LVs):
Carved out from the VG for:lv_root
(for/
)lv_home
(for/home
)lv_swap
(for swap)
Partitioning Steps (using cfdisk
or gdisk
):
- Create ESP (
/dev/sda1
, 512M, type EFI System). - Create
/boot
partition (/dev/sda2
, 1G, type Linux filesystem). - Create LVM partition (
/dev/sda3
, remaining space, type Linux LVM).- In
cfdisk
: Select "Linux LVM". - In
gdisk
: Use hex code8E00
.
- In
- Write changes and exit.
The LVM setup (PV, VG, LVs) will be done after partitioning and before formatting these LVs, typically right before or during the "Formatting Partitions" stage. We'll cover LVM creation commands there.
Scenario 4 UEFI/GPT with LUKS Full-Disk Encryption (on LVM)
This provides strong data protection by encrypting your main partitions. We'll encrypt the LVM physical volume.
Disk Layout Strategy:
- EFI System Partition (ESP):
- Size: 512MB
- Type: EFI System (unencrypted)
- Mount point:
/boot/efi
(or/boot
if it's also the boot partition, but/boot/efi
is cleaner if/boot
is separate)
- /boot Partition:
- Size: 1GB
- Type: Linux filesystem (unencrypted)
- Mount point:
/boot
- Reasoning:
The bootloader needs to load the kernel and initramfs before it can decrypt anything. So,/boot
(containing kernel, initramfs, bootloader config) and ESP (containing bootloader executable) are typically left unencrypted. You can encrypt/boot
with GRUB, but it adds complexity.
- LUKS Encrypted Partition:
- Size: Remainder of the disk.
- Type: Linux filesystem (this will be overwritten by LUKS).
- This partition will be formatted as a LUKS container.
- Inside LUKS: LVM will be set up.
- PV on the opened LUKS container (e.g.,
/dev/mapper/cryptlvm
). - VG on this PV.
- LVs for root, home, swap within the VG.
- PV on the opened LUKS container (e.g.,
Partitioning Steps (using cfdisk
or gdisk
):
- Create ESP (
/dev/sda1
, 512M, type EFI System). - Create
/boot
partition (/dev/sda2
, 1G, type Linux filesystem). - Create a partition for LUKS (
/dev/sda3
, remaining space, type Linux filesystem). - Write changes and exit.
The LUKS setup (cryptsetup luksFormat
, cryptsetup open
) and subsequent LVM setup will be done before formatting the LVs, during the "Formatting Partitions" stage.
Scenario 5 BIOS/MBR Setup (Legacy Systems)
For very old systems that only support BIOS booting and MBR partitioning.
Partitions to create on /dev/sdX
(using fdisk
or cfdisk
with dos
label type):
- (Optional) Boot Partition (
/boot
):- Size: 512MB - 1GB
- Type: Linux (Type 83)
- Purpose: Useful if your root filesystem is LVM or a type the MBR bootloader (like legacy GRUB) can't read directly. If root is a simple ext4, this might not be strictly needed, but it's good practice.
- Bootable flag:
This partition (or the root partition if /boot is not separate) often needs the "bootable" flag set infdisk
/cfdisk
.
- Root Partition (
/
):- Size: 30GB-50GB
- Type: Linux (Type 83)
- Swap Partition:
- Size: RAM size or as needed.
- Type: Linux swap / Solaris (Type 82)
- Home Partition (
/home
):- Size: Remainder of the disk.
- Type: Linux (Type 83)
Using cfdisk
for BIOS/MBR (Example on /dev/sda
):
- Start
cfdisk
: - Select Label Type:
Choosedos
. - Create partitions similar to the GPT examples, but the types will be simpler ("Linux", "Linux swap").
- Set Bootable Flag:
Select the partition that will contain your bootloader's core files (usually the/boot
partition if you have one, or the root partition if/boot
is not separate). Choose[ Bootable ]
to toggle the flag. Only one partition should typically be marked bootable on MBR. - Write changes and quit.
Workshop Partitioning a Virtual Disk (UEFI/GPT with Swap for Hibernation)
Goal:
Gain hands-on experience partitioning a disk using cfdisk
or gdisk
for a UEFI/GPT system, including an ESP, root, home, and a dedicated swap partition. This prepares for hibernation.
Recommendation:
If you are installing on a real machine and are unsure, PRACTICE ON A VIRTUAL MACHINE FIRST or use a spare USB drive as your target disk (e.g., /dev/sdb
). DO NOT experiment on a disk with important data unless you have backups and know what you are doing.
For this workshop, let's assume you are using a spare disk /dev/sdb
(replace with your actual target, like /dev/sda
if installing on a primary disk, or a VM's virtual disk).
Chosen Scheme:
Scenario 2 (UEFI/GPT with ESP, Swap, Root, Home)
Disk: /dev/sdb
(example, VERIFY YOUR DISK LABEL)
Partitions Plan:
/dev/sdb1
: ESP, 512MB, Type: EFI System/dev/sdb2
: Swap, (e.g., 4GB if you have 4GB RAM, or adjust), Type: Linux swap/dev/sdb3
: Root (/
), 30GB, Type: Linux filesystem/dev/sdb4
: Home (/home
), Remainder, Type: Linux filesystem
Steps using cfdisk
:
-
Identify your target disk:
Confirm the device name (e.g.,/dev/sdb
). Triple-check this! -
Unmount any existing partitions on the target disk (if any):
(The
Iflsblk
shows any mount points for/dev/sdb
or its partitions (e.g.,/dev/sdb1
mounted at/run/media/user/SOMETHING
), unmount them:*
is a wildcard, be careful. Or unmount individually:umount /dev/sdb1
) -
Start
cfdisk
: -
Select Label Type:
- If the disk is new or has an MBR,
cfdisk
will prompt for a label type. - Navigate to
gpt
using arrow keys and press Enter. - If the disk already has a GPT table you want to overwrite, you might need to delete existing partitions first. Select a partition, then choose
[ Delete ]
.
- If the disk is new or has an MBR,
-
Create the EFI System Partition (
/dev/sdb1
):- With the "Free space" selected at the top, select
[ New ]
and press Enter. - Partition size: Type
512M
and press Enter. - Primary/logical: (GPT doesn't use this distinction in the same way as MBR, just press Enter).
- The new partition (e.g.,
/dev/sdb1
) will be selected. Select[ Type ]
and press Enter. - Scroll or type to find "EFI System". Select it and press Enter.
- With the "Free space" selected at the top, select
-
Create the Swap Partition (
/dev/sdb2
):- Use arrow keys to select the "Free space" below
/dev/sdb1
. - Select
[ New ]
and press Enter. - Partition size: Type your desired swap size, e.g.,
4G
(for 4 Gigabytes) or8G
, and press Enter. - The new partition (
/dev/sdb2
) will be selected. Select[ Type ]
and press Enter. - Scroll or type to find "Linux swap". Select it and press Enter.
- Use arrow keys to select the "Free space" below
-
Create the Root Partition (
/dev/sdb3
):- Select the "Free space" below
/dev/sdb2
. - Select
[ New ]
and press Enter. - Partition size: Type
30G
(or your chosen size for root) and press Enter. - The new partition (
/dev/sdb3
) will be selected. The default type "Linux filesystem" is usually correct. Press Enter to confirm (or select[ Type ]
and choose "Linux filesystem" if needed).
- Select the "Free space" below
-
Create the Home Partition (
/dev/sdb4
):- Select the remaining "Free space" below
/dev/sdb3
. - Select
[ New ]
and press Enter. - Partition size: Press Enter to accept the default, which will use all remaining space.
- The new partition (
/dev/sdb4
) will be selected. The default type "Linux filesystem" is correct. Press Enter.
- Select the remaining "Free space" below
-
Review Your Partitions:
(Numbers will vary based on your disk and chosen sizes.)
Your screen should now list: -
Write Changes to Disk:
- This is the point of no return for the data on
/dev/sdb
. - Select
[ Write ]
using arrow keys and press Enter. cfdisk
will ask for confirmation: "Are you sure you want to write the partition table to disk?"- Type
yes
(all lowercase) and press Enter.
- This is the point of no return for the data on
-
Exit
cfdisk
:- Select
[ Quit ]
and press Enter.
- Select
-
Verify the New Partition Table:
- Run
lsblk
again: Output should be similar to: - You can also use
fdisk -l /dev/sdb
for a more detailed view.
- Run
Congratulations! You have successfully partitioned your disk according to the chosen scheme. The next step will be to format these newly created partitions with appropriate file systems. If you were using gdisk
, the steps would involve using commands like n
(new), t
(change type code - EF00
for ESP, 8200
for swap, 8300
for Linux filesystem), p
(print), and w
(write).
3. Formatting Partitions and Mounting File Systems
After partitioning your disk, the next step is to create file systems on these raw partitions. A file system is a structure that allows the operating system to store, organize, and retrieve files on a storage device. We also need to activate the swap partition if one was created. Finally, we'll mount these file systems into a proper hierarchy under /mnt
to prepare for the base system installation.
Choosing a File System
Arch Linux supports various file systems. Here are some common choices for your Linux partitions (/
, /home
, /boot
if separate and not ESP):
-
Ext4 (Fourth Extended Filesystem):
- Pros:
Very mature, stable, widely used, and well-tested. Good all-around performance. Journaling helps protect against data corruption from crashes. - Cons:
Lacks some modern features like built-in snapshots or transparent compression found in Btrfs or ZFS. - Recommendation:
Excellent choice for reliability, especially for root (/
) and home (/home
) if you prefer stability and widespread support.
- Pros:
-
Btrfs (B-tree Filesystem):
- Pros:
Modern Copy-on-Write (CoW) filesystem with advanced features like snapshots (great for system rollbacks), checksums for data integrity, built-in RAID capabilities, transparent compression, and integrated volume management (can manage multiple devices and subvolumes which act like flexible partitions). - Cons:
Younger than Ext4, and some advanced features are still maturing. Performance can sometimes be variable, especially with high fragmentation or certain CoW overheads. - Recommendation:
Good for users who want advanced features like snapshots and data integrity. Often used for both/
and/home
. Requires a bit more understanding to manage its features effectively.
- Pros:
-
XFS (Extended File System):
- Pros:
High-performance filesystem, excels at parallel I/O and handling large files. Mature and robust. - Cons:
Resizing (shrinking) XFS partitions can be difficult or impossible. Less feature-rich in terms of snapshots compared to Btrfs. - Recommendation:
Suitable for large storage servers, systems dealing with very large files (e.g., video editing), or/home
partitions if large file performance is critical.
- Pros:
-
FAT32 (File Allocation Table 32):
- Use Case:
This is required for the EFI System Partition (ESP). UEFI firmware can read FAT32. - Pros:
Universally compatible. - Cons:
Lacks journaling, permissions, and other features of modern Linux filesystems. Limited file and partition sizes (though generally not an issue for ESP).
- Use Case:
-
Swap:
- This isn't a file system for storing user files, but a special format for swap space.
For this guide, we'll primarily use Ext4 for /
and /home
due to its stability and simplicity, and FAT32 for the ESP. If you chose Btrfs or XFS, the mkfs
command will change accordingly.
Formatting the Partitions
Let's assume you followed the workshop in the previous section and have these partitions on /dev/sdb
(adjust device names like /dev/sda
or /dev/nvme0n1pX
as per your setup):
/dev/sdb1
: EFI System Partition/dev/sdb2
: Swap Partition/dev/sdb3
: Root Partition/dev/sdb4
: Home Partition
Commands to format:
-
Format the EFI System Partition (ESP):
The ESP (e.g.,/dev/sdb1
) must be formatted as FAT32.mkfs.fat
: Command to create a FAT filesystem.-F32
: Specifies FAT32 format./dev/sdb1
: Your ESP partition. Double-check this device name!
-
Format the Root Partition (
/
):
Let's format the root partition (e.g.,/dev/sdb3
) as Ext4.mkfs.ext4
: Command to create an Ext4 filesystem./dev/sdb3
: Your root partition.- If you wanted Btrfs:
mkfs.btrfs /dev/sdb3
- If you wanted XFS:
mkfs.xfs /dev/sdb3
(you might need to installxfsprogs
first if not available:pacman -S xfsprogs
)
-
Format the Home Partition (
/home
) (if you created a separate one):
Let's format the home partition (e.g.,/dev/sdb4
) as Ext4./dev/sdb4
: Your home partition.- Similarly, use
mkfs.btrfs
ormkfs.xfs
if you chose those for/home
.
-
Initialize and Activate the Swap Partition:
If you created a swap partition (e.g.,/dev/sdb2
):mkswap
: Command to set up a Linux swap area./dev/sdb2
: Your swap partition.
After initializing, you need to activate it for the current live session (it will be permanently enabled later via
You can verify swap is active with: orfstab
):
Important Note on LVM/LUKS:
- If you set up LVM (Scenario 3 in partitioning):
- Create Physical Volume (PV):
pvcreate /dev/sdaX
(your LVM partition) - Create Volume Group (VG):
vgcreate myvolumegroup /dev/sdaX
- Create Logical Volumes (LVs):
- Then format the LVs: (And format ESP and /boot partition as usual if they are separate non-LVM partitions.)
- Create Physical Volume (PV):
- If you set up LUKS (Scenario 4 in partitioning):
- Encrypt the partition:
cryptsetup luksFormat /dev/sdaX
(your LUKS partition) - Open the LUKS container:
cryptsetup open /dev/sdaX cryptlvm
(this creates/dev/mapper/cryptlvm
) - Then, set up LVM on
/dev/mapper/cryptlvm
as described above (e.g.,pvcreate /dev/mapper/cryptlvm
, etc.). - Format LVs as above.
- Encrypt the partition:
Mounting the File Systems
Now that the partitions are formatted, you need to mount them into a directory structure rooted at /mnt
. This directory will temporarily represent the root filesystem of your new Arch Linux system.
-
Mount the Root Partition (
/
):
The root partition (e.g.,/dev/sdb3
or/dev/myvolumegroup/rootvol
if using LVM) must be mounted to/mnt
.mount
: The command to attach a filesystem to a specific directory./dev/sdb3
: Your formatted root partition./mnt
: The mount point.
-
Create Mount Points for Other Partitions within
/mnt
:
If you have other partitions like ESP (/boot
or/boot/efi
) and/home
, you need to create directories for them inside/mnt
before mounting.-
For the ESP:
If you chose
The Arch Wiki and many guides recommend mounting the ESP at/mnt/boot
. This is simple and works well. Another common practice is/mnt/efi
, and then/boot
would be part of the root filesystem or a separate partition. We will use/mnt/boot
for the ESP here./mnt/efi
(and/boot
is not a separate partition to be mounted there): -
For the Home partition:
-
For a separate /boot partition (if you have one, e.g., in LVM/LUKS scenarios):
If/dev/sda2
was your separate/boot
partition (NOT the ESP):However, for our primary example (Scenario 2 partitions: ESP, Swap, Root, Home), the ESP# mkdir /mnt/boot (if not already made for ESP) # mount /dev/sda2 /mnt/boot # mkdir /mnt/boot/efi (now create subdir for ESP) # mount /dev/sda1 /mnt/boot/efi (mount ESP here)
/dev/sdb1
will be mounted directly to/mnt/boot
.
-
-
Mount the EFI System Partition (ESP):
Mount your ESP (e.g.,/dev/sdb1
) to the directory you created for it. For our example,/mnt/boot
:- If you chose
/mnt/efi
as the mount point for ESP:mount /dev/sdb1 /mnt/efi
- If you chose
-
Mount the Home Partition (
/home
):
Mount your home partition (e.g.,/dev/sdb4
or/dev/myvolumegroup/homevol
) to/mnt/home
: -
Verify Mounts:
You should see your partitions listed with their respective mount points under
Check that all partitions are mounted correctly:/mnt
(e.g.,/mnt
,/mnt/boot
,/mnt/home
). Example output for our Scenario 2:You can also useNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdb 8:16 0 XXG 0 disk ├─sdb1 8:17 0 512M 0 part /mnt/boot <-- ESP ├─sdb2 8:18 0 4G 0 part [SWAP] <-- Swap ├─sdb3 8:19 0 30G 0 part /mnt <-- Root └─sdb4 8:20 0 XXG 0 part /mnt/home <-- Home
df -h
to see disk usage and mount points.
Btrfs Specifics (Subvolumes) - Optional advanced topic
If you chose Btrfs for your root filesystem (e.g., on /dev/sdb3
), you might want to use subvolumes for better organization and snapshot capabilities. A common Btrfs layout involves creating subvolumes for root (@
) and home (@home
), and potentially others like @var
, @snapshots
.
-
Format the Btrfs partition:
(-L
sets a label, optional). -
Mount the top-level Btrfs filesystem:
-
Create Btrfs subvolumes:
-
Unmount the top-level Btrfs filesystem:
-
Mount the Btrfs subvolumes with specific options:
Common options includecompress=zstd
(orlzo
),ssd
(if on an SSD),noatime
orrelatime
.If# Mount the '@' subvolume as the system's root mount -o subvol=@,compress=zstd,ssd,noatime /dev/sdb3 /mnt # Create mount points for other subvolumes and ESP mkdir -p /mnt/home mkdir -p /mnt/boot # Or /mnt/efi, and then /mnt/boot/efi # Mount the '@home' subvolume mount -o subvol=@home,compress=zstd,ssd,noatime /dev/sdb3 /mnt/home # Mount ESP (e.g., /dev/sdb1) # mkfs.fat -F32 /dev/sdb1 (if not done) mount /dev/sdb1 /mnt/boot # Or /mnt/boot/efi # Activate swap (if using a swap partition) # mkswap /dev/sdb2 # swapon /dev/sdb2
/home
was on a separate Btrfs partition (e.g./dev/sdb4
), you'd format that, mount it temporarily, create its own@home
subvolume, unmount, then mount the subvolume to/mnt/home
.
This is a more advanced setup. For simplicity in the main guide, we are sticking to Ext4, but it's good to be aware of Btrfs subvolumes.
Workshop Formatting and Mounting Your Partitions
Goal: Format the partitions created in the previous workshop (ESP as FAT32, root as Ext4, home as Ext4, swap as swap). Mount them correctly under /mnt
and activate swap.
Prerequisites: You have completed the partitioning workshop and have partitions similar to:
/dev/sdb1
: ESP/dev/sdb2
: Swap/dev/sdb3
: Root/dev/sdb4
: Home (Remember to replace/dev/sdbX
with your actual device names, e.g.,/dev/sdaX
or/dev/nvme0n1pX
)
Steps:
-
Verify Your Partition Scheme:
Or for more detail: Identify which partition is for ESP, which for swap, which for root (
Before formatting, list your partitions one last time to be absolutely sure of the device names and their intended purposes./
), and which for home (/home
). Let's say they are/dev/sdb1
(ESP),/dev/sdb2
(Swap),/dev/sdb3
(Root),/dev/sdb4
(Home). -
Format the EFI System Partition (ESP):
Assuming/dev/sdb1
is your ESP: -
Initialize and Activate Swap Partition:
Assuming/dev/sdb2
is your swap partition:Theecho "Initializing swap on /dev/sdb2..." mkswap /dev/sdb2 echo "Activating swap on /dev/sdb2..." swapon /dev/sdb2 echo "Swap setup complete. Verifying..." swapon --show free -h
swapon --show
command should list your swap partition, andfree -h
should show non-zero total swap space. -
Format the Root Partition (
/
):
Assuming/dev/sdb3
is your root partition, format as Ext4:(If you were to use Btrfs:echo "Formatting root partition /dev/sdb3 as Ext4..." mkfs.ext4 /dev/sdb3 echo "Root partition formatting complete."
mkfs.btrfs -f /dev/sdb3
). The-f
for btrfs might be needed if the partition previously held another filesystem. -
Format the Home Partition (
/home
):
Assuming/dev/sdb4
is your home partition, format as Ext4:(If you were to use Btrfs:echo "Formatting home partition /dev/sdb4 as Ext4..." mkfs.ext4 /dev/sdb4 echo "Home partition formatting complete."
mkfs.btrfs -f /dev/sdb4
). -
Mount the Root Partition:
Mount your formatted root partition (/dev/sdb3
) to/mnt
: -
Create Mount Points within
/mnt
:
We need directories for/boot
(for ESP) and/home
. -
Mount the EFI System Partition (ESP):
Mount your formatted ESP (/dev/sdb1
) to/mnt/boot
: -
Mount the Home Partition:
Mount your formatted home partition (/dev/sdb4
) to/mnt/home
: -
Verify All Mounts and Swap:
Uselsblk
to check the mount points andswapon --show
for swap.You should see output similar to: Forecho "Verifying mounts with lsblk:" lsblk /dev/sdb # Or your main disk echo "Verifying swap status:" swapon --show echo "Verifying filesystem usage with df -h:" df -h
lsblk /dev/sdb
: Fordf -h
, you'll see/mnt
,/mnt/boot
, and/mnt/home
listed with their sizes and usage.
Reflection:
- Were you able to format each partition with the correct filesystem type?
- Did you successfully activate the swap partition? How did you verify it?
- Are all your filesystems mounted at the correct locations under
/mnt
? What command did you use to verify this? - Why is the order of mounting (root first, then others into subdirectories of root's mount point) important? (Because the subdirectories like
/mnt/boot
must exist on the filesystem mounted at/mnt
before you can mount something else into them.)
With your partitions formatted and correctly mounted, your system is now ready for the installation of the Arch Linux base packages.
4. Installing the Base System
Now that your partitions are prepared and mounted, it's time to install the core Arch Linux system. This involves two main steps: selecting optimal package download mirrors and then using the pacstrap
script to download and install the base packages onto your target system (currently accessible via /mnt
).
Selecting Mirrors
Arch Linux packages are downloaded from mirror servers located around the world. To ensure fast and reliable downloads, you should select mirrors that are geographically close to you and up-to-date.
The live environment comes with a default mirror list located at /etc/pacman.d/mirrorlist
. However, this list might not be optimized for your location or current network conditions.
Using reflector
to Optimize the Mirror List:
reflector
is a script that can fetch the latest mirror status from the Arch Linux Mirror Status page, filter and sort them (e.g., by speed or age), and update your /etc/pacman.d/mirrorlist
file.
-
Ensure
This synchronizes the package databases from the mirrors currently in yourreflector
is available and up-to-date (it usually is on recent ISOs, but good practice to check/refresh pacman's sync databases first):/etc/pacman.d/mirrorlist
. -
Back up the existing mirrorlist (optional, but good practice):
-
Run
reflector
to generate a new mirrorlist:
Here's an example command. You can customize it extensively:Let's break down this command:reflector --verbose --country 'United States' --country 'Canada' -a 6 --sort rate --save /etc/pacman.d/mirrorlist
--verbose
: Shows more output about whatreflector
is doing.--country 'United States' --country 'Canada'
: Filters mirrors by specified countries. You should replace these with your country or nearby countries. You can list multiple--country
options. To see a list of available countries:reflector --list-countries
.-a 6
: Filters for mirrors that have synchronized within the last 6 hours (-a
means age).--sort rate
: Sorts the selected mirrors by their download speed (fastest first). Other sort options includeage
(most recently synchronized),score
(uses a formula considering age and rate).--save /etc/pacman.d/mirrorlist
: Saves the generated list of mirrors to the specified file, overwriting the old one.
A more general example, getting the 20 fastest HTTPS mirrors that synced in the last 12 hours from any country:
--latest 20
: Get the 20 most recently synchronized mirrors.--protocol https
: Prefers HTTPS mirrors.
Recommendation:
A good starting point for many users is to select a few countries nearby, sort by rate, and pick a reasonable number of mirrors (e.g., 5-10). Example for someone in Germany: -
Verify the new mirrorlist (optional):
(Use
You can open the file to see the selected mirrors:Ctrl+X
to exitnano
). You should seeServer = ...
lines at the top, uncommented.
With an optimized mirror list, package downloads will be significantly faster.
Installing Essential Packages with pacstrap
The pacstrap
script is used to install packages into the new system root (which is currently /mnt
). It creates the necessary directory layout, installs the base packages, and sets up a minimal, functional Arch Linux environment.
-
The
pacstrap
command:
The basic command installs thebase
metapackage, the Linux kernel (linux
), and firmware for common hardware (linux-firmware
)./mnt
: The target directory where the new system will be installed.base
: A metapackage that pulls in all the essential utilities and libraries needed for a functional GNU/Linux system (things like systemd, bash, coreutils, pacman itself, etc.).linux
: The latest stable Arch Linux kernel package.linux-firmware
: Firmware files required by many hardware components (graphics cards, network adapters, etc.).
-
Adding Other Useful Base Packages (Recommended):
It's highly recommended to install a few more packages along with the base system. This makes configuring the system easier once youchroot
into it. Common additions include:- A text editor:
nano
(easy to use) orvim
(powerful, steeper learning curve). - Network management:
networkmanager
(provides both wired and wireless connectivity, widely used and user-friendly). - Man pages and documentation:
man-db
,man-pages
,texinfo
. These allow you to read manual pages for commands (e.g.,man ls
). - Optionally, other kernels:
linux-lts
(Long Term Support kernel, if you prefer more stability over the absolute latest features). - Filesystem utilities: If you used Btrfs or XFS, you might want to ensure
btrfs-progs
orxfsprogs
are installed in the target system too (thoughbase
or kernel dependencies often pull these).
An expanded
If you also want the LTS kernel:pacstrap
command might look like this: - A text editor:
-
Execution:
Run your chosenpacstrap
command. It will download all the required packages from the mirrors you selected and install them into/mnt
. This process can take some time depending on your internet speed and the number of packages. You'll see progress bars and package names scrolling by.Example Output Snippet:
==> Creating install root at /mnt ==> Installing packages to /mnt :: Synchronizing package databases... core downloading... extra downloading... community downloading... :: There are XX members in group base: :: Repository core 1) bash 2) bzip2 3) coreutils ... Enter a selection (default=all): (Just press Enter here for all base packages) resolving dependencies... looking for conflicting packages... Packages (YY) package1-version package2-version ... Total Download Size: ABC.XY MiB Total Installed Size: XYZ.AB MiB :: Proceed with installation? [Y/n] (Press Y and Enter) :: Retrieving packages... downloading package1 from mirror... downloading package2 from mirror... ... :: Processing package changes... (1/YY) installing package1... (2/YY) installing package2... ... :: Running post-transaction hooks... (1/X) Arming ConditionNeedsUpdate... (2/X) Creating system user accounts... ...
-
Verification (Optional but good):
You should see familiar Linux directories like
Afterpacstrap
finishes without errors, you can peek into/mnt
to see the newly installed system:bin
,etc
,usr
,var
,home
,boot
, etc. These are now populated with the base Arch Linux system.
Workshop pacstrap
and Mirror Configuration
Goal:
Optimize the package mirror list using reflector
and then install the Arch Linux base system, a kernel, firmware, a text editor, and NetworkManager onto your mounted partitions.
Prerequisites:
- You have completed the "Formatting and Mounting" workshop.
- Your root partition (e.g.,
/dev/sdb3
) is mounted at/mnt
. - Your ESP (e.g.,
/dev/sdb1
) is mounted at/mnt/boot
. - Your home partition (e.g.,
/dev/sdb4
), if separate, is mounted at/mnt/home
. - You have an active internet connection in the live environment.
Steps:
-
Refresh Pacman Sync Databases:
This step is important because
Before usingreflector
, ensurepacman
's local database is up-to-date with the mirrors currently in/etc/pacman.d/mirrorlist
.reflector
itself might need to be installed or updated, and it fetches a list of mirrors from a source defined in pacman's configuration. -
Backup Existing Mirrorlist:
-
Run
reflector
:- First, find your country code if you don't know it: Note down your country and perhaps a couple of neighboring ones.
- Now, construct your
reflector
command. For example, if you are in "Germany" and want the 10 fastest HTTPS mirrors updated in the last 12 hours, also considering "France" and "Netherlands":echo "Running reflector to optimize mirrorlist..." reflector --verbose \ --country Germany --country France --country Netherlands \ --age 12 \ --protocol https \ --sort rate \ --threads 5 \ --number 10 \ --save /etc/pacman.d/mirrorlist
--threads 5
: Use 5 parallel connections to test mirror speeds (can speed up reflector).--number 10
: Keep only the top 10 mirrors.- Adjust the countries, age, and number parameters to your preference.
- If you prefer simplicity and global reach, a command like this works well:
- Wait for
reflector
to finish. It will test various mirrors.
-
Inspect the New Mirrorlist (Optional):
You should see uncommentedServer = ...
lines at the top. -
Install Base System and Additional Packages with
pacstrap
:
We will installbase
, the standardlinux
kernel,linux-firmware
,nano
(text editor),networkmanager
(for network management in the installed system),man-db
,man-pages
, andtexinfo
(for documentation).echo "Starting pacstrap. This may take some time..." pacstrap -K /mnt base linux linux-firmware nano networkmanager man-db man-pages texinfo
- The
-K
option forpacstrap
(orpacstrap /mnt ...
since pacstrap 2.0) will copy the host's/etc/pacman.d/mirrorlist
to/mnt/etc/pacman.d/mirrorlist
and initialize pacman keys on the target. Before pacstrap 2.0, it waspacstrap -i /mnt ...
and-i
only prompted for base group, not copying mirrorlist nor keys. Modernpacstrap
(after version that changed-i
behavior) handles mirrorlist copy and keys initialization by default unless told not to. Using-K
explicitly is good for clarity to initialize keys and copy mirrorlist, or justpacstrap /mnt ...
is fine with modern versions. For simplicity and wider compatibility with ISO versions,pacstrap /mnt ...
is often sufficient as it usually does the right thing. Let's stick to the simpler form unless issues arise. -
Revised simpler command (modern pacstrap handles key init and mirrorlist copy from host):
-
When prompted
Enter a selection (default=all):
for thebase
group, just press Enter. - When asked
:: Proceed with installation? [Y/n]
, type Y and press Enter. - Observe the download and installation process. This is the core of your Arch Linux system being laid down.
- The
-
Verify Installation (Basic Check):
Oncepacstrap
completes successfully (no errors reported at the end):
Reflection:
- How did
reflector
help in the installation process? What criteria did you use to select your mirrors? - What are the key components installed by
pacstrap
withbase
,linux
, andlinux-firmware
? - Why did we include
nano
andnetworkmanager
at this stage? (To have a text editor and network configuration tool immediately available after chrooting and on first boot). - If
pacstrap
failed, what would be your first troubleshooting steps? (Check internet connection, check mirrorlist for valid servers, check for typos in the command, ensure partitions are mounted correctly and have enough space).
Your Arch Linux base system is now installed on the disk! The next crucial step is to configure this system before you can boot into it. This involves generating an fstab
file and then chroot
ing into your new environment.
5. Configuring the System
With the base packages installed, the next phase is to configure the newly installed system. This involves generating the file system table (fstab
), changing root into the new system (arch-chroot
), and then performing essential configurations like setting the time zone, locale, hostname, network, initramfs, and root password.
Generating an fstab
The fstab
(file system table) file, located at /etc/fstab
, is a system configuration file that defines how disk partitions and other block devices are mounted into the filesystem hierarchy.
The genfstab
script is used to auto-detect and generate an fstab
file based on the currently mounted partitions under /mnt
.
-
Run
genfstab
:-U
: Use UUIDs (Universally Unique Identifiers) to identify the partitions. This is more robust than using device names like/dev/sda1
, as device names can sometimes change./mnt
: The root of the new system where the mounted partitions are.genfstab
will scan this hierarchy.>> /mnt/etc/fstab
: Appends the output to thefstab
file within the new system. Using>>
(append) is generally safer than>
(overwrite) if you were to run it multiple times, though for a fresh install>
would also work if the file doesn't exist or is empty.
-
Verify the generated
You should see entries for your root (fstab
:
It's crucial to check the contents of/mnt/etc/fstab
to ensure it correctly reflects your partitioning scheme and mount options./
), ESP (/boot
or/efi
), home (/home
), and swap partitions.Example
fstab
entries:# <file system> <dir> <type> <options> <dump> <pass> # /dev/sdb3 (root) UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx / ext4 rw,relatime 0 1 # /dev/sdb1 (ESP mounted at /boot) UUID=YYYY-YYYY /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2 # /dev/sdb4 (home) UUID=zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz /home ext4 rw,relatime 0 2 # /dev/sdb2 (swap) UUID=wwwwwwww-wwww-wwww-wwww-wwwwwwwwwwww none swap defaults 0 0
<file system>
: UUID of the partition.<dir>
: Mount point.<type>
: Filesystem type (e.g.,ext4
,vfat
,swap
,btrfs
).<options>
: Mount options (e.g.,rw
for read-write,relatime
for updating access times efficiently).- For
vfat
(ESP), common options includerw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
. Some defaults might useutf8
foriocharset
which is also fine. - For
swap
,defaults
is usually sufficient.
- For
<dump>
: Used by thedump
utility (usually0
to disable).<pass>
: Determines the order for filesystem checks (fsck
) at boot time.0
: Do not check.1
: Root filesystem (checked first).2
: Other filesystems to be checked after root.
Ensure all your intended persistent mounts are present and look correct. If you used Btrfs subvolumes, the
fstab
entries would includesubvol=...
options.
Chrooting into the New System
chroot
(change root) is a command that changes the apparent root directory for the current running process and its children. This allows you to work directly within your newly installed Arch Linux system as if you had booted into it.
arch-chroot
is a wrapper script provided by Arch that handles mounting necessary virtual file systems like/proc
,/sys
,/dev
into the chroot environment, making it fully functional.- After running this command, your shell prompt will likely change, indicating you are now operating within the
/mnt
environment as its root. For example, it might look like[root@archiso /]#
or similar, but/
now refers to the/mnt
of the live environment. Any command you run will affect the new system.
You are now "inside" your new Arch Linux installation.
Setting the Time Zone
- List Time Zones (optional, to find yours):
Time zones are located in/usr/share/zoneinfo/
. -
Create a symbolic link from
Example for US Eastern Time: Example for London:/etc/localtime
to your zoneinfo file:
ReplaceRegion/City
with your actual time zone. For example,Europe/Berlin
orAmerica/New_York
. -
Set the Hardware Clock:
This command sets the hardware clock (RTC, the clock in your motherboard) from the system clock. It's generally recommended to set the hardware clock to UTC.--systohc
: Set hardware clock from system clock. By default, it assumes the hardware clock is in UTC. If your hardware clock is set to local time (common if dual-booting with Windows, though Windows can also be configured to use UTC), you might needhwclock --systohc --localtime
. However, UTC is the Linux standard.
Localization
Localization involves configuring your system's language, character encoding, and keyboard layout preferences.
-
Edit
Find the line(s) for your desired locale(s) and remove the/etc/locale.gen
:
This file lists all available locales. You need to uncomment the locales you want to generate.#
at the beginning. For example, for US English with UTF-8 encoding: If you need British English: For German (Germany): It's good practice to at least haveen_US.UTF-8 UTF-8
uncommented as a fallback, in addition to your primary locale. Save the file and exit (Ctrl+O
, Enter,Ctrl+X
in nano). -
Generate Locales:
You should see output indicating the locales are being generated.
Run thelocale-gen
command to generate the uncommented locales: -
Set the
ReplaceLANG
variable in/etc/locale.conf
:
This file sets the default system-wide locale.en_US.UTF-8
with your primary chosen locale fromlocale.gen
. For example: -
Set Keyboard Layout Persistently (Console):
Add a line like: Replace
To make the console keyboard layout (used in TTYs, before Xorg starts) persistent across reboots, create or edit/etc/vconsole.conf
.us
with your desired keymap (e.g.,de-latin1
,uk
,fr
). This is the same name you used withloadkeys
earlier. Save and exit.
Network Configuration
-
Set the Hostname:
Replace
The hostname is a name for your computer on the network.myarchpc
with your desired hostname (e.g.,arch-desktop
,yourname-laptop
). -
Configure
Add the following lines (replace/etc/hosts
:
Add matching entries to/etc/hosts
. This file is used for local hostname resolution.myarchpc
with your chosen hostname): Save and exit. -
Enable a Network Management Service:
If you installednetworkmanager
withpacstrap
(recommended), you should enable its service so it starts automatically on boot.systemctl enable
: This creates symbolic links that cause systemd to start the service during the boot process.NetworkManager
: The service name for NetworkManager.- If you chose a different network manager (e.g.,
systemd-networkd
andsystemd-resolved
for wired/manual configuration), you would enable those services instead. For most desktop/laptop users, NetworkManager is convenient.
Initramfs (Initial RAM File System)
The initramfs is a gzipped cpio archive containing an initial root filesystem that is loaded into memory during the Linux boot process. It contains kernel modules and utilities necessary to mount the real root filesystem (e.g., drivers for your disk controller, LVM, LUKS decryption tools).
The mkinitcpio
utility is used to generate initramfs images. The base
package should have set up a default configuration in /etc/mkinitcpio.conf
.
-
Review
Pay attention to the/etc/mkinitcpio.conf
(Optional but good to know):HOOKS
array. The defaultHOOKS
line usually includesbase udev autodetect modconf kms keyboard keymap consolefont block filesystems fsck
.- If you are using LVM, you need the
lvm2
hook (usually beforefilesystems
). - If you are using LUKS encryption, you need the
encrypt
hook (usually beforelvm2
if LVM is on LUKS, and beforefilesystems
). - If you are using Btrfs on the root partition, the
fsck
hook is not needed for Btrfs (asbtrfs check
is not run automatically this way) andbtrfs
hook might be needed if root is on btrfs and something special is needed. Thefilesystems
hook generally handles Btrfs mounting. - The order of hooks matters. For example,
keyboard
andkeymap
are needed beforeencrypt
if you want to type your LUKS passphrase with the correct keyboard layout.
- If you are using LVM, you need the
-
Re-generate the Initramfs:
Even if you didn't change the config, it's good practice to regenerate it, especially if multiple kernels were installed or to ensure it's built correctly within the chroot.-P
(uppercase P): Generate initramfs for all presets defined in/etc/mkinitcpio.d/
(e.g.,linux.preset
,linux-lts.preset
if you installed LTS kernel). This will create files like/boot/initramfs-linux.img
and/boot/initramfs-linux-fallback.img
.
Setting the Root Password
The root
user is the superuser with unrestricted privileges. You must set a password for it.
Workshop System Configuration within Chroot
Goal:
Perform essential system configurations within the chroot
environment: generate fstab
, set timezone, configure locales, set hostname, enable NetworkManager, regenerate initramfs, and set the root password.
Prerequisites:
- You have successfully completed the
pacstrap
workshop. - Your new Arch system is installed under
/mnt
.
Steps:
-
Generate
fstab
:(Optional:echo "Generating fstab..." genfstab -U /mnt >> /mnt/etc/fstab echo "fstab generated. Verifying its content (first 15 lines):" head -n 15 /mnt/etc/fstab
nano /mnt/etc/fstab
to inspect fully). Ensure entries for/
,/boot
,/home
(if separate), andswap
look correct with UUIDs. -
Enter the Chroot Environment:
Your prompt should change, indicating you are now in the new system's root.pwd
should show/
. -
Set Time Zone:
- Find your region/city (e.g.,
America/Los_Angeles
,Europe/Paris
). - Create the symlink (replace
Your/City
accordingly): - Set hardware clock to UTC:
- Find your region/city (e.g.,
-
Configure Locales:
- Edit
/etc/locale.gen
to uncomment your locale(s). We'll uncommenten_US.UTF-8 UTF-8
and, for example,de_DE.UTF-8 UTF-8
. - Generate locales:
- Set default language in
/etc/locale.conf
(e.g.,en_US.UTF-8
): - Set console keyboard layout in
/etc/vconsole.conf
(e.g.,us
orde-latin1
):
- Edit
-
Configure Network:
- Set hostname (e.g.,
myarchbox
): - Add entries to
/etc/hosts
: - Enable NetworkManager service:
- Set hostname (e.g.,
-
Regenerate Initramfs:
- If you used LVM or encryption, you would first edit
/etc/mkinitcpio.conf
to addlvm2
orencrypt
hooks. For our standard setup, defaults are fine.
- If you used LVM or encryption, you would first edit
-
Set Root Password:
Follow the prompts to set and confirm your root password.
Reflection:
- What is the purpose of the
fstab
file, and why are UUIDs preferred? - What does
arch-chroot
do, and why is it necessary? - If you forget to set the correct timezone, what issues might you encounter? (Incorrect file timestamps, SSL certificate validation issues, problems with cron jobs).
- Why is regenerating the initramfs (
mkinitcpio -P
) important, especially after kernel updates or changes to hooks? (To ensure the boot process has all necessary modules and configurations to find and mount the root filesystem).
You have now configured the core aspects of your new Arch Linux system. The final step before rebooting is to install a bootloader.
6. Bootloader Installation
A bootloader is a crucial piece of software that loads the operating system's kernel into memory when the computer starts. Without a bootloader, your system won't know how to boot into Arch Linux. We will cover two popular choices: GRUB (widely used, feature-rich) and systemd-boot (simpler, for UEFI systems only).
Important:
The choice of bootloader and its installation method depends on whether your system is using UEFI or legacy BIOS firmware. You should have verified this in the "Pre-installation Setup" section (ls /sys/firmware/efi/efivars
).
Understanding Bootloaders
-
GRUB (Grand Unified Bootloader):
- The most common bootloader for Linux distributions.
- Highly configurable and powerful.
- Supports BIOS and UEFI systems, various filesystems, LVM, LUKS encryption, and multi-booting with other operating systems.
- Can be a bit more complex to configure than systemd-boot.
-
systemd-boot (formerly Gummiboot):
- A simple UEFI boot manager. It does not work with BIOS systems.
- Part of the
systemd
project. - Easier to configure as it involves simple text files for boot entries.
- Typically requires the EFI System Partition (ESP) to be mounted at
/boot
(or it can manage kernels/initramfs images directly on the ESP if copied there).
You should still be in the arch-chroot
environment for these steps.
Microcode Updates
Processor microcode is firmware for your CPU, released by Intel or AMD to fix bugs or security vulnerabilities. It's highly recommended to install and load microcode updates.
- Install the appropriate microcode package:
- For Intel CPUs:
- For AMD CPUs: Install the one corresponding to your CPU manufacturer. If unsure, you can install both; the bootloader will pick the correct one.
The bootloader needs to be configured to load this microcode before the kernel. GRUB usually handles this automatically if the package is installed when grub-mkconfig
is run. For systemd-boot, you'll add an initrd
line for it in the boot entry.
Option 1 GRUB (Grand Unified Bootloader)
GRUB is a versatile choice suitable for most systems.
GRUB Installation for UEFI Systems
Prerequisites:
- You booted the Arch ISO in UEFI mode.
- You have an EFI System Partition (ESP), typically mounted at
/boot
(as in our workshop) or/efi
. If it's at/efi
, adjust the--efi-directory
path accordingly. - The
efibootmgr
package is needed bygrub-install
to interact with the UEFI firmware.
Steps:
-
Install GRUB and
efibootmgr
: -
Install GRUB to the ESP: The command installs GRUB's UEFI application to the ESP and creates an entry in the firmware's boot manager.
--target=x86_64-efi
: Specifies the target architecture and firmware type.--efi-directory=/boot
: Crucial! This is the mount point of your ESP. If your ESP is mounted at/efi
, use--efi-directory=/efi
.--bootloader-id=GRUB
: This is the name that will appear in the UEFI boot menu for this GRUB installation (e.g., "GRUB"). You can change it (e.g., "ArchLinux").--recheck
: Can be added if you encounter issues; it forcesgrub-install
to re-probe devices.- No device path (like
/dev/sda
) is specified for UEFI.
If successful, you'll see "Installation finished. No error reported."
-
Generate the GRUB Configuration File (
grub.cfg
): GRUB needs a configuration file (/boot/grub/grub.cfg
) that tells it what operating systems and kernels to boot. Thegrub-mkconfig
tool generates this file by scanning your system.-o /boot/grub/grub.cfg
: Specifies the output file path.- This command should detect your Arch Linux kernel(s) (e.g.,
linux
andlinux-lts
if installed) and the microcode updates (ifintel-ucode
oramd-ucode
is installed). - It will also detect other operating systems like Windows if
os-prober
is installed (pacman -S os-prober
) and they are present. Foros-prober
to work effectively with GRUB, you might need to enable it in/etc/default/grub
by uncommenting/addingGRUB_DISABLE_OS_PROBER=false
before runninggrub-mkconfig
.
GRUB Installation for BIOS/MBR Systems
Prerequisites:
- You booted the Arch ISO in BIOS/Legacy mode.
- You have an MBR partition table (or GPT with a BIOS boot partition if doing advanced setup, but standard MBR is simpler for pure BIOS).
Steps:
-
Install GRUB:
(You don't needefibootmgr
for BIOS.) -
Install GRUB to the Master Boot Record (MBR):
This command installs GRUB's boot code to the MBR of your disk (or to a BIOS boot partition if you have one and specify it).--target=i386-pc
: Specifies the target for BIOS systems./dev/sdX
: Crucial! This is your main boot disk (e.g.,/dev/sda
), NOT a partition like/dev/sda1
. GRUB will be written to the MBR of this disk.--recheck
: Can be added if needed.
If successful, you'll see "Installation finished. No error reported."
-
Generate the GRUB Configuration File (
grub.cfg
):
Same command as for UEFI:
Option 2 systemd-boot (UEFI Systems Only)
systemd-boot
is a simpler alternative to GRUB for UEFI systems. It's less feature-rich but often easier to manage if your needs are basic.
Prerequisites:
- UEFI system and UEFI boot mode.
- ESP mounted at
/boot
. This is the most straightforward setup forsystemd-boot
, as it expects kernels and initramfs images to be directly on the ESP. If your ESP is mounted elsewhere (e.g.,/efi
), you'd need to copy kernel, initramfs, and microcode to/efi
and adjust paths in loader entries. For this guide, we assume ESP is at/boot
.
Steps:
-
Install
systemd-boot
boot manager to the ESP:
Thebootctl
command is used to managesystemd-boot
.--path=/boot
: Specifies the mount point of your ESP.- This command installs
systemd-boot
binaries to the ESP (e.g.,/boot/EFI/systemd/systemd-bootx64.efi
and/boot/EFI/BOOT/BOOTX64.EFI
as a fallback). It also creates a boot entry in the firmware.
-
Configure the Loader (
A minimal configuration might look like:/boot/loader/loader.conf
):
This file contains general settings forsystemd-boot
.default arch.conf # Or arch-*.conf, refers to your default entry file name timeout 3 # Seconds to wait before auto-booting default console-mode max # Try to set highest console mode editor no # Disable editing kernel parameters from menu (set to 'yes' to enable)
default
: Specifies which boot entry file in/boot/loader/entries/
to boot by default. We will createarch.conf
next.- If you use
default @saved
, systemd-boot will remember the last selected entry. - You can use wildcards like
default arch-*.conf
and it will pick the one that sorts first alphabetically if you have multiple arch entries.
-
Create Boot Entries (
/boot/loader/entries/
):
For each kernel you want to boot, you create a.conf
file in/boot/loader/entries/
.-
Example for the standard
Add the following content (replacelinux
kernel (/boot/loader/entries/arch.conf
):YOUR_ROOT_PARTITION_UUID
):title Arch Linux linux /vmlinuz-linux initrd /intel-ucode.img # Or /amd-ucode.img if you have AMD initrd /initramfs-linux.img options root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx rw
title
: The name displayed in the boot menu.linux
: Path to the kernel image (relative to/boot
).initrd
: Path to the microcode image (must be listed before the main initramfs).initrd
: Path to the initramfs image.options
: Kernel command-line parameters.root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
: Crucial! Specifies the root filesystem.- Find the UUID of your root partition (e.g.,
/dev/sdb3
) by running:blkid -s UUID -o value /dev/sdb3
(run this command outside chroot, or if inside chroot, use the correct device path your system sees).
- Find the UUID of your root partition (e.g.,
rw
: Mount root filesystem as read-write.- Other options can be added here (e.g.,
quiet
for less boot verbosity,resume=UUID=...
for hibernation).
-
Example for
(Use the same root partition UUID).linux-lts
kernel (if installed) (/boot/loader/entries/arch-lts.conf
):
Finding the Root Partition UUID:
Look for the line corresponding to
While still inchroot
, you can useblkid
on the device name your new system will see. If your root partition was/dev/sdb3
in the live environment and is now/
inside chroot, you still need the UUID for/dev/sdb3
. It's often easier to get this from the/etc/fstab
you generated:/
and copy its UUID.Alternatively, exit chroot temporarily, run
blkid /dev/sdb3
(your root part), copy UUID, thenarch-chroot /mnt
again. -
Workshop Installing and Configuring GRUB (UEFI)
Goal:
Install the necessary microcode package, then install and configure GRUB as the bootloader for a UEFI system where the ESP is mounted at /boot
.
Prerequisites:
- You are still in the
arch-chroot /mnt
environment. - Your system is UEFI-based and you booted the live ISO in UEFI mode.
- Your ESP is mounted at
/boot
. - Packages like
base
,linux
,linux-firmware
are installed.
Steps:
-
Install Microcode:
- Determine your CPU manufacturer. If unsure, you can look at
lscpu | grep "Vendor ID"
.GenuineIntel
for Intel,AuthenticAMD
for AMD. - Let's assume you have an Intel CPU for this example. If AMD, use
amd-ucode
.
- Determine your CPU manufacturer. If unsure, you can look at
-
Install GRUB and
efibootmgr
: -
Run
grub-install
for UEFI:
Ensure your ESP is indeed mounted at/boot
within the chroot (it should be if you followed previous steps:/
from the live ISO's/mnt
is now/
in chroot, and/mnt/boot
from live ISO is now/boot
in chroot).echo "Running grub-install for UEFI..." grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCHGRUB --recheck
- We use
--bootloader-id=ARCHGRUB
to give it a distinct name in the UEFI boot menu. --recheck
is a good addition to ensure devices are properly scanned.- If this command fails, common issues include:
- Not being in UEFI boot mode (chroot from a BIOS-booted live ISO).
- ESP not mounted correctly at
--efi-directory
. efibootmgr
not installed or not working.- No space on ESP (unlikely with 512MB but possible if much else is there).
- If successful, it will say: "Installation finished. No error reported."
- We use
-
Generate GRUB Configuration File:
Optional: If you plan to dual-boot with Windows and want GRUB to detect it, installos-prober
first and ensure it's enabled.Now generate# Optional for dual-boot detection: # pacman -S os-prober # nano /etc/default/grub # Ensure GRUB_DISABLE_OS_PROBER=false is present and uncommented. Save.
grub.cfg
:- This command should detect your Linux kernels (e.g.,
vmlinuz-linux
) and the installed microcode (intel-ucode.img
oramd-ucode.img
). It will automatically add the microcode as aninitrd
line before the maininitramfs-linux.img
in the GRUB menu entries. - Inspect the output. You should see lines like "Found linux image: /boot/vmlinuz-linux", "Found initrd image: /boot/intel-ucode.img /boot/initramfs-linux.img".
- This command should detect your Linux kernels (e.g.,
-
Verify Bootloader Files (Optional but good practice):
Check if GRUB files are present on the ESP:
Reflection:
- Why is microcode important, and how does GRUB handle loading it? (GRUB, via
grub-mkconfig
andos-prober
or internal scripts, detects the ucode package and adds it as an initial ramdisk before the main initramfs). - What is the purpose of
efibootmgr
in a UEFI GRUB installation? (It allowsgrub-install
to interact with the motherboard's UEFI firmware to register the GRUB bootloader application, so the firmware knows to load it). - What are the key differences in
grub-install
commands for UEFI vs. BIOS?- UEFI:
grub-install --target=x86_64-efi --efi-directory=/path/to/esp --bootloader-id=NAME
(no device like/dev/sda
). - BIOS:
grub-install --target=i386-pc /dev/sda
(device specified, MBR targeted).
- UEFI:
- If, after reboot, GRUB doesn't appear, what could be wrong? (UEFI boot order not pointing to GRUB,
grub-install
failed to write to firmware, Secure Boot enabled and GRUB not signed, ESP not formatted correctly or not recognized).
With the bootloader installed, your Arch Linux system should now be bootable! The next step is to exit the chroot, unmount partitions, and reboot.
7. Post-installation Setup
You've successfully installed the base Arch Linux system, configured it, and installed a bootloader. It's time to reboot into your new installation and perform essential post-installation tasks to make it a usable desktop or server environment.
Exiting Chroot and Unmounting
-
Exit the Chroot Environment:
This will return you to the live ISO's shell (
If you are still inside thearch-chroot /mnt
environment, type:root@archiso ~ #
). -
Unmount All Partitions:
It's crucial to unmount all partitions you mounted under/mnt
before rebooting. The-R
(recursive) option forumount
can be helpful, but sometimes it's better to unmount explicitly, starting from the most deeply nested. If your mounts were/mnt
,/mnt/boot
,/mnt/home
:Alternatively,umount /mnt/home # If you had a separate home umount /mnt/boot # Unmount ESP (or separate /boot) umount /mnt # Unmount root
umount -R /mnt
attempts to unmount/mnt
and everything beneath it. If you encounter "target is busy" errors, ensure no processes (like an open terminal stillcd
-ed into/mnt
) are using the mounts. You can usefuser -km /mnt/path
to kill processes using a mount point, but unmounting in reverse order of mounting usually works. Also, if you activated swap on a partition (swapon /dev/sdXN
), you can deactivate it now, though the system will handle it on shutdown/reboot: -
Reboot the System:
Important: Remove the Arch Linux installation USB drive as soon as the computer starts to reboot. Otherwise, you might boot back into the live environment.
First Boot into the New System
If everything went well, you should see your bootloader (GRUB or systemd-boot) menu. Select your Arch Linux entry and press Enter. After the kernel loads and systemd initializes, you should be greeted by a login prompt on a TTY (text console):
(Replacemyarchbox
with the hostname you set).
Login as the root
user with the password you set earlier.
Troubleshooting Boot Issues:
- System doesn't boot / No bootloader menu:
- Check BIOS/UEFI boot order: Ensure the hard drive with Arch Linux is the primary boot device and the correct UEFI entry (e.g., "ARCHGRUB") is selected.
- Secure Boot: If enabled, it might be blocking GRUB. Try disabling Secure Boot in UEFI settings.
- Bootloader installation error: You might need to boot back into the Arch ISO,
arch-chroot
again, and try reinstalling/reconfiguring the bootloader.
- Kernel Panic:
- Often indicates issues with initramfs, missing kernel modules, or incorrect
root=
parameter in bootloader config. - Check
fstab
and bootloader configuration for correct UUIDs/device names. - Rebuild initramfs (
mkinitcpio -P
) in chroot.
- Often indicates issues with initramfs, missing kernel modules, or incorrect
- Stuck at "A start job is running for...":
- Often related to
fstab
entries for partitions that can't be mounted (wrong UUID, filesystem corruption, device not found). - Check
fstab
carefully.
- Often related to
Creating a User Account
Operating as root
for daily tasks is dangerous. You should create a regular user account for yourself.
-
Create the User:
Replaceyourusername
with your desired username.-m
: Creates the user's home directory (e.g.,/home/yourusername
).-G wheel
: Adds the user to thewheel
group. Thewheel
group is traditionally used to control who can usesudo
.-s /bin/bash
: Sets the user's default login shell to Bash. Other shells likezsh
orfish
can be used if installed (pacman -S zsh
, then use/bin/zsh
).
-
Set a Password for the New User:
Enter and confirm a strong password for your new user.
Setting up Sudo
sudo
(superuser do) allows permitted users to execute commands as the root user (or other users) by prefixing commands with sudo
.
-
Install
sudo
(if not already pulled in bybase
or another package, though it usually is): -
Configure
This will opensudo
usingvisudo
:
Thesudoers
file (/etc/sudoers
) controls who can usesudo
and what they can do. Always edit this file using thevisudo
command, as it checks for syntax errors before saving. A syntax error in/etc/sudoers
can lock you out ofsudo
./etc/sudoers
in a text editor (usuallyvi
ornano
by default,visudo
respects theEDITOR
environment variable). Look for the line: Uncomment it by removing the#
at the beginning: This line means: "Users in thewheel
group can execute any command (ALL
) on any host (ALL=
) as any user ((ALL:ALL)
)". Save the file and exit:- In
vi
: PressEsc
, then type:wq
and Enter. - In
nano
: PressCtrl+O
, Enter (to write), thenCtrl+X
(to exit).
- In
Now, log out of the root session (exit
) and log back in as your new user (yourusername
). You should be able to use sudo
, e.g., sudo pacman -Syu
. You'll be prompted for your user's password, not the root password.
Graphics Drivers
To use a graphical desktop environment, you need graphics drivers.
-
Identify Your Graphics Card:
This command lists PCI devices and filters for VGA-compatible controllers or 3D controllers. Look for "Kernel driver in use" and the model of your card (NVIDIA, AMD, Intel). -
Install Drivers:
- Intel Integrated Graphics:
The open-source drivers are part of Mesa and usually work out-of-the-box.
(
libva-intel-driver
andintel-media-driver
are for video acceleration;vulkan-intel
for Vulkan support). - AMD Radeon Graphics (Open Source):
Modern AMD GPUs are well-supported by open-source drivers in Mesa.
(
xf86-video-amdgpu
is the Xorg DDX driver,vulkan-radeon
for Vulkan,libva-mesa-driver
andmesa-vdpau
for video acceleration). For very old AMD cards, you might needxf86-video-ati
. - NVIDIA Graphics:
You have options:
- Open-source
nouveau
driver: Part of Mesa. Installed by default ifmesa
is present. Performance is generally lower than proprietary drivers, especially for newer cards and gaming. - Proprietary NVIDIA driver:
Offers the best performance and features.
There are several versions:nvidia
: For recent GPUs.nvidia-lts
: For use with thelinux-lts
kernel.nvidia-dkms
: Builds the kernel module automatically if you use custom kernels or update kernels frequently.- Older drivers for legacy cards:
nvidia-390xx-dkms
,nvidia-470xx-dkms
. Check the Arch Wiki for which driver your card needs. For a recent card with the standardlinux
kernel: If usinglinux-lts
: After installing NVIDIA proprietary drivers, you often need to reboot or at least rebuild your initramfs (sudo mkinitcpio -P
) and restart your display manager for changes to take effect properly, especially ifnouveau
was previously active.nouveau
also needs to be blacklisted, but thenvidia
package often handles this.
- Open-source
- Intel Integrated Graphics:
The open-source drivers are part of Mesa and usually work out-of-the-box.
(
Installing a Desktop Environment or Window Manager
Arch Linux doesn't come with a graphical environment by default. You need to install one.
-
Install Xorg Server (Display Server):
Most desktop environments and window managers require Xorg.xorg-server
: The main X server.xorg-xinit
: For launching X sessions withstartx
(useful for window managers or testing).xorg-apps
: A group of basic X applications and utilities.
-
Choose and Install a Desktop Environment (DE) or Window Manager (WM):
-
Desktop Environments (provide a full suite of integrated applications and tools):
- GNOME: Modern, user-friendly, can be resource-intensive.
- KDE Plasma: Highly customizable, feature-rich, moderately resource-intensive.
- XFCE: Lightweight, fast, traditional desktop.
- Cinnamon: Traditional desktop layout, developed by Linux Mint.
- LXQt: Very lightweight Qt-based DE.
-
Window Managers (provide window management, often require more manual configuration for a full "desktop" experience):
- i3wm (Tiling): Popular, keyboard-driven, highly efficient.
Create
sudo pacman -S i3-wm i3status i3lock dmenu suckless-tools # dmenu for application launching, suckless-tools for 'st' terminal (optional) # You'd typically launch i3 via .xinitrc and startx, or via a display manager.
~/.xinitrc
:echo "exec i3" > ~/.xinitrc
. Then runstartx
. - Openbox (Stacking): Lightweight, highly configurable.
- i3wm (Tiling): Popular, keyboard-driven, highly efficient.
-
-
Reboot or Start Display Manager:
Alternatively, you can try starting it manually if you don't want to reboot yet:
After installing a DE and enabling its display manager, you typically need to reboot for the display manager to take over the login screen:sudo systemctl start gdm
(orsddm
,lightdm
).
Sound Configuration
Modern Linux systems typically use PipeWire for audio management. It aims to replace both PulseAudio and JACK.
-
Install PipeWire and related packages:
pipewire
: The core PipeWire server.pipewire-alsa
: ALSA configuration for PipeWire.pipewire-pulse
: A drop-in replacement for PulseAudio server (applications expecting PulseAudio will work).pipewire-jack
: JACK client library support for PipeWire.wireplumber
: A session and policy manager for PipeWire (recommended). (Alternatively,pipewire-media-session
can be used but WirePlumber is newer).
-
Enable PipeWire Services for your User:
You might need to log out and log back in, or reboot.
PipeWire services usually run at the user level. They are often automatically started by the desktop environment or via XDG autostart. If they don't start automatically, you can enable them for your user: -
Test Sound:
- Install a media player or use a web browser with audio.
- Install
pavucontrol
(PulseAudio Volume Control, works withpipewire-pulse
too) for a graphical mixer: Launchpavucontrol
to check output devices and levels.
Useful Applications
Install some common applications. Logged in as your regular user:
- Web Browser:
- Terminal Emulator (if your DE's default isn't preferred):
- Office Suite:
- Media Player:
- Archive Manager:
- Bluetooth support (if needed):
Yay or Paru (AUR Helpers) - Optional
The Arch User Repository (AUR) contains thousands of community-contributed packages. AUR helpers like yay
or paru
automate fetching, building, and installing AUR packages.
Do NOT run makepkg
or AUR helpers as root.
- Install
base-devel
andgit
:
These are needed to build packages. -
Install
yay
(example):cd /tmp # Or any other temporary build directory in your home, like ~/builds git clone https://aur.archlinux.org/yay.git cd yay makepkg -si
git clone
: Downloads theyay
PKGBUILD.cd yay
: Enters the directory.makepkg -si
:m
: Resolves dependencies usingpacman
.s
: Builds the package.i
: Installs the package usingpacman -U
. Follow prompts. Onceyay
is installed, you can remove theyay
build directory from/tmp
or~/builds
.
To use
yay
(similar syntax topacman
):
Workshop Setting up a Basic Usable System
Goal:
After the first reboot into your Arch Linux installation, create a regular user, set up sudo
, install graphics drivers, a lightweight desktop environment (XFCE), and PipeWire for sound. Also, install Firefox.
Prerequisites:
- You have successfully rebooted into your Arch Linux installation and are logged in as
root
. - You have an active internet connection (NetworkManager should be handling this if enabled and configured). If not, use
nmtui
ornmcli
as root to connect.
Steps:
-
Create a New User:
Replacestudent
with your desired username. -
Install and Configure
sudo
:echo "Installing sudo..." pacman -S sudo --noconfirm # --noconfirm to skip prompt if already installed echo "Configuring sudoers with visudo..." # This sed command non-interactively uncomments the %wheel line. # Be careful with sed on system files; visudo is safer for manual edits. sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers # Alternatively, and more safely, run 'visudo' and uncomment manually: # EDITOR=nano visudo (then uncomment '%wheel ALL=(ALL:ALL) ALL') echo "sudo configured."
-
Log Out as Root and Log In as New User:
At the login prompt, log in asstudent
(or your chosen username) with the password you set. -
Test
You should be prompted forsudo
:
Try updating the system (this also refreshes package lists).student
's password. If it works,sudo
is set up correctly. -
Install Graphics Drivers:
- First, identify your graphics hardware:
- For this workshop, we'll assume Intel integrated graphics as it's common in VMs and many laptops. If you have AMD/NVIDIA, adjust the package names.
-
Install Xorg Server:
-
Install XFCE Desktop Environment and LightDM Display Manager:
echo "Installing XFCE4 and LightDM..." sudo pacman -S xfce4 xfce4-goodies lightdm lightdm-gtk-greeter mousepad parole ristretto # mousepad (text editor), parole (media player), ristretto (image viewer) are common XFCE apps. echo "Enabling LightDM service..." sudo systemctl enable lightdm echo "XFCE4 and LightDM installed and enabled."
-
Install PipeWire for Sound:
-
Install Firefox:
-
Reboot:
After Rebooting:
- You should be greeted by the LightDM login screen.
- Log in as
student
. - The XFCE desktop should load.
- Test:
- Open a terminal (XFCE Terminal).
- Launch Firefox and browse the web.
- Play an audio file or a YouTube video to test sound (use
pavucontrol
to check/adjust if needed). - Check display resolution.
Reflection:
- Why is it important to create a non-root user and use
sudo
? (Security principle of least privilege). - What are the main components of a graphical desktop on Linux? (X server, Desktop Environment/Window Manager, Display Manager, supporting libraries like Mesa).
- If XFCE didn't start, what logs would you check? (
/var/log/Xorg.0.log
,journalctl -xe
for systemd service errors related to LightDM). - How does PipeWire integrate with applications that expect PulseAudio or ALSA? (Through
pipewire-pulse
andpipewire-alsa
compatibility layers).
You now have a functional Arch Linux system with a graphical desktop! The next sections will briefly touch upon further customization and troubleshooting.
8. Advanced Configuration and Customization
With a working Arch Linux system, you can now delve into tailoring it precisely to your needs. This section provides pointers to some common areas of advanced configuration and customization. The Arch Wiki will be your best friend for in-depth information on these topics.
Kernel Management
Arch Linux provides several kernel packages. You installed linux
(the latest stable). You might consider others:
-
linux-lts
(Long Term Support):- Receives security and bug fixes for a longer period. May offer more stability if you encounter issues with the mainline kernel or prefer fewer major updates.
- To install:
sudo pacman -S linux-lts linux-lts-headers
(headers are for building external modules). - After installation, update your bootloader configuration:
- GRUB:
sudo grub-mkconfig -o /boot/grub/grub.cfg
should detect it. - systemd-boot:
You'll need to create a new entry in/boot/loader/entries/
(e.g.,arch-lts.conf
) pointing to/vmlinuz-linux-lts
and/initramfs-linux-lts.img
.
- GRUB:
-
linux-zen
(Zen Kernel):- A kernel optimized for desktop, multimedia, and gaming performance. It includes various patches and different scheduler settings.
- To install:
sudo pacman -S linux-zen linux-zen-headers
. - Update bootloader configuration as above.
-
Custom Kernels: You can compile your own kernel for ultimate control (an advanced topic).
Managing Multiple Kernels:
If you have multiple kernels, your bootloader will typically list them, allowing you to choose at boot time. This is useful for testing new kernels or having a fallback.
Power Management
For laptops, effective power management is crucial for battery life.
-
tlp
: A popular and highly effective command-line tool for advanced power management. It applies various tweaks automatically on boot and when switching between AC and battery power.- Install:
sudo pacman -S tlp tlp-rdw
(tlp-rdw
is for radio device wizard, optional but often recommended). - Enable and start the service:
- Configuration is in
/etc/tlp.conf
. Defaults are usually sensible. - Check status:
sudo tlp-stat
- Install:
-
powertop
: A tool to diagnose issues with power consumption and identify power-hungry applications or settings.- Install:
sudo pacman -S powertop
- Run calibration (on battery):
sudo powertop --calibrate
- Interactive mode:
sudo powertop
(navigate tabs, see tunables).
- Install:
Font Rendering
Good font rendering significantly improves readability and visual appeal.
- Install Fonts:
Arch repositories have many font packages. - Fontconfig:
Controls how fonts are selected and rendered.- The defaults are usually good, but you can customize antialiasing, hinting, subpixel rendering, etc., by creating/editing
~/.config/fontconfig/fonts.conf
or system-wide in/etc/fonts/local.conf
. - Example for enabling full hinting and RGBA subpixel rendering (if your monitor supports it):
Create
~/.config/fontconfig/fonts.conf
(or/etc/fonts/local.conf
):You may need to log out and back in for changes to apply fully. LCD Font test websites can help you determine your subpixel layout.<?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig> <match target="font"> <edit name="antialias" mode="assign"> <bool>true</bool> </edit> <edit name="hinting" mode="assign"> <bool>true</bool> </edit> <edit name="hintstyle" mode="assign"> <const>hintfull</const> </edit> <edit name="rgba" mode="assign"> <const>rgb</const> <!-- or rgba, bgr, vbgr, etc. depending on subpixel layout --> </edit> </match> </fontconfig>
- The defaults are usually good, but you can customize antialiasing, hinting, subpixel rendering, etc., by creating/editing
Backups
Regular backups are essential.
- Timeshift:
Excellent for creating filesystem snapshots, similar to Windows System Restore or macOS Time Machine. Great for rolling back system updates if something breaks.- Supports Btrfs snapshots (if using Btrfs) or rsync for other filesystems.
- Install:
sudo pacman -S timeshift
- Run
timeshift-launcher
to configure. Recommended to store snapshots on a separate partition/disk.
- Rsync-based scripts:
For backing up/home
or other important data to an external drive or server. E.g.,rsync -avh --delete /home/yourusername /path/to/backup/drive/
. - Déjà Dup or Vorta (BorgBackup frontend):
GUI tools for user data backups.sudo pacman -S deja-dup
sudo pacman -S borg vorta
(Borg is a powerful deduplicating backup program)
Security
- Firewall:
- UFW (Uncomplicated Firewall):
A simple frontend foriptables
/nftables
. - Firewalld:
More advanced, supports zones. Often default on RHEL-based systems.
- UFW (Uncomplicated Firewall):
- AppArmor or SELinux:
Mandatory Access Control systems that can confine applications. More advanced to set up. AppArmor is generally considered easier.sudo pacman -S apparmor
- Add
apparmor=1 security=apparmor
to kernel parameters in bootloader config. - Enable AppArmor service:
sudo systemctl enable --now apparmor.service
- Install profiles:
sudo pacman -S apparmor-profiles
(hypothetical, check AUR or community repo).
- Keep System Updated:
Regularly runsudo pacman -Syu
. - Fail2Ban:
Scans log files and bans IPs that show malicious signs (too many password failures, seeking exploits, etc.).sudo pacman -S fail2ban
- Configure jails in
/etc/fail2ban/jail.local
. sudo systemctl enable --now fail2ban
Dotfiles Management
"Dotfiles" are user-specific configuration files (e.g., ~/.bashrc
, ~/.config/i3/config
). Managing them with version control (like Git) allows you to track changes, sync them across machines, and easily set up a new system.
- Create a Git repository (e.g.,
~/.dotfiles
). - Move your config files/directories into it.
- Use symbolic links to link them back to their original locations (e.g.,
ln -s ~/.dotfiles/bashrc ~/.bashrc
). - Many tools and scripts exist to help manage this (e.g.,
stow
,yadm
).
Workshop Installing an AUR Helper and Customizing Appearance
Goal:
Install yay
(an AUR helper). Use yay
to install a custom icon theme and a system information tool like neofetch
. Apply the icon theme if your DE supports it.
Prerequisites:
- A working Arch Linux installation with a desktop environment (e.g., XFCE from the previous workshop).
- Internet connection.
- Logged in as your regular user (e.g.,
student
).
Steps:
-
Install
Enter your password when prompted.base-devel
andgit
(if not already done):
These are prerequisites for building AUR packages. -
Clone
yay
repository and build it:cd ~ # Go to your home directory (or a dedicated builds directory like ~/builds) git clone https://aur.archlinux.org/yay.git cd yay makepkg -si
git clone
: Downloads the source files (PKGBUILD) foryay
.cd yay
: Enters the directory.makepkg -si
:s
: Syncs dependencies (installs them using pacman).i
: Installs the built package usingpacman -U
.
- You'll be prompted for your password by
sudo
whenmakepkg
tries to install dependencies or the final package. - Review the PKGBUILD if prompted (good practice, though
yay
is widely trusted). PressN
to skip editing unless you want to inspect it. Then proceed with the build.
-
Verify
You should see theyay
installation:yay
version printed. -
Clean up the
yay
build files (optional): -
Search for an Icon Theme using
yay
:
Let's look for the "Papirus" icon theme, which is very popular.-Ss
: Searches both official repositories and AUR. You'll see results.papirus-icon-theme
is likely the one from official repos or AUR. If it's in official repos,pacman
could install it. If it's AUR-only or you want the latest git version from AUR: When installing from AUR withyay
:- It might ask if you want to show diffs of PKGBUILDs or skip review. For trusted packages like Papirus, skipping review (
N
) is often fine after initial trust is established. - It will then download sources, build, and install.
-
Install
neofetch
:
neofetch
is a command-line system information tool that displays a logo of your OS and system details. It's often in official repositories, butyay
can install it too. -
Run
You should see an ASCII art Arch Linux logo and system information.neofetch
:
Open your terminal and type: -
Apply the Icon Theme (XFCE example):
- Open XFCE Settings Manager (usually
xfce4-settings-manager
or from the application menu). - Go to "Appearance."
- Select the "Icons" tab.
- You should see "Papirus" (or variants like Papirus-Dark, Papirus-Light) in the list. Select it.
- The icons in your system should change.
- (The method varies for other DEs like GNOME (use GNOME Tweaks) or KDE Plasma (System Settings -> Appearance -> Icons)).
- Open XFCE Settings Manager (usually
-
Customize
neofetch
(Optional Exploration):
neofetch
is highly customizable via its config file at~/.config/neofetch/config.conf
.- If the file doesn't exist,
neofetch
uses defaults. You can copy the default config to customize: (The path to default config might vary;neofetch --help
can show it, or just runneofetch
once to potentially create~/.config/neofetch/config.conf
automatically with defaults). - Open
~/.config/neofetch/config.conf
with a text editor (e.g.,mousepad ~/.config/neofetch/config.conf
). - Explore the options. You can change which info is displayed, the order, the ASCII art, colors, etc.
- For example, find
info "OS" distro
and change it toinfo "Operating System" distro
to change the label. - Save the file and run
neofetch
again to see changes.
- If the file doesn't exist,
Reflection:
- What is the AUR, and why are AUR helpers like
yay
useful? (Community repo; automate build/install process). - What are the security implications of using the AUR? (Packages are user-produced; inspect PKGBUILDs for unknown/untrusted packages).
- How does your desktop environment manage themes and icons? Where are these settings typically found?
- Explore
neofetch
's configuration. What interesting pieces of system information can it display?
This workshop gives you a taste of extending your system with community packages and customizing its look and feel. Arch Linux offers endless possibilities for personalization.
9. Hibernation Setup
Hibernation (suspend-to-disk) saves the content of your RAM to your swap space and powers off the computer. When you turn it back on, the system restores its state from swap, allowing you to resume exactly where you left off. This requires a sufficiently large swap partition or swap file and correct configuration.
We will primarily focus on hibernation with a swap partition, as it's generally more straightforward to set up. Hibernation with a swap file is possible but more complex.
Prerequisites for Hibernation:
- A swap partition (recommended size: RAM size + a bit more, e.g.,
sqrt(RAM_size_in_GB) * 1GB
). If your RAM is 8GB, a 9-10GB swap partition is a good idea. If you have a lot of RAM (e.g., 32GB), you might not need much more than RAM size unless you use a lot of it. - You know the UUID of your swap partition.
- You are comfortable editing kernel parameters and
mkinitcpio.conf
.
Configuring for Hibernation with a Swap Partition
-
Identify Your Swap Partition and its UUID:
Look for the partition with
If you don't remember your swap partition device name or UUID:TYPE="swap"
. Note its device name (e.g.,/dev/sdb2
) and its UUID. Alternatively, if it's already in your/etc/fstab
: This should show a line like:UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx none swap defaults 0 0
. Copy this UUID. Let's call itSWAP_UUID
. -
Configure the Bootloader with the
resume
Kernel Parameter:
The kernel needs to know which swap partition to use for resuming from hibernation.-
For GRUB:
- Edit
/etc/default/grub
: - Find the line starting with
GRUB_CMDLINE_LINUX_DEFAULT
(orGRUB_CMDLINE_LINUX
if the default one is empty). It might look likeGRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3"
. - Add the
resume=UUID=SWAP_UUID
parameter. For example: Replacexxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
with your actual swap partition's UUID. - Save the file.
- Re-generate the GRUB configuration:
- Edit
-
For systemd-boot:
- Edit your loader entry file(s) in
/boot/loader/entries/
(e.g.,arch.conf
,arch-lts.conf
). - Find the
options
line. It might look likeoptions root=UUID=YYYY-...YYY rw
. - Add
resume=UUID=SWAP_UUID
to this line. For example: - Save the file. Repeat for any other kernel entries if you have them.
- Edit your loader entry file(s) in
-
-
Configure the Initramfs with the
resume
Hook:
The initramfs needs to be able to handle the resume process early in boot. This is done by adding theresume
hook.- Edit
/etc/mkinitcpio.conf
: - Find the
HOOKS=(...)
line. It usually looks something like: -
Add the
If you use LVM and your swap is on an LVM LV, theresume
hook. Theresume
hook must come AFTERudev
and preferably beforefilesystems
. A good place is afterblock
orkeyboard
/keymap
if those are present and beforefilesystems
. Example:lvm2
hook should come beforeresume
. If you use LUKS encryption and swap is encrypted,encrypt
hook comes beforelvm2
(if applicable) andresume
. The general order for complex setups is oftenblock encrypt lvm2 resume filesystems
. -
Save the file.
-
Re-generate the initramfs:
- Edit
-
Reboot:
A reboot is necessary for the new kernel parameters and initramfs to take effect. -
Test Hibernation:
Your computer should save its state and power off. When you turn it back on, it should resume to your previous session.
After rebooting, try to hibernate:Troubleshooting Hibernation:
- System reboots instead of resuming:
This is common.- Check
dmesg | grep -i "resume\|hibernation"
for error messages after a failed resume. - Ensure
SWAP_UUID
is correct in kernel parameters andfstab
. - Ensure swap partition is large enough.
- Ensure
resume
hook is correctly placed inmkinitcpio.conf
and initramfs was rebuilt. - Some hardware/drivers can be problematic. Check Arch Wiki for hardware-specific quirks.
- Check
- Slow resume/hibernation:
Could be I/O speed of swap device. - System hangs:
Could be driver issues.
- System reboots instead of resuming:
Hibernation with a Swap File (More Complex)
Hibernating to a swap file is possible but requires more careful setup because the kernel needs to know the physical offset of the swap file on the disk. This is particularly tricky with CoW filesystems like Btrfs (though Btrfs has specific procedures).
General Steps for a Swap File on Ext4/XFS:
-
Create a Swap File:
(Let's assume you don't have a swap partition active).# Example: Create an 8GB swap file sudo fallocate -l 8G /swapfile # Preferred method if supported # OR # sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 status=progress sudo chmod 600 /swapfile sudo mkswap /swapfile # sudo swapon /swapfile # Activate temporarily for testing, but not for hibernation yet
-
Add Swap File to
Then run/etc/fstab
:sudo swapon -a
or reboot to make it active. -
Get Root Filesystem UUID and Swap File Offset:
ROOT_UUID
: UUID of the partition where/swapfile
resides (e.g., your/
partition). Get it fromlsblk -f
orcat /etc/fstab
.SWAP_FILE_OFFSET
: This is the physical offset of the swap file on the disk.- Crucial: The swap file must be contiguous and not fragmented.
fallocate
usually ensures this. - Install
btrfs-progs
if not present, as it providesfilefrag
:sudo pacman -S btrfs-progs
(even if not using Btrfs filesystem,filefrag
utility is useful). - Run:
sudo filefrag -v /swapfile
- Look at the output. You need the value from the
physical_offset
column for the first extent (usually under the0:
row, in thephysical_offset
column of theext: logical_offset physical_offset length expected
section). It's a number.
- Crucial: The swap file must be contiguous and not fragmented.
-
Configure Kernel Parameters:
- GRUB (
/etc/default/grub
): Thensudo grub-mkconfig -o /boot/grub/grub.cfg
. - systemd-boot (
/boot/loader/entries/arch.conf
):
- GRUB (
-
Configure
mkinitcpio.conf
:
Add theresume
hook as described for swap partitions. The hook will use the kernel parameters. -
Rebuild Initramfs:
sudo mkinitcpio -P
-
Reboot and Test.
Important for Swap Files:
- If the swap file is reallocated or defragmented, its
resume_offset
might change, breaking hibernation. This is why swap partitions are often preferred for reliability. - Swap files on Btrfs have specific requirements (no CoW on the file, specific setup). Consult the Arch Wiki for "Btrfs swap file".
Workshop Enabling Hibernation (with Swap Partition)
Goal:
Configure your Arch Linux system (which should have a swap partition from earlier workshops) to support hibernation.
Prerequisites:
- Your Arch Linux system is running.
- You created a dedicated swap partition during installation (e.g.,
/dev/sdb2
). - You are logged in as a user with
sudo
privileges. - You are using GRUB (as set up in a previous workshop). If using systemd-boot, adapt step 2.
Steps:
-
Identify Swap Partition UUID: Open a terminal and find the UUID of your swap partition.
This should output something like: Copy the UUID (the long string of hex characters). Let's refer to it asYOUR_SWAP_UUID
. Verify it's also correctly listed in/etc/fstab
: -
Add
Find the lineresume
Kernel Parameter to GRUB:GRUB_CMDLINE_LINUX_DEFAULT="..."
. It might containquiet
or other parameters. Addresume=UUID=YOUR_SWAP_UUID
inside the quotes. For example, if it wasGRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3"
, change it to:GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3 resume=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
(Replacexxxx...
with your actual swap UUID). Save the file (Ctrl+O
, Enter,Ctrl+X
in nano). -
Update GRUB Configuration:
Watch the output to ensure no errors. -
Add
Find theresume
Hook tomkinitcpio.conf
:HOOKS=(...)
line. Addresume
to theHOOKS
array, typically afterblock
and beforefilesystems
. Example original:HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block filesystems fsck)
Example modified:HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block resume filesystems fsck)
Save the file. -
Regenerate Initramfs:
Wait for it to complete without errors. -
Reboot the System:
-
Test Hibernation:
After the system reboots and you log in:- Open a few applications (e.g., terminal, text editor, web browser).
- Then, try to hibernate:
- The system should save its state to disk and power off.
- Turn the computer back on. It should boot up and restore your applications and their state as they were before hibernation.
-
Troubleshooting (if it reboots or doesn't resume):
- If it doesn't resume, log in and check kernel messages:
- Double-check:
- The swap UUID in
/etc/default/grub
(and thatgrub-mkconfig
was run). - The
resume
hook in/etc/mkinitcpio.conf
(and thatmkinitcpio -P
was run). - The swap partition is active (
swapon --show
). - The swap partition is large enough (at least RAM size).
- The swap UUID in
Reflection:
- Why are both a kernel parameter (
resume=UUID=...
) and an initramfs hook (resume
) needed for hibernation? (Kernel parameter tells the already-booted kernel where to find the hibernation image; the initramfs hook helps the early boot process handle the resume operation before the main rootfs is mounted). - What are the potential downsides or complexities of hibernating to a swap file compared to a swap partition? (Offset changes, fragmentation issues, specific filesystem considerations like Btrfs).
- If hibernation fails, what's a systematic way to diagnose the problem? (Check logs, verify configurations step-by-step, ensure sufficient swap space).
Successfully setting up hibernation can be very convenient, especially for laptop users.
10. Troubleshooting Common Issues
Even with careful installation, you might encounter issues. This section covers some common problems and basic troubleshooting steps. The Arch Wiki is your ultimate resource for detailed troubleshooting. Remember to approach problems methodically.
No Network Connectivity
Symptoms:
- Cannot ping external sites (e.g.,
ping archlinux.org
). - Web browser shows "Server not found."
pacman
cannot download packages.
Troubleshooting Steps:
-
Check Physical Connection:
- Wired:
Is the Ethernet cable properly plugged in at both ends? Are there link lights on the network adapter? - Wireless:
Is Wi-Fi turned on? Are you connected to the correct network? (Usenmcli dev wifi list
if using NetworkManager).
- Wired:
-
Check IP Address and Interface Status:
- Is your network interface (e.g.,
enp2s0
,wlan0
) listed asUP
? IfDOWN
, trysudo ip link set dev <interface> up
. - Does it have an IP address (inet)? If not, DHCP might have failed.
- Is your network interface (e.g.,
-
Check Network Service Status: If you're using NetworkManager (common):
- Is it active (running)? If not,
sudo systemctl start NetworkManager
andsudo systemctl enable NetworkManager
. - Check NetworkManager's own logs:
journalctl -u NetworkManager
. If you're usingsystemd-networkd
:
- Is it active (running)? If not,
-
Restart Network Service:
-
Check DHCP Client:
NetworkManager uses an internal DHCP client. If usingsystemd-networkd
, ensure its DHCP client is configured for the interface. If you manually trydhclient
ordhcpcd
, ensure only one DHCP client is active for an interface. -
Check DNS Resolution:
- Does this file contain
nameserver
entries (e.g.,nameserver 1.1.1.1
,nameserver 8.8.8.8
)? - NetworkManager and
systemd-resolved
usually manage this file. If it's missing or incorrect, DNS lookups will fail. - Test DNS:
ping 8.8.8.8
(pings Google's DNS server by IP). If this works butping google.com
fails, it's a DNS issue.
- Does this file contain
-
Check Firewall:
If you configured a firewall (UFW, firewalld), ensure it's not blocking necessary traffic (especially DNS on port 53/udp and 53/tcp, or outgoing HTTP/HTTPS). -
Router/Modem: Try rebooting your router/modem.
Bootloader Problems
Symptoms:
- System boots directly into BIOS/UEFI setup.
- GRUB rescue prompt appears (
grub rescue>
). - systemd-boot menu doesn't appear or shows no entries.
- Error messages like "No bootable device found."
Troubleshooting (requires booting from Arch Linux Live ISO):
- Boot from Arch Live ISO:
Ensure you boot in the same mode (UEFI or BIOS) as your installation. - Connect to Internet, Mount Partitions:
- Connect to Wi-Fi/Ethernet.
- Identify your partitions (
lsblk
). - Mount your root partition to
/mnt
. - Mount your ESP to
/mnt/boot
(or/mnt/efi
if that's your setup). - Mount any other necessary partitions like
/mnt/home
. - If using LVM/LUKS, open/activate them first.
arch-chroot
into your system:- Troubleshoot GRUB:
- Ensure
grub
andefibootmgr
(for UEFI) are installed (pacman -Q grub efibootmgr
). - Reinstall GRUB:
- UEFI:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --recheck
(adjust/boot
andGRUB
ID if needed). - BIOS:
grub-install --target=i386-pc /dev/sdX --recheck
(replace/dev/sdX
with your disk).
- UEFI:
- Regenerate
grub.cfg
: - Check
/etc/default/grub
for errors. - Check UEFI boot order (
efibootmgr
command from within chroot) - make sure GRUB is the top entry.
- Ensure
- Troubleshoot systemd-boot:
- Ensure ESP is mounted at
/boot
. - Reinstall:
bootctl --path=/boot install
. - Check
/boot/loader/loader.conf
for syntax errors and correctdefault
entry. - Check entry files in
/boot/loader/entries/
(e.g.,arch.conf
):- Correct paths to kernel (
/vmlinuz-linux
), initramfs (/initramfs-linux.img
), and microcode. - Correct
root=UUID=...
parameter. - Ensure files (
vmlinuz-linux
, etc.) actually exist in/boot
.
- Correct paths to kernel (
- Ensure ESP is mounted at
- Exit chroot, unmount, reboot.
Graphics Issues
Symptoms:
- Black screen after bootloader or when starting graphical session.
- Graphical session starts but is slow, tearing, or incorrect resolution.
- Error messages about "Failed to start Light Display Manager" or similar.
Troubleshooting:
-
Check Which Driver is Loaded:
Look for "Kernel driver in use". Is iti915
(Intel),amdgpu
(AMD),nouveau
ornvidia
(NVIDIA)? -
Check Xorg Logs: The primary log file for Xorg is
Look for lines starting with/var/log/Xorg.0.log
. (If Xorg fails and restarts, it might beXorg.1.log
).(EE)
(error) or(WW)
(warning). These often pinpoint the issue (driver not found, configuration error). -
Ensure Correct Drivers Are Installed:
- Intel:
mesa
,libva-intel-driver
,intel-media-driver
. - AMD:
mesa
,xf86-video-amdgpu
(orxf86-video-ati
for old cards). - NVIDIA:
nvidia
and its utils, or ensurenouveau
is being used if intended. If using proprietary NVIDIA, ensurenouveau
is blacklisted (lsmod | grep nouveau
should show nothing). The NVIDIA packages usually handle blacklisting.
- Intel:
-
Mesa Installation:
Ensuremesa
is installed, as it provides OpenGL implementation used by most DEs.pacman -Q mesa
-
Early KMS Start:
Kernel Mode Setting (KMS) should ideally start early in the boot process. Ensurekms
hook is in/etc/mkinitcpio.conf
(it's usually in the defaultHOOKS
array) and rebuild initramfs (sudo mkinitcpio -P
). For NVIDIA proprietary drivers, KMS setup can be different. Check Arch Wiki for "NVIDIA KMS". -
Display Manager Issues:
If Xorg seems fine but DE doesn't start, check Display Manager logs: -
Xorg Configuration (less common now):
Modern Xorg often auto-configures well. Manual Xorg config in/etc/X11/xorg.conf.d/
is less common but sometimes needed for specific hardware or multi-monitor setups. Errors here can break X. -
Switch to a TTY:
If the GUI is frozen or black, try switching to a text console:Ctrl+Alt+F2
(or F3-F6). Log in and troubleshoot from there.Ctrl+Alt+F1
orCtrl+Alt+F7
usually returns to the graphical session.
Sound Issues
Symptoms:
- No sound output.
- No microphone input.
- Applications report sound errors.
Troubleshooting (assuming PipeWire setup):
-
Check PipeWire Services:
Are they active (running)? If not:systemctl --user enable --now pipewire pipewire-pulse wireplumber
. -
Volume Levels and Muting:
- Use
pavucontrol
(PulseAudio Volume Control - works with PipeWire-Pulse).- Check "Output Devices" tab: Is the correct device selected? Is it unmuted? Is the volume slider up?
- Check "Playback" tab: Are applications listed? Is their output unmuted and volume up? Directed to correct sink?
- Use
alsamixer
(console mixer): PressF6
to select your sound card. Check master volume, PCM, speaker, headphone levels.MM
means muted; pressM
to unmute. Use arrow keys to adjust volume.
- Use
-
Correct Output Device:
Sometimes the wrong device (e.g., HDMI audio when you want analog speakers) is selected as default. Set the correct default sink inpavucontrol
("Output Devices" tab, click the checkmark icon next to the desired device). -
Application-Specific Settings:
Some applications have their own audio output/input settings. -
Reinstall PipeWire Packages:
-
Check
dmesg
for Sound Card Errors:
dmesg | grep -i "snd\|sof\|audio"
might show firmware loading issues or hardware detection problems. You might need additional firmware (e.g.,sof-firmware
).
Package Management Errors (Pacman)
-
"Invalid or corrupted package (PGP signature)":
Your system's keyring or the package signature is out of date or corrupt.- Update Arch keyring:
sudo pacman -Sy archlinux-keyring
- Re-initialize keys:
sudo pacman-key --init
- Populate keys:
sudo pacman-key --populate archlinux
- Then try your
pacman
command again. If it persists, try refreshing all keys:sudo pacman-key --refresh-keys
. This can take a while.
- Update Arch keyring:
-
"File exists in filesystem" errors during update/install:
Pacman thinks a file it wants to install/update is already owned by another package or exists untracked.- Identify the conflicting file path.
- Find which package owns it (if any):
pacman -Qo /path/to/conflicting/file
. - If it's owned by another package, there might be a packaging conflict you need to resolve (uninstall one, or one package might replace another).
- If it's an untracked file, you can try renaming/deleting it (at your own risk, understand what the file is) and retrying the
pacman
command. Or usesudo pacman -S --overwrite /path/to/conflicting/file package-name
to force overwrite that specific file. Use--overwrite '*'
with extreme caution.
-
"Failed to commit transaction (conflicting files)": Similar to above.
-
"Database lock" (
/var/lib/pacman/db.lck
):
Pacman or another utility (like an AUR helper) is already running or was interrupted.- Ensure no other pacman/yay instance is running.
- If you're sure none are running, remove the lock file:
sudo rm /var/lib/pacman/db.lck
.
-
"Error: GPGME error: No data" when updating mirrors or system:
Usually a temporary mirror issue or network problem.- Refresh mirrorlist with
reflector
. - Run
sudo pacman -Syyu
(doubley
forces refresh of all sync databases).
- Refresh mirrorlist with
Kernel Panics
Symptoms:
- System freezes during boot, displaying many lines of text, often including "Kernel panic - not syncing: ..." followed by an error message and a call trace.
Troubleshooting:
- Note the Error Message: The message after "Kernel panic - not syncing:" is crucial. Search for it online (especially on the Arch Wiki/forums).
- Hardware Issues: Kernel panics can be caused by failing RAM, overheating CPU, faulty motherboard, or disk errors. Run hardware diagnostics if possible (memtest86+ for RAM).
- Driver Issues: A buggy kernel module can cause a panic.
- Incorrect Kernel Parameters: Especially
root=
orresume=
. - Corrupted Filesystem:
fsck
might be needed. - Boot with an Older Kernel: If you have multiple kernels installed (e.g.,
linux
andlinux-lts
), try booting the other one from your bootloader menu. If it works, the issue is likely with the problematic kernel or its specific modules/config. - Chroot and Rebuild Initramfs:
sudo mkinitcpio -P
. - Chroot and Reinstall Kernel:
sudo pacman -S linux
(orlinux-lts
).
Workshop Debugging a Simulated Bootloader Problem (GRUB UEFI)
Goal:
Intentionally "break" the GRUB UEFI boot setup and then use the Arch Live ISO to chroot in and repair it. This simulates a common real-world recovery scenario.
Scenario:
Your Arch Linux system with GRUB (UEFI, ESP at /boot
) is currently booting fine. We will simulate a scenario where GRUB's core EFI file is "accidentally" deleted.
Warning:
This involves modifying boot files. While the fix is straightforward, ensure you're comfortable or doing this in a VM.
Steps to Simulate the Problem (from your running Arch system):
- Identify GRUB's EFI file:
It's typically at/boot/EFI/YOUR_BOOTLOADER_ID/grubx64.efi
. If your bootloader ID wasGRUB
orARCHGRUB
: - "Accidentally" rename/move it (safer than deleting for a simulation):
- Reboot:
Expected Outcome:
The system will likely fail to find GRUB. It might drop you into the UEFI firmware settings, show an error like "No bootable media," or try to network boot. It won't boot Arch.
Steps to Fix the Problem (using Arch Live ISO):
- Boot from Arch Live ISO:
Ensure you boot it in UEFI mode. - Verify Boot Mode:
ls /sys/firmware/efi/efivars
(should list files). - Connect to the Internet
(not strictly needed for this fix, but good practice). - Identify Your Partitions:
lsblk
. Note your root partition (e.g.,/dev/sda3
) and ESP (e.g.,/dev/sda1
). - Mount Partitions:
arch-chroot
into Your System:-
Diagnose within Chroot:
- You could just rename the file back:
mv /boot/EFI/GRUB/grubx64.efi.broken /boot/EFI/GRUB/grubx64.efi
. But let's practice a full reinstall as if it were truly gone or corrupted.
- You could just rename the file back:
-
Reinstall GRUB:
- Ensure
grub
andefibootmgr
are present (they should be):pacman -Q grub efibootmgr
. - Run the
grub-install
command you used originally. Adjust--efi-directory
and--bootloader-id
if they were different from this example: This command should recreate the/boot/EFI/GRUB/grubx64.efi
file and ensure the UEFI firmware entry is correct. "Installation finished. No error reported." is the goal.
- Ensure
-
Regenerate
grub.cfg
(Good practice, though not strictly needed if only EFI file was missing): -
Exit Chroot, Unmount, and Reboot:
Remove the Live ISO. Your system should now boot normally via GRUB.
Reflection:
- What was the key file that, when missing, prevented GRUB from loading? (
grubx64.efi
on the ESP). - Why is it important to boot the live ISO in the same mode (UEFI/BIOS) as your installed system when doing repairs? (Tools like
grub-install
andefibootmgr
behave differently or are unavailable in the wrong mode). - What are the essential steps for chrooting into a broken system for repair? (Boot live media, mount system partitions correctly,
arch-chroot
). - Besides reinstalling, what other GRUB-related files could cause boot issues if corrupted or misconfigured? (
/boot/grub/grub.cfg
, files in/boot/grub/<arch-type>/
).
This workshop demonstrates a fundamental recovery technique applicable to many boot-related problems.
Conclusion
Congratulations on successfully navigating the Arch Linux installation process! By building your system from the ground up, you've gained invaluable insight into the inner workings of a GNU/Linux distribution. This hands-on experience is one of Arch's greatest strengths, fostering a deeper understanding and appreciation for the components that make up a modern operating system.
The Arch Way Recap
Throughout this journey, you've encountered the core principles of Arch Linux, often referred to as "The Arch Way":
- Simplicity:
You began with a minimal base and added only what you needed, configuring services through straightforward text files. - User-Centrality:
You were in control at every step, making decisions about your partitioning scheme, bootloader, desktop environment, and system services. This control comes with responsibility, empowering you to create a system tailored precisely to your requirements. - Modernity:
You installed the latest stable software packages, and the rolling-release model ensures you'll continue to receive updates as they become available. - Pragmatism & Versatility:
Arch provides the tools and the framework; you decide how to use them to build anything from a lightweight server to a feature-rich desktop workstation.
Keeping Your System Up-to-Date
Arch Linux is a rolling-release distribution, meaning regular updates not only provide new features but also crucial security patches and bug fixes.
-
Update Regularly:
It's good practice to update your system frequently, perhaps once a week or every few days.-S
: Sync packages.y
: Refresh local package databases from the server (useyy
to force refresh all, useful if mirrors changed or after a long time).u
: Upgrade installed packages.
-
Read Arch News Before Major Updates:
Before running-Syu
, especially if it's been a while, check the Arch Linux homepage (https://archlinux.org/news/
) for any news items that might require manual intervention during an update. This is rare but important. -
AUR Packages: If you use an AUR helper like
Be mindful that AUR packages are user-submitted and compiled on your system; they might occasionally have issues or require attention during updates.yay
:
Further Learning Resources
Your learning journey with Arch Linux doesn't end here. The skills you've developed are a foundation for further exploration.
- The Arch Wiki (
https://wiki.archlinux.org/
):
This is your primary resource. It's an incredibly comprehensive and well-maintained knowledge base covering almost every aspect of Arch Linux and Linux in general. If you have a question or want to configure something, the Arch Wiki likely has an article on it. - Arch Linux Forums (
https://bbs.archlinux.org/
):
A place to ask questions (after searching the Wiki and forums first!), share solutions, and discuss Arch Linux with the community. - Man Pages:
Don't forget the manual pages for commands:man <command>
. /usr/share/doc/
:
Many packages install additional documentation here.
Encouragement
Installing Arch Linux can be challenging, but the rewards – a system built to your specifications and a profound understanding of its architecture – are well worth the effort. You've demonstrated patience, attention to detail, and a willingness to learn. These qualities will serve you well as you continue to explore the vast and exciting world of Linux.
Embrace the "do-it-yourself" philosophy, continue to experiment (perhaps in a virtual machine first for risky changes), and don't be afraid to break things – that's often how the best learning happens. The Arch community and the extensive documentation are there to support you.
Welcome to the Arch Linux community! Enjoy your new system.