Installing Arch Linux: The Ultimate Beginner’s Tutorial
Arch Linux, renowned for its flexibility, customizability, and bleeding-edge software, often seems daunting to beginners. This guide breaks down the installation process into manageable steps, making it accessible even if you’ve never installed a Linux distribution before. We’ll focus on a UEFI system, as that’s the most common setup today.
Warning: This process will erase your existing data. Back up anything important before you begin! You should also have a second device (phone, tablet, another computer) handy to refer to this guide and troubleshoot any issues.
Prerequisites:
- USB Flash Drive (at least 4GB): You’ll use this to boot the installation environment.
- Internet Connection (Wired preferred): A wired connection simplifies the process considerably. We’ll cover Wi-Fi, but it requires extra steps.
- BIOS/UEFI Boot Order Adjusted: Ensure your computer boots from the USB drive. This is usually done by pressing a key (F2, F12, Del, Esc – check your motherboard’s manual) during startup.
- Basic Command Line Familiarity: While we explain each command, having some experience with a terminal is helpful.
- Patience and Time: Arch installation is not a 5-minute process. Allocate at least an hour or two.
1. Download and Prepare the Installation Medium
- Download the Arch Linux ISO: Go to the official Arch Linux download page (https://archlinux.org/download/) and download the latest ISO image.
-
Create a Bootable USB Drive: Use a tool like Rufus (Windows), Etcher (Windows, macOS, Linux), or the
dd
command (Linux) to create a bootable USB drive from the ISO.- Rufus (Windows): Select the ISO, your USB drive, and ensure “Partition scheme” is set to “GPT” and “Target system” to “UEFI (non CSM)”.
- Etcher: Select the ISO and your USB drive. Etcher handles the rest automatically.
dd
(Linux): Be extremely careful with this command! Incorrect usage can erase your hard drive. Identify your USB drive usinglsblk
. Then, run:sudo dd bs=4M if=/path/to/archlinux.iso of=/dev/sdX status=progress && sync
(Replace/path/to/archlinux.iso
with the actual path to the ISO and/dev/sdX
with the correct device identifier for your USB drive – make sure this is correct!).
2. Boot from the USB Drive
- Insert the USB drive into your computer.
- Restart your computer.
- Enter your BIOS/UEFI settings (usually by pressing Del, F2, F10, F12, or Esc during startup – check your motherboard manual).
- Change the boot order to prioritize the USB drive.
- Save changes and exit. Your computer should now boot into the Arch Linux installation environment. You’ll see a prompt like
root@archiso ~ #
.
3. Connect to the Internet
-
Wired Connection: If you have a wired connection, it should work automatically. Test it with:
bash
ping -c 3 archlinux.org
If you see replies, you’re connected. -
Wireless Connection: This requires using
iwctl
.- Start
iwctl
:
bash
iwctl - List available devices:
bash
device list
(Note the name of your wireless device, usually something likewlan0
.) - Scan for networks:
bash
station wlan0 scan
(Replacewlan0
with your device name.) - List available networks:
bash
station wlan0 get-networks - Connect to your network:
bash
station wlan0 connect SSID
(ReplaceSSID
with your network’s name. You’ll be prompted for the password.) - Exit
iwctl
:
bash
exit - Test the connection as above.
- Start
4. Update the System Clock
Ensure the system clock is accurate:
bash
timedatectl set-ntp true
5. Partition the Disk
This is the most crucial and potentially dangerous step. We’ll use fdisk
for a basic UEFI setup with:
- EFI System Partition (ESP): For boot files (512MB).
-
Root Partition: For the operating system (the remaining space).
- Swap partition(Optional): It is used as virtual memory.
-
Identify your disk:
bash
lsblk
Identify the disk you want to install Arch on (e.g.,/dev/sda
,/dev/nvme0n1
). Be absolutely certain you’ve selected the correct disk! -
Start
fdisk
:
bash
fdisk /dev/sdX
(Replace/dev/sdX
with your disk’s identifier.) -
Create a GPT partition table (if one doesn’t exist):
- Type
g
and press Enter.
- Type
-
Create the EFI System Partition (ESP):
- Type
n
(for new partition) and press Enter. - Press Enter for the default partition number.
- Press Enter for the default first sector.
- Type
+512M
for the last sector (this creates a 512MB partition) and press Enter. - Type
t
(to change the partition type) and press Enter. - Type
1
(for EFI System) and press Enter.
- Type
-
Create the Root Partition:
- Type
n
and press Enter. - Press Enter for the default partition number.
- Press Enter for the default first sector.
-
Press Enter for the default last sector (this uses the remaining space).
-
Create the Swap partition (Optional):
- Type
n
and press Enter. - Press Enter for the default partition number.
- Press Enter for the default first sector.
- Type
+4G
(4GB of Swap, or your desired size) for the last sector. - Type
t
(to change the partition type) and press Enter. - Type
82
(for Linux Swap) and press Enter.
- Type
- Type
-
Write the changes and exit:
- Type
w
(to write the changes to the disk) and press Enter. This is irreversible.
- Type
-
You can confirm by typing
p
before writing.
6. Format the Partitions
Now, format the partitions you just created:
bash
mkfs.fat -F32 /dev/sdX1 # Format the ESP (replace /dev/sdX1 with your ESP)
mkfs.ext4 /dev/sdX2 # Format the root partition (replace /dev/sdX2)
mkswap /dev/sdX3 # Format the swap partition (replace/dev/sdX3)
swapon /dev/sdX3 # Enable the Swap partition
7. Mount the Partitions
Mount the partitions to prepare for installation:
bash
mount /dev/sdX2 /mnt # Mount the root partition
mkdir /mnt/boot # Create a directory for the boot partition
mount /dev/sdX1 /mnt/boot # Mount the ESP
8. Install the Base System
Use pacstrap
to install the base system, the Linux kernel, and firmware:
bash
pacstrap /mnt base linux linux-firmware
9. Generate fstab
Generate the fstab
file, which defines how your partitions are mounted at boot:
bash
genfstab -U /mnt >> /mnt/etc/fstab
Always check the generated /mnt/etc/fstab
file with cat /mnt/etc/fstab
to ensure it’s correct before proceeding. Look for errors and ensure the UUIDs and mount points are accurate.
10. Chroot into the New System
chroot
allows you to enter the newly installed system as if you’ve booted into it:
bash
arch-chroot /mnt
Your prompt should change, indicating you’re now inside the new system.
11. Set the Time Zone
bash
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime # Replace Region/City
hwclock --systohc
Replace Region/City
with your time zone (e.g., America/Los_Angeles
). You can find a list of time zones in /usr/share/zoneinfo/
.
12. Set the Locale
- Edit
/etc/locale.gen
:
bash
nano /etc/locale.gen - Uncomment (remove the
#
from) the line corresponding to your desired locale (e.g.,en_US.UTF-8 UTF-8
). Save and close the file (Ctrl+O, Enter, Ctrl+X). - Generate the locale:
bash
locale-gen - Set the
LANG
variable in/etc/locale.conf
:
bash
echo "LANG=en_US.UTF-8" > /etc/locale.conf
(Replaceen_US.UTF-8
with your chosen locale.)
13. Set the Hostname
bash
echo "myhostname" > /etc/hostname
Replace myhostname
with your desired hostname.
Then, add the same hostname to /etc/hosts
:
nano /etc/hosts
Add the following lines (replace myhostname
with your hostname):
127.0.0.1 localhost
::1 localhost
127.0.1.1 myhostname.localdomain myhostname
Save and close the file.
14. Set the Root Password
bash
passwd
Enter and confirm your root password.
15. Install a Boot Loader (GRUB)
We’ll use GRUB for this guide (UEFI systems):
bash
pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg
16. Install Essential Packages (Optional but Recommended)
It’s highly recommended to install a network manager, and potentially other useful tools, before rebooting:
“`bash
pacman -S networkmanager
systemctl enable NetworkManager # Enable it to start on boot
# Other useful packages:
pacman -S vim git wget sudo # A text editor, version control, download utility, and sudo
```
17. Create a User Account (Highly Recommended!)
It’s a security best practice to create a non-root user account.
```bash
useradd -m -G wheel -s /bin/bash myusername
passwd myusername
```
Replace "myusername" with your desired username. This command creates a user, adds them to the "wheel" group (which allows using `sudo`), and sets the default shell to Bash. Set the password for the new user.
Next, you need to give the `wheel` group sudo access.
```bash
EDITOR=nano visudo
```
Uncomment the line that says `%wheel ALL=(ALL) ALL`. Save and exit.
18. Unmount and Reboot
- Exit the chroot environment:
bash
exit - Unmount the partitions:
bash
umount -R /mnt - Reboot:
bash
reboot
Remove the USB drive when prompted (or after the system shuts down).
19. Post-Installation (After Reboot)
If everything went well, you should be greeted by a GRUB menu. Select Arch Linux, and you’ll boot into your newly installed system. Log in with the user account you created (or as root, but it’s not recommended for daily use).
- Connect to the Internet: If you installed and enabled
NetworkManager
, it should connect automatically. If not, refer back to the “Connect to the Internet” section (usingip link
to identify interfaces). - Update the System:
bash
sudo pacman -Syu - Install a Desktop Environment (DE) or Window Manager (WM): This is where Arch Linux’s customizability shines. You can choose from a variety of DEs (like GNOME, KDE Plasma, Xfce) or WMs (like i3, Sway, Openbox). The Arch Wiki has extensive guides on installing each. Here’s an example for Xfce:
bash
sudo pacman -S xfce4 xfce4-goodies
Then, you’ll need a display manager (like LightDM) to provide a graphical login:
bash
sudo pacman -S lightdm lightdm-gtk-greeter
sudo systemctl enable lightdm
Reboot to see the graphical login.
Troubleshooting
- Boot Problems: Ensure your BIOS/UEFI settings are correct (boot order). Double-check the
grub-install
andgrub-mkconfig
commands. - Network Issues: Verify your network card is recognized (
ip link
). Useiwctl
for Wi-Fi (refer to the “Connect to the Internet” section). Make sureNetworkManager
is enabled (systemctl status NetworkManager
). - Partitioning Errors: Carefully review the “Partition the Disk” section. Use
lsblk
to check your partitions. - Package Installation Errors: Ensure you’re connected to the internet. Use
pacman -Syu
to update the package database. - General Errors: The Arch Wiki (https://wiki.archlinux.org/) is your best friend. Search for error messages or specific issues. The Arch forums are also a valuable resource.
Conclusion
Installing Arch Linux is a learning experience. This guide provides a solid foundation, but there are many more customization options and configurations you can explore. Don’t be afraid to experiment, consult the Arch Wiki, and enjoy the process of building your perfect Linux system! Remember to take your time, read carefully, and back up your data before you start. Good luck!