DEV Community

Cover image for Hitchhiker's Guide to the Arch Linux Installation
Jimmy McBride
Jimmy McBride Subscriber

Posted on • Originally published at jimmymcbride.dev

Hitchhiker's Guide to the Arch Linux Installation

If you're here, you're probably about to embark on your first-ever Arch Linux installation, and let me tell you, that can seem pretty intimidating at first glance. But don’t worry—you’re not alone! We’re going to take this one step at a time, and I’ll guide you through every part of the process as you venture into the wonderful world of Arch Linux.

Pro tip: If this is your first time installing Arch, I recommend giving it a try on a virtual machine first. That way, you can get a feel for the steps without worrying about messing up your main system. Once you're comfortable, you can tackle the real deal with confidence!


1. Prepare the Installation Medium

  • Download the latest Arch Linux ISO from the official site.
  • Create a bootable USB using a tool like dd, Rufus, or Etcher.

2. Boot the System from the USB

  • Insert the USB, reboot your computer, and select the USB device from your BIOS/UEFI boot menu.
  • When the boot loader appears, select Arch Linux install medium and press Enter.

3. Set the Console Keyboard Layout

Since we're in the USA, set the keyboard layout to American English:

loadkeys us
Enter fullscreen mode Exit fullscreen mode

4. Verify the Boot Mode (UEFI vs BIOS)

  • Run this command to confirm you're in UEFI mode (64-bit):
  ls /sys/firmware/efi
Enter fullscreen mode Exit fullscreen mode
  • If the directory exists, you're in UEFI mode. Otherwise, you’re in BIOS mode.

5. Connect to the Internet

  • To verify network devices:
  ip link
Enter fullscreen mode Exit fullscreen mode
  • For Ethernet: You should be automatically connected if the cable is plugged in.
  • For Wi-Fi:
  iwctl
Enter fullscreen mode Exit fullscreen mode
  • Use device list, station DEVICE scan, station DEVICE get-networks, and station DEVICE connect SSID to connect.

    • Verify the connection:
  ping archlinux.org
Enter fullscreen mode Exit fullscreen mode

6. Update the System Clock

  • Run this command to synchronize your system clock:
  timedatectl set-ntp true
Enter fullscreen mode Exit fullscreen mode

7. Partition the Disk

Partitioning can be confusing, especially if it’s your first time. Here’s a quick breakdown: a partition is just a section of your hard drive dedicated to specific tasks—like storing files or acting as the bootloader. In Linux, we often divide the disk into several partitions, and for Arch Linux, the main ones we’ll need are for the root system and the EFI boot.

Important: Be absolutely sure you're working on the correct drive. Double and triple-check, or you risk losing all of your data. Trust me, I’ve accidentally wiped my data more times than I care to admit by not being careful enough with this step!

When you enter fdisk, things might seem a bit cryptic, so let’s make it easy. To create a new partition, use the following steps:

  • Identify your disk:
  fdisk -l
Enter fullscreen mode Exit fullscreen mode
  • Partition your disk using fdisk (assuming /dev/sda):
  fdisk /dev/sda
Enter fullscreen mode Exit fullscreen mode
  • Create the following partitions:

    1. EFI System Partition (FAT32, ~512MB) for UEFI systems.
    2. Root Partition (ext4, at least 30GB).
  • Type n to create a new partition.

  • Select the partition number (usually 1 for the first partition).

  • For the partition type, choose 23 (Linux root x86-64).

  • After selecting the partition size (I recommend at least 30GB for the root partition), you’ll move on to the next one.

8. Format the Partitions

  • Format the root partition as ext4:
  mkfs.ext4 /dev/sdaX
Enter fullscreen mode Exit fullscreen mode
  • Format the EFI partition (for UEFI systems):
  mkfs.fat -F32 /dev/sdaY
Enter fullscreen mode Exit fullscreen mode

9. Create a Swap File (Instead of Swap Partition)

While some users still opt for a swap partition, a swap file is more flexible and easier to resize later. Swap is useful when your system runs out of RAM or when you want to hibernate your computer.

  • How to size the swap file:
    • If you don’t hibernate: A swap file about half the size of your RAM is usually enough.
    • If you hibernate: The swap file should be equal to or slightly larger than your RAM.

Why hibernation matters: Laptops benefit from hibernation since you can save your session and resume later without losing your work. On desktops, it’s less critical, especially if you shut down your system regularly (like I do—it keeps my setup clutter-free!).

To create a 4GB swap file (adjust as needed for your setup):

  fallocate -l 4G /swapfile
  chmod 600 /swapfile
  mkswap /swapfile
  swapon /swapfile
Enter fullscreen mode Exit fullscreen mode
  • Add the swap file to fstab for persistence:
  echo '/swapfile none swap defaults 0 0' | tee -a /etc/fstab
Enter fullscreen mode Exit fullscreen mode

10. Mount the File Systems

  • Mount the root partition:
  mount /dev/sdaX /mnt
Enter fullscreen mode Exit fullscreen mode
  • Mount the EFI partition (for UEFI):
  mkdir /mnt/boot
  mount /dev/sdaY /mnt/boot
Enter fullscreen mode Exit fullscreen mode

11. Install the Base System

  • Install the base packages:
  pacstrap /mnt base linux linux-firmware
Enter fullscreen mode Exit fullscreen mode

12. Generate the fstab File

  • Generate the file system table:
  genfstab -U /mnt >> /mnt/etc/fstab
Enter fullscreen mode Exit fullscreen mode

13. Chroot into the New System

  • Change root into the new system:
  arch-chroot /mnt
Enter fullscreen mode Exit fullscreen mode

14. Set the Time Zone

  • Set your time zone to CST (Central Standard Time):
  ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
  hwclock --systohc
Enter fullscreen mode Exit fullscreen mode

15. Localization

  • Edit /etc/locale.gen to uncomment en_US.UTF-8 UTF-8.
  • Generate the locales:
  locale-gen
Enter fullscreen mode Exit fullscreen mode
  • Set the locale:
  echo "LANG=en_US.UTF-8" > /etc/locale.conf
Enter fullscreen mode Exit fullscreen mode

16. Configure the Network

  • Set the hostname (we'll keep it lighthearted with archbtw):
  echo "archbtw" > /etc/hostname
Enter fullscreen mode Exit fullscreen mode
  • Edit /etc/hosts:
  127.0.0.1 localhost
  ::1       localhost
  127.0.1.1 archbtw.localdomain archbtw
Enter fullscreen mode Exit fullscreen mode

17. Install NetworkManager, base-devel, and git

Pro tip: I always forget to install NetworkManager, and it causes major headaches when I can’t connect to the internet. Save yourself the trouble!

pacman -S networkmanager base-devel git
systemctl enable NetworkManager
Enter fullscreen mode Exit fullscreen mode

18. Create a New User Before Rebooting

Before rebooting, let’s create a user account:

useradd -m -G wheel -s /bin/bash yourusername
passwd yourusername
Enter fullscreen mode Exit fullscreen mode
  • Enable the user to use sudo by editing the sudoers file:
EDITOR=vi visudo
Enter fullscreen mode Exit fullscreen mode

Uncomment this line:

%wheel ALL=(ALL) ALL
Enter fullscreen mode Exit fullscreen mode

19. Install and Configure the Bootloader

For UEFI systems, install and configure GRUB:

  • Install GRUB and EFI boot manager:
  pacman -S grub efibootmgr
Enter fullscreen mode Exit fullscreen mode
  • Install GRUB to the EFI directory:
  grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
Enter fullscreen mode Exit fullscreen mode
  • Generate the GRUB configuration file:
  grub-mkconfig -o /boot/grub/grub.cfg
Enter fullscreen mode Exit fullscreen mode

20. Set Root Password

  • Set the root password:
  passwd
Enter fullscreen mode Exit fullscreen mode

21. Reboot into the New System

  • Exit the chroot environment:
  exit
Enter fullscreen mode Exit fullscreen mode
  • Unmount partitions:
  umount -R /mnt
Enter fullscreen mode Exit fullscreen mode
  • Reboot:
  reboot
Enter fullscreen mode Exit fullscreen mode

Join the Community!

If you made it this far, congrats! Installing Arch Linux isn’t easy, but you did it. 🎉 If you’re into Linux, programming, or just want to chat with like-minded people, join me and other positive people in our Discord community! We’re always happy to talk shop, share tips, and help each other grow. Click here to join!

Top comments (18)

Collapse
 
webreflection profile image
Andrea Giammarchi

I wonder if I should move into a file as swap ... I am using an encrypted setup (not documented in here, it'd be useful, I could do that too) with an encrypted swap too ... my only concern with the swap as partition a part is that:

  • if encrypted, requires double unlock at bootstrap (done that too via a hook)
  • if I need more swap, I can't resize the file and call it a day

The latter has never been needed so far but I can see it as a strong point to:

  • have to un-luck only the root partition when encrypted
  • have the ability to grow or shrink the swap without causing issues to the root partition too

does this make sense?

Another thing non covered here, grub is cool and everything but efibootmgr also works greatly.

I run on archibold.io/ btw 👋

Collapse
 
jimmymcbride profile image
Jimmy McBride

I've never built an encrypted system. I don't have anything on my PC that's sensitive enough to be worth the effort.... yet! :p

I highly recommend swap file over swap partitions. The flexibility is awesome! I used to create a partition for root and home and swap, and then I'd get stuck in a trap of my own making. Now, the less partitions, the better. Especially for desktop.

Collapse
 
webreflection profile image
Andrea Giammarchi • Edited

I don't have anything on my PC that's sensitive enough to be worth the effort.... yet!

I have work related, GitHub related, password related stuff (any .env file to name one) that are better kept as far away as I can from people potentially stealing my Laptop, as it's my daily driver for everything.

Performance is not noticeably degraded neither but agreed for a static Desktop Rig used occasionally it might not be worth the unlock effort on boot. If interested, it's super trivial to setup encryption on a single drive if it's one only you probably would just need to include encryption dependencies on boot and call it a day, I did write my own hook that gets built with any new linux automatically on any update that requires it.

I might as well write a post about it but I am not sure how many would read it ... although security matters and it's also a plus for Linux to have it the easy way, it's not straight forward at all for Windows machines, Apple gets closer to Linux though.

Thread Thread
 
jimmymcbride profile image
Jimmy McBride

I'd love to read that post and learn more about encryption! If you do, send it my way please. :)

Collapse
 
aditya_075 profile image
Aditya Mhambrey

I wish more people started enjoying Arch and stopped looking at Arch as a cult. Really good article btw!

Collapse
 
jimmymcbride profile image
Jimmy McBride

I agree! 💯 I joke about being a filthy meta slave Arch enjoyer all the time. I do my very best to not judge what other people choose and not push it on anyone. At the end of the day, you should use the distro YOU think is cool, not the disto I think is cool.

I always want to be seen as a kind and understanding Arch Linux enjoyer who does his best to help everyone. I want people to be like, "Maybe Arch Linux users aren't the RTFM toxic elitest I thought they were"

Collapse
 
aditya_075 profile image
Aditya Mhambrey

I really think you should make more Arch Content. Content about Window Managers like i3 and AwesomeWM is a great way to engage people into Arch Linux. It's not even about which Distro you choose anymore when you think about Linux as a philosophy ( Do one thing well ). It's only when you start saying Arch is better than other Distributions, you find yourself in trouble.

Thread Thread
 
jimmymcbride profile image
Jimmy McBride

Yeah! I love this idea. Basically, my philosophy at this moment is:

I want to make niche content that has a large audience. My favorite things are Linux and full stack development. Every dev knows git and every developer can benifit from learning the command line. So I want to make as much content around bash, getting people comfortable in the terminal, how to use git effectively and sprinkling in some stuff I like a lot like arch installs and web tutorials here and there, so show my own personal flavor.

I'd like to get all the foundational content out for free and create a paid subscription where people can get more advanced content and project guides that build off the foundation content I've taught for free.

So I just want to get people into Linux and into the terminal and app development. Then people who align with my "flavor" will find a lot of value in the more exclusive content I post.

Thread Thread
 
aditya_075 profile image
Aditya Mhambrey

Love it! I wish you luck!

Thread Thread
 
jimmymcbride profile image
Jimmy McBride

Tyvm :)

Collapse
 
andrea_from_italy profile image
andrea_fazzi

The process to install arch is instructive and puts in plain sight very important concepts as chroot...
Thank you

Collapse
 
jimmymcbride profile image
Jimmy McBride

Thanks a bunch! That was exactly my goal :)

Collapse
 
zajca profile image
Martin Zajíc

It has been some time since I last install arch on my machine but I had used archinstall, it's just more pleasant especially for beginners and for lazy people.

Collapse
 
jimmymcbride profile image
Jimmy McBride

The main appeal of arch is the minimal install and pacman + AUR. Between pacman and AUR you get access to a lot of packages that are very up to date. Any downstream Linux distro of arch gets this, making thing like Manjaro very nice.

With vanilla Arch though, you get to literally build you OS the way you want it, so there's pride it that, there's learning in that, it's an amazing experience imo.

Also it's a rolling distro! So you just sudo pacman -Syu and your system is updated to next version, no restart required. VS Debian where you have to reinstall your OS once a year and 2ice a year for Ubuntu. Rolling distributions make updating less intrusive than Mac or Windows, static distributions are more disruptive for updates.

This are the main reasons I love Arch. :)

Collapse
 
jimmymcbride profile image
Jimmy McBride

Love this! Thanks a lot. :)

 
cagatay_sunal profile image
Çağatay Sunal

Fedora is not a rolling distro. It has distinct releases.