Arch Linux Installation: A Step-by-Step Guide
Hey guys! So, you're thinking about diving into the world of Arch Linux? Awesome! Arch is a super customizable and powerful distro, but let's be real, the installation process can seem a bit intimidating at first. Don't worry, though! This guide is here to walk you through each step, making the process as smooth as possible. We'll break it down in a way that's easy to understand, even if you're not a Linux guru just yet. We'll cover everything from preparing your system to the final configuration, ensuring you have a fully functional Arch Linux setup. So, grab your favorite beverage, get comfy, and let's get started!
Preparing for the Installation
Before we even think about touching the command line, there are some crucial preparations we need to take care of. This is like laying the foundation for a solid building – get this right, and the rest will be much smoother. We're talking about downloading the Arch Linux ISO, creating bootable media, and configuring your system's BIOS or UEFI settings. These steps are vital to ensure that your computer can boot into the Arch Linux installation environment. Skipping these steps or doing them incorrectly can lead to frustration and potential roadblocks later on. So, let's take our time and make sure everything is set up perfectly.
Downloading the Arch Linux ISO
The first thing you'll need is the Arch Linux ISO image. Think of this as the master key to unlocking your Arch installation. This ISO contains all the necessary files and tools to get your system up and running. To grab the latest version, head over to the official Arch Linux website. You'll find a list of mirror servers – these are basically different locations where the ISO is hosted. Choose one that's geographically close to you for faster download speeds. Once you've downloaded the ISO, it's a good idea to verify its integrity. This means checking if the downloaded file is exactly the same as the one on the server, ensuring it hasn't been corrupted during the download process. You can do this by comparing the checksum (a unique fingerprint of the file) provided on the Arch Linux website with the checksum of your downloaded ISO. There are various tools available for this, depending on your operating system. Verifying the ISO is a small step that can save you from potential headaches down the line, so don't skip it!
Creating Bootable Media
Okay, you've got the ISO, now what? We need to get it onto a USB drive or DVD so we can boot your computer from it. This is what we call creating bootable media. A USB drive is generally the preferred method these days, as it's faster and more convenient. There are several tools you can use to create a bootable USB, such as Rufus (for Windows), Etcher (cross-platform), or the dd
command (for Linux users). Each tool has its own way of doing things, but the basic principle is the same: you select the Arch Linux ISO and tell the tool to write it to your USB drive. Make sure you choose the correct USB drive, as this process will erase all data on it! Once the bootable media is created, you're one step closer to installing Arch Linux. This step is critical because your computer needs to boot from this media to start the installation process. A corrupted or incorrectly created bootable USB can prevent your system from booting into the Arch Linux environment, so double-check that everything is done correctly.
Configuring BIOS/UEFI Settings
Alright, time to dive into your computer's BIOS or UEFI settings. This is where you tell your computer to boot from the USB drive or DVD we just created. The way you access these settings varies depending on your computer's manufacturer, but it usually involves pressing a specific key during startup, such as Delete, F2, F12, or Esc. You might need to consult your computer's manual or do a quick online search to find the correct key for your system. Once you're in the BIOS/UEFI settings, look for the boot order or boot priority options. You'll need to change the order so that your USB drive or DVD is listed before your hard drive. This ensures that your computer tries to boot from the installation media first. You might also need to disable Secure Boot, a feature that prevents the system from booting from unsigned media. Secure Boot can sometimes interfere with the Arch Linux installation process, so disabling it can help avoid potential issues. Remember to save your changes before exiting the BIOS/UEFI settings. Getting these settings right is crucial because if your computer doesn't boot from the installation media, you won't be able to proceed with the Arch Linux installation. So, take your time and make sure everything is configured correctly.
Starting the Installation Process
Okay, so you've got your bootable media ready, and your BIOS/UEFI settings are configured. Now for the exciting part: booting into the Arch Linux installation environment! This is where the real fun begins. You'll be greeted with a command-line interface – don't panic! This is perfectly normal for Arch Linux. The installation process is largely command-line based, which might seem daunting at first, but trust me, it's not as scary as it looks. We'll guide you through each command step-by-step. We'll start by verifying the boot mode, connecting to the internet, and updating the system clock. These initial steps are crucial for setting up the environment and ensuring that everything is in sync. A stable internet connection is essential for downloading packages during the installation, and an accurate system clock is important for various system processes. So, let's get started and dive into the command line!
Booting into the Installation Medium
With your bootable media inserted and your BIOS/UEFI settings adjusted, restart your computer. If everything is set up correctly, your system should boot from the USB drive or DVD and you'll be greeted by the Arch Linux boot menu. From here, you'll typically select the first option, which is usually something like "Arch Linux install medium." This will boot you into a live environment, which is a fully functional operating system running from the installation media. Once the system has booted, you'll be presented with a command-line prompt. This is your gateway to installing Arch Linux. It might look intimidating, but don't worry, we'll be using this command line to execute the necessary commands for the installation. If you don't see the Arch Linux boot menu, it's likely that your BIOS/UEFI settings are not configured correctly, or the bootable media was not created properly. Double-check these steps and try again. Successfully booting into the installation medium is the first major milestone in the Arch Linux installation process.
Verifying the Boot Mode
Before we proceed further, it's essential to verify the boot mode. This means checking whether your system has booted in UEFI mode or BIOS (legacy) mode. UEFI is the modern standard, and if your system supports it, it's generally recommended to install Arch Linux in UEFI mode. To check the boot mode, you can use the following command in the terminal: ls /sys/firmware/efi/efivars
. If this command shows a directory listing, it means your system has booted in UEFI mode. If the directory doesn't exist, it means you've booted in BIOS mode. Knowing the boot mode is crucial because it affects how we partition the disks and install the bootloader later on. Installing Arch Linux in the wrong boot mode can lead to boot issues and a non-functional system. So, take a moment to verify your boot mode before proceeding. If you accidentally booted in the wrong mode, you'll need to reboot your system and adjust your BIOS/UEFI settings accordingly.
Connecting to the Internet
Next up, we need to connect to the internet. A stable internet connection is crucial during the Arch Linux installation because we'll be downloading packages from the Arch repositories. If you're using a wired connection, chances are you'll be automatically connected to the internet. You can verify this by pinging a website, such as Google, using the command ping google.com
. If you get a response, you're connected. If you're using Wi-Fi, you'll need to connect manually. The easiest way to do this is using the iwctl
command-line utility. First, type iwctl
to enter the iwctl
interface. Then, use the following commands:
device list
: This will list your network interfaces. Identify the name of your Wi-Fi interface (e.g.,wlan0
).station <interface> scan
: Replace<interface>
with the name of your Wi-Fi interface. This will scan for available Wi-Fi networks.station <interface> get-networks
: This will list the available Wi-Fi networks.station <interface> connect <SSID>
: Replace<interface>
with your Wi-Fi interface name and<SSID>
with the name of your Wi-Fi network. You'll be prompted for the password.exit
: This will exit theiwctl
interface.
Once you've connected to Wi-Fi, verify the connection by pinging a website again. A stable internet connection is essential for downloading the necessary packages and completing the installation successfully. Without it, you'll encounter errors and won't be able to proceed.
Updating the System Clock
Before we move on, it's important to update the system clock. An accurate system clock is crucial for various system processes and can prevent issues later on. To synchronize the system clock with a network time server, use the following command: timedatectl set-ntp true
. This command will enable Network Time Protocol (NTP) synchronization, which automatically updates the system clock. You can check the status of the NTP synchronization using the command timedatectl status
. Look for the line "NTP service: active" to confirm that NTP is enabled and working correctly. Updating the system clock is a simple step, but it's an important one to ensure a smooth and trouble-free installation process. An incorrect system clock can lead to problems with package installations, certificate validations, and other time-sensitive operations.
Partitioning the Disks
Alright, buckle up, guys! We're about to dive into one of the most crucial steps of the installation: partitioning the disks. This is where we divide your hard drive into different sections, each with its own purpose. Think of it like organizing your room – you wouldn't just dump everything in one pile, right? You'd have separate spaces for your clothes, books, and other belongings. Similarly, we'll create partitions for the root directory, the boot partition, and optionally a swap partition. The root partition is where the main system files will be installed, the boot partition is where the bootloader will reside, and the swap partition is used as virtual memory. Choosing the right partitioning scheme is essential for the stability and performance of your Arch Linux system. We'll be using the fdisk
utility, a powerful command-line tool for managing disk partitions. Don't worry if you've never used it before; we'll walk you through each step. It's important to be careful during this process, as mistakes can lead to data loss. So, let's take our time and make sure we get it right.
Identifying the Disks
First things first, we need to identify the disks on your system. To do this, we'll use the lsblk
command. This command lists all block devices, including hard drives and partitions. The output will show you the device names, such as /dev/sda
, /dev/nvme0n1
, and so on. It's crucial to identify the correct disk you want to install Arch Linux on. Be extra careful here, as choosing the wrong disk can lead to data loss on other drives. Once you've identified the correct disk, make a note of its device name. We'll be using this name in the next steps when we create the partitions. If you have multiple disks, take your time to double-check that you've selected the right one. This is a critical step, and accuracy is key to avoiding potential problems.
Using fdisk
to Create Partitions
Now that we know which disk we're working with, it's time to fire up fdisk
and create the partitions. fdisk
is a powerful command-line utility that allows us to manage disk partitions. To start fdisk
, use the command fdisk /dev/sdX
, replacing /dev/sdX
with the device name of your disk (e.g., /dev/sda
). You'll be greeted with the fdisk
prompt. Here's a breakdown of the basic commands you'll need:
g
: Create a new GPT partition table (recommended for UEFI systems).o
: Create a new DOS partition table (for BIOS/legacy systems).n
: Create a new partition.p
: Print the partition table.d
: Delete a partition.w
: Write the changes to disk and exit.q
: Quit without saving changes.
For a basic Arch Linux installation, we'll typically create three partitions:
- Root partition (
/
): This is where the main system files will be installed. A size of 20-30GB is usually sufficient. - Boot partition (
/boot
): This is where the bootloader will reside. A size of 512MB is recommended. - Swap partition: This is used as virtual memory. The size depends on your system's RAM and usage patterns. A common recommendation is to use a size equal to your RAM, or twice your RAM if you have less than 8GB of RAM.
When creating the partitions, you'll be prompted for the partition number, first sector, and last sector. For the first partition, you can usually accept the default values for the first sector. For the last sector, you'll need to specify the size of the partition. You can do this by entering +<size>G
for gigabytes (e.g., +20G
for 20GB) or +<size>M
for megabytes (e.g., +512M
for 512MB). Once you've created all the partitions, use the p
command to print the partition table and verify that everything is correct. If you're happy with the layout, use the w
command to write the changes to disk and exit fdisk
. Remember, writing the changes is a destructive operation, so double-check everything before you proceed.
Formatting the Partitions
With the partitions created, we now need to format them. Formatting a partition prepares it for storing files by creating a file system. We'll be using the mkfs
command for this. The specific command you'll use depends on the file system you want to use. For the root partition, ext4
is a common and reliable choice. For the boot partition, ext4
or FAT32
are often used. For the swap partition, we'll use the mkswap
command. Here are the commands you'll need:
- Root partition:
mkfs.ext4 /dev/sdXY
(replace/dev/sdXY
with the device name of your root partition, e.g.,/dev/sda2
) - Boot partition:
mkfs.ext4 /dev/sdXZ
(replace/dev/sdXZ
with the device name of your boot partition, e.g.,/dev/sda1
) - Swap partition:
mkswap /dev/sdXW
(replace/dev/sdXW
with the device name of your swap partition, e.g.,/dev/sda3
)
After formatting the swap partition, you need to enable it using the command swapon /dev/sdXW
. Formatting the partitions is a crucial step because it creates the file systems that will be used to store the operating system files. Without formatting, the partitions would be just empty spaces on the disk. So, make sure you format each partition correctly before moving on.
Installing the Base System
Okay, we've partitioned and formatted the disks, which means we're ready to install the base system! This is where we'll be copying the core files of Arch Linux onto your newly created partitions. We'll start by mounting the partitions, which is like connecting them to the file system tree. Then, we'll use the pacstrap
script to install the base packages, which include the kernel, system utilities, and other essential components. This step is the heart of the Arch Linux installation process, as it lays the foundation for your entire system. The pacstrap
script automates the process of downloading and installing the packages, making it much easier than manually installing each package individually. So, let's get those base packages installed and start building your Arch Linux system!
Mounting the Partitions
Before we can install anything, we need to mount the partitions. Mounting a partition makes it accessible within the file system. We'll start by mounting the root partition to /mnt
, which is the standard mount point for temporary file systems during installation. Then, we'll create a /mnt/boot
directory and mount the boot partition to it. Here are the commands you'll need:
mount /dev/sdXY /mnt
(replace/dev/sdXY
with the device name of your root partition, e.g.,/dev/sda2
)mkdir /mnt/boot
mount /dev/sdXZ /mnt/boot
(replace/dev/sdXZ
with the device name of your boot partition, e.g.,/dev/sda1
)
If you have a separate partition for /home
, you can mount it to /mnt/home
as well. Mounting the partitions is a crucial step because it allows us to access and write to them. Without mounting, we wouldn't be able to install the base system or configure the bootloader. So, make sure you mount the partitions correctly before proceeding.
Installing Base Packages with pacstrap
Now for the main event: installing the base packages using the pacstrap
script. This script is a lifesaver, as it automates the process of downloading and installing the essential components of Arch Linux. We'll be using the pacstrap
script to install the base
package group, which includes the Linux kernel, systemd, and other core utilities. We'll also install some additional packages, such as base-devel
, linux-firmware
, networkmanager
, vim
, and dhcpcd
. These packages provide essential development tools, firmware for your hardware, network management capabilities, a text editor, and a DHCP client for automatic IP address assignment. Here's the command you'll need:
pacstrap /mnt base base-devel linux-firmware networkmanager vim dhcpcd
This command will download and install the specified packages to the /mnt
directory, which is where we mounted the root partition. The installation process may take some time, depending on your internet connection speed and system performance. Be patient and let the script do its thing. Installing the base packages is a critical step because it provides the foundation for your Arch Linux system. Without these packages, your system wouldn't be able to boot or function properly. So, make sure the installation completes successfully before moving on.
Configuring the System
Awesome! We've got the base system installed, which means we're making great progress. Now it's time to configure the system, which involves generating the fstab
file, setting the time zone, configuring localization, setting the hostname, configuring the network, setting the root password, and installing a bootloader. This is where we'll be customizing Arch Linux to fit your specific needs and preferences. We'll be diving into the system's configuration files and making the necessary adjustments to ensure a smooth and functional system. This step is crucial because it's where we'll be setting up the basic system settings that will be used every time you boot your computer. So, let's roll up our sleeves and get configuring!
Generating fstab
The first thing we need to do is generate the fstab
file. The fstab
file is a configuration file that tells the system how to mount the partitions at boot time. It's essential for ensuring that your partitions are mounted correctly every time you start your computer. We'll be using the genfstab
utility to automatically generate the fstab
file based on the current partition layout. To generate the fstab
file, use the following command:
genfstab -U /mnt >> /mnt/etc/fstab
The -U
option tells genfstab
to use UUIDs (Universally Unique Identifiers) to identify the partitions. UUIDs are unique identifiers that are assigned to each partition, making them more reliable than device names (e.g., /dev/sda1
), which can change if you add or remove disks. The >>
operator appends the output of genfstab
to the /mnt/etc/fstab
file. It's a good idea to check the generated fstab
file to make sure everything looks correct. You can do this by using a text editor like vim
to open the file: vim /mnt/etc/fstab
. Verify that all your partitions are listed with the correct mount points and file system types. A correctly generated fstab
file is crucial for the proper functioning of your Arch Linux system. Without it, your system might not be able to mount the partitions at boot time, leading to boot failures.
Chrooting into the New System
Okay, we've generated the fstab
file, now it's time to chroot into the new system. Chrooting is a process that changes the root directory for the current process and its children. In our case, we'll be changing the root directory from the live environment to the root partition of our newly installed Arch Linux system. This allows us to perform further configuration tasks as if we were running inside the installed system. To chroot, use the following command:
arch-chroot /mnt
This command will change the root directory to /mnt
, which is where we mounted the root partition. From now on, any commands you execute will be run within the context of the installed Arch Linux system. Chrooting is an essential step because it allows us to configure the system from the inside, ensuring that the changes are applied to the installed system and not just the live environment. Once you've chrooted, you'll notice that the command prompt changes, indicating that you're now in the chrooted environment.
Setting the Time Zone
With the system chrooted, we can now set the time zone. Setting the time zone ensures that your system's clock is synchronized with the correct time zone, which is important for various applications and services. To set the time zone, we'll first create a symbolic link from the desired time zone file in /usr/share/zoneinfo
to /etc/localtime
. You can find a list of available time zones in the /usr/share/zoneinfo
directory. For example, to set the time zone to America/Los_Angeles, you would use the following command:
lndir -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
Replace America/Los_Angeles
with your desired time zone. After setting the time zone, you need to synchronize the hardware clock with the system clock. To do this, use the following command:
hwclock --systohc
This command will set the hardware clock (the clock that keeps track of time even when the system is powered off) to the current system time. Setting the time zone correctly is important for various reasons, including accurate timestamps for logs, proper scheduling of tasks, and correct display of time in applications. So, make sure you set the time zone to your correct location.
Configuring Localization
Next up, we need to configure localization. Localization involves setting the system's language, character encoding, and other locale-specific settings. This ensures that your system displays text correctly and uses the appropriate conventions for your language and region. To configure localization, we'll need to edit the /etc/locale.gen
file and uncomment the locales you want to use. Open the file with a text editor like vim
: vim /etc/locale.gen
. Find the lines corresponding to your desired locales and remove the #
symbol at the beginning of the line to uncomment them. For example, to enable the en_US.UTF-8
locale, you would uncomment the line en_US.UTF-8 UTF-8
. Save the file and exit the editor. After editing /etc/locale.gen
, you need to generate the locales using the locale-gen
command:
locale-gen
This command will generate the locale files based on the uncommented locales in /etc/locale.gen
. Once the locales are generated, you need to set the system locale by creating the /etc/locale.conf
file and setting the LANG
variable. For example, to set the system locale to en_US.UTF-8
, you would create the file with the following content:
LANG=en_US.UTF-8
You can create the file using a text editor like vim
or by using the echo
command: `echo