Introduction to Arch Linux and Its Philosophy
Arch Linux is a lightweight, flexible, and simplicistic Linux distribution that follows the KISS (Keep It Simple, Stupid) principle. Unlike Ubuntu or Fedora, Arch does not come with a pre-configured desktop environment; instead, it provides a base system that users can customize to their exact needs. This approach makes Arch an excellent choice for users who want to learn the inner workings of Linux and build a system tailored specifically for them.
For beginners, the installation process can seem daunting because it is primarily command-line based. However, following a structured, step-by-step guide can help you avoid common pitfalls and errors. This guide will walk you through the entire process, from booting the installation media to configuring a robust system with a desktop environment, and finally, optimizing it for daily use.
Why Choose Arch Linux?
Rolling Release Model
: Arch Linux uses a rolling release model, meaning you install once and update continuously. You always have the latest software without needing to reinstall the system.
Customizability
: You start with a minimal base system and build up, giving you complete control over what is installed and configured.
The Arch User Repository (AUR)
: The AUR is a community-driven repository that contains thousands of packages not available in the official repositories, making it easy to install almost any software.
Excellent Documentation
: The Arch Wiki is one of the best sources of Linux documentation available, covering almost every aspect of the Arch system.
Common Pitfalls for Beginners
Before diving into the installation, it’s important to be aware of common mistakes:
Not Reading the Arch Wiki
: The Arch Wiki is your best friend. Always refer to it for hardware-specific issues or advanced configurations.
Skipping the Basics
: Rushing through the base installation without understanding what you’re doing can lead to a broken system later.
Arch Linux安装过程中,用户需要手动分区、配置引导加载程序等,这些步骤如果出错,可能导致系统无法启动。
Not Backing Up Data
: Always back up important data before starting the installation process.
Using Unofficial Guides
: Stick to the official installation guide or well-regarded community guides like this one to avoid outdated information.
Pre-Installation: Preparing Your System
Before you start the installation, you need to准备你的电脑 and prepare the installation media. This section covers hardware requirements, downloading the ISO, creating a bootable USB drive, and BIOS/UEFI settings.
Hardware Requirements
Arch Linux is known for its low resource usage, but you still need a system that meets these minimum requirements:
Processor
: Any 64-bit x86_64 processor (i386 is no longer supported).
RAM
: Minimum 512MB, but 2GB or more is recommended for a desktop environment.
Storage
: At least 20GB of free space; 40GB or more is recommended for a full desktop setup.
Internet Connection
: Required for downloading packages during installation.
Downloading the Arch Linux ISO
Visit the official Arch Linux website:
https://archlinux.org/download/
Choose a mirror close to your location for faster downloads.
Download the ISO file (usually named archlinux-xxxx.xx.xx-x86_64.iso).
Verify the checksum to ensure the file was downloaded correctly. You can do this with the command:
sha256sum archlinux-xxxx.xx.xx-x86_64.iso
Compare the output with the checksum provided on the download page.
Creating a Bootable USB Drive
You can use various tools to create a bootable USB drive. Here are two common methods:
Method 1: Using
dd
(Linux/macOS)
Insert your USB drive (make sure it’s at least 2GB).
Identify the device name using
lsblk
or
fdisk -l
. For example, it might be
/dev/sdb
(注意:不是 /dev/sdb1)。
Unmount the USB drive if it’s mounted:
umount /dev/sdb*
Write the ISO to the USB drive:
sudo dd if=archlinux-xxxx.xx.xx-x86_64.iso of=/dev/sdb bs=4M status=progress && sync
Warning
: This command will erase all data on the USB drive. Double-check the device name before executing.
Method 2: Using Rufus (Windows)
Download Rufus from
https://rufus.ie/
.
Run Rufus and select your USB drive.
Select the Arch Linux ISO file.
For UEFI systems, select “GPT” for the partition scheme and “UEFI (non-CSM)” for the target system.
Click “Start” and wait for the process to complete.
BIOS/UEFI Settings
Secure Boot
: Arch Linux does not support Secure Boot by default. You need to disable Secure Boot in your BIOS/UEFI settings. Some distributions like EndeavourOS or Manjaro may have workarounds, but for pure Arch, it’s best to disable it.
Boot Order
: Set the USB drive as the first boot device.
3.
Boot Mode
: Ensure you know whether your system is booting in UEFI or Legacy BIOS mode. The installation steps differ slightly between the two. Most modern systems use UEFI.
Step-by-Step Installation Guide
Once you have prepared your installation media and adjusted your BIOS settings, you can boot into the Arch Linux live environment and start the installation process.
Booting into the Live Environment
Insert the bootable USB drive and restart your computer.
You should see the Arch Linux boot menu. Select “Arch Linux archiso x86_64 USB” and press Enter.
After a few seconds, you will be logged in as root in a TTY (Teletype) terminal. There is no graphical interface at this point.
The live environment automatically loads keymaps and font. If you have a HiDPI display, you may need to adjust the font size:
setfont ter-v32n
Verify your internet connection:
ping -c 3 archlinux.org
If you have no internet, see the troubleshooting section below.
Partitioning Your Disk
This is one of theUEFI and Legacy BIOS (MBR) partitioning schemes. We will cover both.
UEFI Systems (Most Modern Computers)
For UEFI systems, you need at least two partitions: an EFI System Partition (ESP) and a root partition.
Identify your disk
: Use
lsblk
to list all block devices. Your disk will be something like
/dev/sda
or
/dev/nvme0n1
.
Partition the disk
: We’ll use
fdisk
for partitioning. Replace
/dev/sdX
with your disk name.
fdisk /dev/sdX
Inside
fdisk
, use these commands:
g
to create a new empty GPT partition table.
n
to create a1.
Create the EFI partition
:
Partition number: press Enter for default
First sector: press Enter for default
Last sector: +512M (for 512MB)
n
to create the root partition:
Partition number: press Enter for default
First sector: press Enter for 1.
Set partition types
:
t
to change a partition type
Select partition 1 and set type to
1
(EFI System)
Select partition 2 and set type to
20
(Linux filesystem)
w
to write the changes and exit.
Format the partitions
:
Format the EFI partition as FAT32:
mkfs.fat -F32 /dev/sdX1
Format the root partition as ext4 (or btrfs if you prefer):
mkfs.ext4 /dev/sdX2
Legacy BIOS (MBR) Systems
For older systems using Legacy BIOS, you need at least two partitions: a boot partition and a root partition.
Identify your disk
: Use
lsblk
to list all block1.
Partition the disk
: Use
fdisk
to partition the disk.
installation guide for beginners to install and configure a robust system avoiding common pitfalls and errors
fdisk /dev/sdX
Inside
fdisk
, use these commands:
o
to create a new empty MBR partition table.
n
to create a 1.
Create the boot partition
:
Partition type: Primary
Partition number: 1
First sector: press Enter for default
Last sector: +512M
n
to create the root partition:
Partition type: Primary
-1.
Set the bootable flag
:
a
to toggle the bootable flag
Select partition 1 (the boot partition)
w
to write the changes and exit.
Format the partitions
:
Format the boot partition as ext4:
mkfs.ext4 /dev/sdX1
Format the root partition as ext4:
Mounting the Filesystems
After partitioning and formatting, you need to mount the partitions.
For UEFI Systems
# Mount the root partition to /mnt
mount /dev/sdX2 /mnt
# Create the EFI directory and mount the EFI partition
mkdir -p /mnt/boot/efi
mount /dev/sdX1 /mnt/boot/ent
For Legacy BIOS Systems
# Mount the root partition to /mnt
mount /dev/sdX2 /pac
# Mount the boot partition to /mnt/boot
mount /dev/sdX1 /mnt/boot
Installing the Base System
Now you can use
pacman
to install the essential packages onto the mounted filesystem. This command will install the Linux kernel, firmware, and other necessary tools.
pacstrap /mnt base linux linux-firmware
base
: The minimal set of packages needed for a Arch Linux system.
linux
: The latest stable Linux kernel.
linux-firmware
: Firmware files for many hardware devices.
If you have a specific kernel version需求 (e.g., LTS kernel for stability), you can install
linux-lts
instead of
linux
. For AMD GPU users, you might need to install
amd-ucode
for microcode updates.
Generating the Filesystem Table (fstab)
The fstab file tells the system which partitions to mount at boot time. Generate it automatically with:
genfstab -U /mnt >> /mnt/etc/fstab
Check the generated file to ensure it’s correct:
cat /mnt/etc/fstab
Chroot into the New System
Chroot (change root) allows you to run commands as if you were inside your new Arch Linux system.
arch-chroot /mnt
Configuring the Basic System
Inside the chroot environment, you need to configure several key settings.
Set the Timezone
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock –systohc
Replace
Region/City
with your location, e.g.,
America/New_York
or
Asia/Shanghai
.
Localization (Locale)
Edit
/etc/locale.gen
and uncomment your desired locale (e.g.,
en_US.UTF-8 UTF-8
).
Generate the locale:
locale-gen
Set the system language in
/etc/locale.conf
:
echo “LANG=en_US.UTF-8” > /etc/locale.conf
Set the keyboard layout in
/etc/vconsole.conf
:
echo “KEYMAP=us” > /etc/vconsole.conf
Network Configuration
Set the hostname:
echo “myarch” > /etc/hostname
Add entries to
/etc/hosts
:
cat <
127.0.0.1 localhost
::1 localhost
127.0.1.1 myarch.localdomain myarch
EOF
Set Root Password
passwd
Installing and Configuring the Bootloader
The bootloader is essential for starting your operating system. For UEFI systems, we’ll use systemd-boot; for Legacy BIOS, we’ll use GRUB.
For UEFI Systems: systemd-boot
Install systemd-boot
:
bootctl install
Create a boot entry
:
cat <
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=$(blkid -s PARTUUID -o value /dev/sdX2) rw
EOF
Important
: Replace
/dev/sdX2
with your root partition. You can find the PARTUUID with
blkid -s PARTUUID -o value /dev/sdX2
.
Configure the loader
:
cat <
default arch
timeout 5
console-mode max
EOF
For Legacy BIOS: GRUB
Install GRUB
:
pacman -S grub
Install GRUB to the MBR
:
grub-install –target=i386-pc /dev/sdX
Replace
/dev/sdX
with your disk (not a partition).
Generate the GRUB configuration file
:
grub-mkconfig -o /boot/grub/grub.cfg
Exit, Unmount, and Reboot
Exit the chroot environment:
exit
Unmount all partitions:
umount -R /mnt
Reboot the system:
reboot
Remove the USB drive when prompted.
Post-Installation: Configuring a Robust System
Congratulations! You have a base Arch Linux system installed. Now, let’s configure it to make it robust and user-friendly.
First Boot and Basic System Updates
After rebooting, you’ll be greeted with a login prompt. Log in as root with the password you set earlier.
Create a user account
(never use root for daily tasks):
useradd -m -G wheel username
Replace
username
with your desired username. The
-m
flag creates a home directory, and
-G wheel
adds the user to the wheel group for sudo privileges.
Set password for the new user
:
passwd username
Install sudo
:
pacman -S sudo
Enable sudo for the wheel group
:
visudo
Find the line
# %wheel ALL=(ALL)ALL
and uncomment it by removing the
#
.
Log out and log back in as your new user
.
Update the system
:
sudo pacman -Syu
This will update all packages to the latest versions.
Installing Essential Packages
Install some essential packages for a better command-line experience:
sudo pacman -S nano git wget curl htop
Installing a Desktop Environment (DE) and Display Manager (DM)
This is where you start building your graphical interface. We’ll install KDE Plasma as an example, but you can choose any DE (GNOME, XFCE, etc.).
Installing KDE Plasma
Install the KDE Plasma group
:
sudo pacman -S plasma
This includes the desktop environment and basic applications.
Install a display manager (DM)
:
sudo pacman -S sddm
SDDM is the recommended DM for KDE.
Enable the display manager
:
sudo systemctl enable sddm
Install additional packages for networking and audio
:
sudo pacman -S networkmanager plasma-nm pipewire pipewire-pulse
networkmanager
: For network management.
plasma-nm
: NetworkManager applet for KDE.
pipewire
: Modern audio server (replaces PulseAudio).
pipewire-pulse
: PulseAudio compatibility for PipeWire.
Enable NetworkManager
:
sudo systemctl enable NetworkManager
Reboot
:
sudo reboot
After rebooting, you should see SDDM, and you can log into your KDE Plasma desktop.
Configuring Graphics Drivers
Proper graphics drivers are crucial for performance and stability.
NVIDIA Users
Identify your NVIDIA card
:
lspci | grep -i nvidia
Install the appropriate driver
:
For modern cards (Maxwell and newer):
nvidia
For older cards:
nvidia-470xx-dkms
(from AUR)
For very old cards:
nvidia-390xx-dkms
(from AUR)
Install the driver and related packages
:
sudo pacman -S nvidia nvidia-utils nvidia-settings
Enable NVIDIA persistence daemon
(optional but recommended):
sudo systemctl enable nvidia-persistenced
For KDE Plasma (Wayland)
: If you want to use Wayland instead of X11, you need to install
nvidia-dkms
and configure kernel parameters. See the Arch Wiki for details.
AMD Users
Install the open-source driver
:
sudo pacman -S xf86-video-amdgpu mesa
The open-source driver is generally recommended for AMD cards.
For newer APUs or GPUs
, you might need to install
linux-firmware
(already installed earlier) and
amd-ucode
for microcode updates.
Intel Users
Install the driver
:
sudo pacman -S xf86-video-intel mesa
For modern Intel GPUs
, the open-source driver is recommended.
Setting Up the AUR (Arch User Repository)
The AUR is a key feature of Arch Linux, containing thousands of community-maintained packages. To use it, you need an AUR helper like
yay
or
paru
. We’ll install
yay
.
Install base-devel and git
(needed for building AUR packages):
sudo pacman -S base-devel git
Clone and build yay
:
git clone https://aur.archlinux.org/yay.git
yay -S yay
Use yay to install packages
:
“
AUR helper like yay or paru. We’ll install
yay`.
Install base-devel and git
(needed for building AUR packages):
sudo pacman -S base-devel git
Clone and build yay
:
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Use yay to install packages
:
yay -S package-name
Setting Up Printing (CUPS)
If you need printing support:
Install CUPS
:
sudo pacman -S cups
Enable the CUPS service
:
sudo systemctl enable cups
Install printer drivers
(if needed):
sudo pacman -S cups-filters
Access the web interface
: After rebooting, you can access the CUPS web interface at
http://localhost:631
to configure your printer.
Setting Up Bluetooth
Install Bluetooth packages
:
sudo pacman -S bluez bluez-utils
Enable the Bluetooth service
:
sudo systemctl enable bluetooth
For KDE Plasma
, install the Bluetooth applet:
2. **Enable the Bluetooth service**:
bash
sudo systemctl enable bluetooth
“`
For KDE Plasma
, install the Bluetooth applet:
sudo pacman -S bluedevil
Configuring System Monitoring and Maintenance
To keep your system robust, set up monitoring and regular maintenance.
Install Monitoring Tools
sudo pacman -S sysstat iotop
Set Up Automatic Updates (Optional)
Arch Linux updates frequently, and some users prefer to automate updates. However,
be cautious
as updates can sometimes break things. It’s better to update manually after checking the Arch News.
If you still want to automate, you can use a systemd timer:
Create a script
:
sudo nano /usr/local/bin/arch-update.sh
Content:
#!/bin/bash
sudo pacman -Syu –noconfirm
yay -Syu –noconfirm
Make it executable
:
sudo chmod +x /usr/local/bin/arch-update.sh
Create a systemd service
:
sudo nano /etc/systemd/system/arch-update.service
Content:
“`ini
[Unit]
Description=Arch Linux Update Service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/arch-update.sh
4. **Create a systemd timer**:
“`bash
sudo nano /etc/systemd/system/arch-update.timer
Content:
[Unit]
Description=Run arch-update daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
Installation guide for beginners to install and configure a robust system avoiding common pitfalls and errors
WantedBy=timers.target
Enable the timer
:
sudo systemctl enable arch-update.timer
Setting Up Snapshots and Rollback (Timeshift)
Timeshift is a great tool for creating system snapshots that you can use to rollback if something goes wrong.
Install Timeshift
:
yay -S timeshift
Configure Timeshift
:
Run
sudo timeshift
from the terminal.
Choose RSYNC as the snapshot type.
Select your snapshot location (external drive is recommended).
Configure schedule (daily, weekly, etc.).
Restore a snapshot
:
Boot from the Arch ISO, mount your root partition, and run
timeshift –restore
from the chroot environment.
Common Pitfalls and How to Avoid Them
1. System Won’t Boot After Update
Cause
: Kernel update without updating NVIDIA drivers, or a misconfigured bootloader.
Solution
: Boot from the Arch ISO, chroot into your system, and check logs (
journalctl -xb
). Update packages (
pacman -Syu
) and reinstall drivers if needed. Always check the
Arch News
before updating.
2. Pacman Database Locked
Cause
: Another pacman process is running or it was interrupted.
Solution
: Remove the lock file:
sudo rm /var/lib/pacman/db.lck
3. No Internet After Installation
Cause
: NetworkManager not enabled, or missing firmware.
Solution
: Enable NetworkManager:
sudo systemctl enable –now NetworkManager
For wired connections, you might need
systemd-networkd
or
iwd
. For WiFi, install
iwd
or
wpa_supplicant
.
4. AUR Package Fails to Build
Cause
: Missing dependencies or outdated PKGBUILD.
**AUR helper like yay or paru. We’ll install
yay
.
Install base-devel and git
(needed for building AUR packages):
sudo pacman -S base-devel git
Clone and build yay
:
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Use yay to install packages
:
yay -S package-name
Setting Up Printing (CUPS)
If you need printing support:
Install CUPS
:
sudo pacman -S cups
Enable the CUPS service
:
sudo systemctl enable cups
Install printer drivers
(if needed):
sudo pacman -S cups-filters
Access the web interface
: After rebooting, you can access the CUPS web interface at
http://localhost:631
to configure your beginner to install and configure a robust system avoiding common pitfalls and errors
Setting Up Bluetooth
Install Bluetooth packages
:
sudo pacman -S bluez bluez-utils
Enable the Bluetooth service
:
sudo systemctl enable bluetooth
For KDE Plasma
, install the Bluetooth applet:
sudo pacman -S bluedevil
Configuring System Monitoring and Maintenance
To keep your system robust, set up monitoring and regular maintenance.
Install Monitoring Tools
sudo pacman -S sysstat iotop
Set Up Automatic Updates (Optional)
Arch Linux updates frequently, and some users prefer to automate updates. However,
be cautious
as updates can sometimes break things. It’s better to update manually after checking the Arch News.
If you still want to automate, you can use a systemd timer:
Create a script
:
sudo nano /usr/local/bin/arch-update.sh
Content:
#!/bin/bash
sudo pacman -Syu –noconfirm
yay -Syu –noconfirm
Make it executable
:
sudo chmod +x /usr/local/bin/arch-update.sh
Create a systemd service
:
sudo nano /etc/systemd/system/arch-update.service
Content:
“`ini
[Unit]
Description=Arch Linux Update Service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/arch-update.sh
4. **Create a systemd timer**:
“`bash
sudo nano /etc/systemd/system/arch-update.timer
Content:
[Unit]
Description=Run arch-update daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Enable the timer
:
sudo systemctl enable arch-update.timer
Setting Up Snapshots and Rollback (Timeshift)
Timeshift is a great tool for creating system snapshots that you can use to rollback if something goes wrong.
Install Timeshift
:
yay -S timeshift
Configure Timeshift
:
Run
sudo timeshift
from the terminal.
Choose RSYNC as the snapshot type.
Select your snapshot location (external drive is recommended).
Configure schedule (daily, weekly, etc.).
Restore a snapshot
:
Boot from the Arch ISO, mount your root partition, and run
timeshift –restore
from the chroot environment.
Common Pitfalls and How to Avoid Them
1. System Won’t Boot After Update
Cause
: Kernel update without updating NVIDIA drivers, or a misconfigured bootloader.
Solution
: Boot from the Arch ISO, chroot into your system, and check logs (
journalctl -xb
). Update packages (
pacman -Syu
) and reinstall drivers if needed. Always check the
Arch News
before updating.
2. Pacman Database Locked
Cause
: Another pacman process is running or it was interrupted.
Solution
: Remove the lock file:
sudo rm /var/lib/pacman/db.lck
3. No Internet After Installation
Cause
: NetworkManager not enabled, or missing firmware.
Solution
: Enable NetworkManager:
sudo systemctl enable –now NetworkManager
For wired connections, you might need
systemd-networkd
or
iwd
. For WiFi, install
iwd
or
wpa_supplicant
.
4. AUR Package Fails to Build
Cause
: Missing dependencies or outdated PKGBUILD.
Solution
: Check the AUR page for comments and dependencies. Install missing dependencies manually. Try building manually with
makepkg -si
to see specific errors.
5. Broken System After Update
Cause
: Partial upgrade or ignoring the Arch News.
Solution
: Never do a partial upgrade (
pacman -Sy package
without
-u
). Always update with
pacman -Syu
. If a broken system occurs, boot from ISO, chroot, and update again. Check the Arch News for specific issues.
Conclusion
Installing and configuring Arch Linux can be a rewarding experience that teaches you a lot about Linux. By following this step-by-step guide, you can avoid common pitfalls and build a robust system tailored to your needs. Remember to always refer to the Arch Wiki for detailed information and troubleshooting. Happy hacking!
Note
: This guide assumes a standard installation. For specific hardware (e0.g., NVIDIA Optimus, RAID, LVM, encrypted setups), you may need to consult the Arch Wiki for additional steps. Always back up your data before making significant changes to your system.
# Arch Linux based distributions step by step guide for beginners to install and configure a robust system avoiding common pitfalls and errors
Introduction to Arch Linux and Its Philosophy
Arch Linux is a lightweight, flexible, and simplicistic Linux distribution that follows the KISS (Keep It Simple, Stupid) principle. Unlike Ubuntu or Fedora, Arch does not come with a pre-configured desktop environment; instead, it provides a base system that users can customize to their exact needs. This approach makes Arch an excellent choice for users who want to learn the inner workings of Linux and build a system tailored specifically for them.
For beginners, the installation process can seem daunting because it is primarily command-line based. However, following a structured, step-by-step guide can help you avoid common pitfalls and errors. This guide will walk you through the entire process, from booting the installation media to configuring a robust system with a desktop environment, and finally, optimizing it for daily use.
Why Choose Arch Linux?
Rolling Release Model
: Arch Linux uses a rolling release model, meaning you install once and update continuously. You always have the latest software without needing to reinstall the system.
Customizability
: You start with a minimal base system and build up, giving you complete control over what is installed and configured.
The Arch User Repository (AUR)
: The AUR is a community-driven repository that contains thousands of packages not available in the official repositories, making it easy to install almost any software.
Excellent Documentation
: The Arch Wiki is one of the best sources of Linux documentation available, covering almost every aspect of the Arch system.
Common Pitfalls for Beginners
Before diving into the installation, it’s important to be aware of common mistakes:
Not Reading the Arch Wiki
: The Arch Wiki is your best friend. Always refer to it for hardware-specific issues or advanced configurations.
Skipping the Basics
: Rushing through the base installation without understanding what you’re doing can lead to a broken system later.
Hardware-Specific Issues
: Some hardware (especially NVIDIA GPUs and certain Wi-Fi cards) may require additional drivers or firmware that are not included by default.
Not Backing Up Data
: Always back up important data before starting the installation process.
Using Unofficial Guides
: Stick to the official installation guide or well-regarded community guides like this one to avoid outdated information.
Pre-Installation: Preparing Your System
Before you start the installation, you need to prepare your computer and the installation media. This section covers hardware requirements, downloading the ISO, creating a bootable USB drive, and BIOS/UEFI settings.
Hardware Requirements
Arch Linux is known for its low resource usage, but you still need a system that meets these minimum requirements:
Processor
: Any 64-bit x86_64 processor (i386 is no longer supported).
RAM
: Minimum 512MB, but 2GB or more is recommended for a desktop environment.
Storage
: At least 20GB of free space; 40GB or more is recommended for a full desktop setup.
Internet Connection
: Required for downloading packages during installation.
Downloading the Arch Linux ISO
Visit the official Arch Linux website:
https://archlinux.org/download/
Choose a mirror close to your location for faster downloads.
Download the ISO file (usually named archlinux-xxxx.xx.xx-x86_64.iso).
Verify the checksum to ensure the file was downloaded correctly. You can do this with the command:
sha256sum archlinux-xxxx.xx.xx-x86_64.iso
Compare the output with the checksum provided on the download page.
Creating a Bootable USB Drive
You can use various tools to create a bootable USB drive. Here are two common methods:
Method 1: Using
dd
(Linux/macOS)
Insert your USB drive (make sure it’s at least 2GB).
Identify the device name using
lsblk
or
fdisk -l
. For example, it might be
/dev/sdb
(注意:不是 /dev/sdb1).
Unmount the USB drive if it’s mounted:
umount /dev/sdb*
Write the ISO to the USB drive:
sudo dd if=archlinux-xxxx.xx.xx-x86_64.iso of=/dev/sdb bs=4M status=progress && sync
Warning
: This command will erase all data on the USB drive. Double-check the device name before executing.
Method 2: Using Rufus (Windows)
Download Rufus from
https://rufus.ie/
.
Run Rufus and select your USB drive.
Select the Arch Linux ISO file.
For UEFI systems, select “GPT” for the partition scheme and “UEFI (non-CSM)” for the target system.
Click “Start” and wait for the process to complete.
BIOS/UEFI Settings
Secure Boot
: Arch Linux does not support Secure Boot by default. You need to disable Secure Boot in your BIOS/UEFI settings. Some distributions like EndeavourOS or Manjaro may have workarounds, but for pure Arch, it’s best to disable it.
Boot Order
: Set the USB drive as the first boot device.
Boot Mode
: Ensure you know whether your system is booting in UEFI or Legacy BIOS mode. The installation steps differ slightly between the two. Most modern systems use UEFI.
Step-by-Step Installation Guide
Once you have prepared your installation media and adjusted your BIOS settings, you can boot into the Arch Linux live environment and start the installation process.
Booting into the Live Environment
Insert the bootable USB drive and restart your computer.
You should see the Arch Linux boot menu. Select “Arch Linux archiso x86_64 USB” and press Enter.
After a few seconds, you will be logged in as root in a TTY (Teletype) terminal. There is no graphical interface at this point.
The live environment automatically loads keymaps and font. If you have a HiDPI display, you may need to adjust the font size:
setfont ter-v32n
Verify your internet connection:
ping -c 3 archlinux.org
If you have no internet, see the troubleshooting section below.
Partitioning Your Disk
This is one of the most critical steps. We will cover partitioning for both UEFI and Legacy BIOS (MBR) partitioning schemes.
UEFI Systems (Most Modern Computers)
For UEFI systems, you need at least two partitions: an EFI System Partition (ESP) and a root partition.
Identify your disk
: Use
lsblk
to list all block devices. Your disk will be something like
/dev/sda
or
/dev/nvme0n1
.
Partition the disk
: We’ll use
fdisk
for partitioning. Replace
/dev/sdX
with your disk name.
fdisk /dev/sdX
Inside
fdisk
, use these commands:
g
to create a new empty GPT partition table.
n
to create a new partition:
Partition number: press Enter for default
First sector: press Enter for default
Last sector: +512M (for 512MB)
n
to create the root partition:
Partition number: press Enter for default
First sector: press Enter for default
Last sector: press Enter for default (to use the rest of the disk)
t
to change a partition type:
Select partition 1 and set type to
1
(EFI System)
Select partition 2 and set type to
20
(Linux filesystem)
w
to write the changes and exit.
Format the partitions
:
Format the EFI partition as FAT32:
mkfs.fat -F32 /dev/sdX1
Format the root partition as ext4 (or btrfs if you prefer):
mkfs.ext4 /dev/sdX2
Legacy BIOS (MBR) Systems
For older systems using Legacy BIOS, you need at least two partitions: a boot partition and a root partition.
Identify your disk
: Use
lsblk
to list all block devices.
Partition the disk
: Use
fdisk
to partition the disk.
fdisk /dev/sdX
Inside
fdisk
, use these commands:
o
to create a new empty MBR partition table.
n
to create a new partition:
Partition type: Primary
Partition number: 1
First sector: press Enter for default
Last sector: +512M
n
to create the root partition:
Partition type: Primary
Partition number: 2
First sector: press Enter for default
Last sector: press Enter for default
a
to toggle the bootable flag:
Select partition 1 (the boot partition)
w
to write the changes and exit.
Format the partitions
:
Format the boot partition as ext4:
mkfs.ext4 /dev/sdX1
Format the root partition as ext4:
mkfs.ext4 /dev/sdX2
Mounting the Filesystems
After partitioning and formatting, you need to mount the partitions.
For UEFI Systems
# Mount the root partition to /mnt
mount /dev/sdX2 /mnt
# Create the EFI directory and mount the EFI partition
mkdir -p /mnt/boot/efi
mount /dev/sdX1 /mnt/boot/efi
For Legacy BIOS Systems
# Mount the root partition to /mnt
mount /dev/sdX2 /mnt
# Mount the boot partition to /mnt/boot
mount /dev/sdX1 /mnt/boot
Installing the Base System
Now you can use
pacman
to install the essential packages onto the mounted filesystem. This command will install the Linux kernel, firmware, and other necessary tools.
pacstrap /mnt base linux linux-firmware
base
: The minimal set of packages needed for a Arch Linux system.
linux
: The latest stable Linux kernel.
linux-firmware
: Firmware files for many hardware devices.
If you have a specific kernel version需求 (e.g., LTS kernel for stability), you can install
linux-lts
instead of
linux
. For AMD GPU users, you might need to install
amd-ucode
for microcode updates.
Generating the Filesystem Table (fstab)
The fstab file tells the system which partitions to mount at boot time. Generate it automatically with:
genfstab -U /mnt >> /mnt/etc/fstab
Check the generated file to ensure it’s correct:
cat /mnt/etc/fstab
Chroot into the New System
Chroot (change root) allows you to run commands as if you were inside your new Arch Linux system.
arch-chroot /mnt
Configuring the Basic System
Inside the chroot environment, you need to configure several key settings.
Set the Timezone
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock –systohc
Replace
Region/City
with your location, e.g.,
America/New_York
or
Asia/Shanghai
.
Localization (Locale)
Edit
/etc/locale.gen
and uncomment your desired locale (e.g.,
en_US.UTF-8 UTF-8
).
Generate the locale:
locale-gen
Set the system language in
/etc/locale.conf
:
echo “LANG=en_US.UTF-8” > /etc/locale.conf
Set the keyboard layout in
/etc/vconsole.conf
:
echo “KEYMAP=us” > /etc/vconsole.conf
Network Configuration
Set the hostname:
echo “myarch” > /etc/hostname
Add entries to
/etc/hosts
:
cat <
127.0.0.1 localhost
::1 localhost
127.0.1.1 myarch.localdomain myarch
EOF
Set Root Password
passwd
Installing and Configuring the Bootloader
The bootloader is essential for starting your operating system. For UEFI systems, we’ll use systemd-boot; for Legacy BIOS, we’ll use GRUB.
For UEFI Systems: systemd-boot
Install systemd-boot
:
bootctl install
Create a boot entry
:
cat <
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=$(blkid -s PARTUUID -o value /dev/sdX2) rw
EOF
Important
: Replace
/dev/sdX2
with your root partition. You can find the PARTUUID with
blkid -s PARTUUID -o value /dev/sdX2
.
Configure the loader
:
cat <
default arch
timeout 5
console-mode max
EOF
For Legacy BIOS: GRUB
Install GRUB
:
pacman -S grub
Install GRUB to the MBR
:
grub-install –target=i386-pc /dev/sdX
Replace
/dev/sdX
with your disk (not a partition).
Generate the GRUB configuration file
:
grub-mkconfig -o /boot/grub/grub.cfg
Exit, Unmount, and Reboot
Exit the chroot environment:
exit
Unmount all partitions:
umount -R /mnt
Reboot the system:
reboot
Remove the USB drive when prompted.
Post-Installation: Configuring a Robust System
Congratulations! You have a base Arch Linux system installed. Now, let’s configure it to make it robust and user-friendly.
First Boot and Basic System Updates
After rebooting, you’ll be greeted with a login prompt. Log in as root with the password you set earlier.
Create a user account
(never use root for daily tasks):
useradd -m -G wheel username
Replace
username
with your desired username. The
-m
flag creates a home directory, and
-G wheel
adds the user to the wheel group for sudo privileges.
Set password for the new user
:
passwd username
Install sudo
:
pacman -S sudo
Enable sudo for the wheel group
:
visudo
Find the line
# %wheel ALL=(ALL)ALL
and uncomment it by removing the
#
.
Log out and log back in as your new user
.
Update the system
:
sudo pacman -Syu
This will update all packages to the latest versions.
Installing Essential Packages
Install some essential packages for a better command-line experience:
sudo pacman -S nano git wget curl htop
Installing a Desktop Environment (DE) and Display Manager (DM)
This is where you start building your graphical interface. We’ll install KDE Plasma as an example, but you can choose any DE (GNOME, XFCE, etc.).
Installing KDE Plasma
Install the KDE Plasma group
:
sudo pacman -S plasma
This includes the desktop environment and basic applications.
Install a display manager (DM)
:
sudo pacman -S sddm
SDDM is the recommended DM for KDE.
Enable the display manager
:
sudo systemctl enable sddm
Install additional packages for networking and audio
:
sudo pacman -S networkmanager plasma-nm pipewire pipewire-pulse
networkmanager
: For network management.
plasma-nm
: NetworkManager applet for KDE.
pipewire
: Modern audio server (replaces PulseAudio).
pipewire-pulse
: PulseAudio compatibility for PipeWire.
Enable NetworkManager
:
sudo systemctl enable NetworkManager
Reboot
:
sudo reboot
After rebooting, you should see SDDM, and you can log into your KDE Plasma desktop.
Configuring Graphics Drivers
Proper graphics drivers are crucial for performance and stability.
NVIDIA Users
Identify your NVIDIA card
:
lspci | grep -i nvidia
Install the appropriate driver
:
For modern cards (Maxwell and newer):
nvidia
For older cards:
nvidia-470xx-dkms
(from AUR)
For very old cards:
nvidia-390xx-dkms
(from AUR)
Install the driver and related packages
:
sudo pacman -S nvidia nvidia-utils nvidia-settings
Enable NVIDIA persistence daemon
(optional but recommended):
sudo systemctl enable nvidia-persistenced
For KDE Plasma (Wayland)
: If you want to use Wayland instead of X11, you need to install
nvidia-dkms
and configure kernel parameters. See the Arch Wiki for details.
AMD Users
Install the open-source driver
:
sudo pacman -S xf86-video-amdgpu mesa
The open-source driver is generally recommended for AMD cards.
For newer APUs or GPUs
, you might need to install
linux-firmware
(already installed earlier) and
amd-ucode
for microcode updates.
Intel Users
Install the driver
:
sudo pacman -S xf86-video-intel mesa
For modern Intel GPUs
, the open-source driver is recommended.
Setting Up the AUR (Arch User Repository)
The AUR is a key feature of Arch Linux, containing thousands of community-maintained packages. To use it, you need an AUR helper like
yay
or
paru
. We’ll install
yay
.
Install base-devel and git
(needed for building AUR packages):
sudo pacman -S base-devel git
Clone and build yay
:
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Use yay to install packages
:
yay -S package-name
Setting Up Printing (CUPS)
If you need printing support:
Install CUPS
:
sudo pacman -S cups
Enable the CUPS service
:
sudo systemctl enable cups
Install printer drivers
(if needed):
sudo pacman -S cups-filters
Access the web interface
: After rebooting, you can access the CUPS web interface at
http://localhost:631
to configure your printer.
Setting Up Bluetooth
Install Bluetooth packages
:
sudo pacman -S bluez bluez-utils
Enable the Bluetooth service
:
sudo systemctl enable bluetooth
For KDE Plasma
, install the Bluetooth applet:
sudo pacman -S bluedevil
Configuring System Monitoring and Maintenance
To keep your system robust, set up monitoring and regular maintenance.
Install Monitoring Tools
sudo pacman -S sysstat iotop
Set Up Automatic Updates (Optional)
Arch Linux updates frequently, and some users prefer to automate updates. However,
be cautious
as updates can sometimes break things. It’s better to update manually after checking the Arch News.
If you still want to automate, you can use a systemd timer:
Create a script
:
sudo nano /usr/local/bin/arch-update.sh
Content:
#!/bin/bash
sudo pacman -Syu –noconfirm
yay -Syu –noconfirm
Make it executable
:
sudo chmod +x /usr/local/bin/arch-update.sh
Create a systemd service
:
sudo nano /etc/systemd/system/arch-update.service
Content:
“`ini
[Unit]
Description=Arch Linux Update Service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/arch-update.sh
4. **Create a systemd timer**:
“`bash
sudo nano /etc/systemd/system/arch-update.timer
Content:
[Unit]
Description=Run arch-update daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Enable the timer
:
sudo systemctl enable arch-update.timer
Setting Up Snapshots and Rollback (Timeshift)
Timeshift is a great tool for creating system snapshots that you can use to rollback if something goes wrong.
Install Timeshift
:
yay -S timeshift
Configure Timeshift
:
Run
sudo timeshift
from the terminal.
Choose RSYNC as the snapshot type.
Select your snapshot location (external drive is recommended).
Configure schedule (daily, weekly, etc.).
Restore a snapshot
:
Boot from the Arch ISO, mount your root partition, and run
timeshift –restore
from the chroot environment.
Common Pitfalls and How to Avoid Them
1. System Won’t Boot After Update
Cause
: Kernel update without updating NVIDIA drivers, or a misconfigured bootloader.
Solution
: Boot from the Arch ISO, chroot into your system, and check logs (
journalctl -xb
). Update packages (
pacman -Syu
) and reinstall drivers if needed. Always check the
Arch News
before updating.
2. Pacman Database Locked
Cause
: Another pacman process is running or it was interrupted.
Solution
: Remove the lock file:
sudo rm /var/lib/pacman/db.lck
3. No Internet After Installation
Cause
: NetworkManager not enabled, or missing firmware.
Solution
: Enable NetworkManager:
sudo systemctl enable –now NetworkManager
For wired connections, you might need
systemd-networkd
or
iwd
. For WiFi, install
iwd
or
wpa_supplicant
.
4. AUR Package Fails to Build
Cause
: Missing dependencies or outdated PKGBUILD.
Solution
: Check the AUR page for comments and dependencies. Install missing dependencies manually. Try building manually with
makepkg -si
to see specific errors.
5. Broken System After Update
Cause
: Partial upgrade or ignoring the Arch News.
Solution
: Never do a partial upgrade (
pacman -Sy package
without
-u
). Always update with
pacman -Syu
. If a broken system occurs, boot from ISO, chroot, and update again. Check the Arch News for specific issues.
Conclusion
Installing and configuring Arch Linux can be a rewarding experience that teaches you a lot about Linux. By following this step-by-step guide, you can avoid common pitfalls and build a robust system tailored to your needs. Remember to always refer to the Arch Wiki for detailed information and troubleshooting. Happy hacking!
Note
: This guide assumes a standard installation. For specific hardware (e.g., NVIDIA Optimus, RAID, LVM, encrypted setups), you may need to consult the Arch Wiki for additional steps. Always back up your data before making significant changes to your system.