This is my guide to installing Arch Linux. In my eyes, this is the minimum-viable setup necessary to boot into a solid base without headaches. Where the Arch Wiki's install guide tends to cover every edge case and give you multiple options, this guide is opinionated and ignores many edge cases. In the case where the guide breaks for you, refer back to the Arch Wiki for help.
You can download the Arch Linux ISO image from their website. If you're doing this from a Linux system, you can use this command to write to the drive, assuming the usb drive is /dev/sdb
, this would be your command:
sudo dd if=~/Downloads/archlinux-*-x86_64.iso of=/dev/sdb
Next, boot from your USB drive. It's different for every computer, but in general, you will press a key at boot, and it will give you a boot device menu, from which you will select your USB drive.
If all goes well, you should see some boot text (don't worry, this is normal), then it should boot to a terminal prompt:
root@archiso ~ #
This guide assumes you are in a situation where you do not have, or can not use, an ethernet port on your device. If this is not the case, I believe you can just attach your ethernet connection and move on.
First, list the available WiFi networks that you can connect to:
iwctl station wlan0 get-networks
Once you see your's, connect to it:
iwctl station wlan0 connect <SSID>
To test if it worked, try pinging a website:
ping -c5 google.com
Following these next commands WILL RESULT IN DATA LOSS. Please make sure to back up any important data before you continue. Also, this guide is intended for a setup with ONLY Arch Linux. if you wish to dual boot, refer to some other guide.
For this guide, we will use parted
to partition the drives. First, make sure you know what drive you are installing on. To list all available drives, use lsblk
. In this guide, I will use /dev/nvme0n1
as the drive to install on.
First, create a new GPT partition table on the drive (this will wipe it!):
parted /dev/nvme0n1 -- mklabel gpt
Create the boot partition. It will use 512MB:
parted /dev/nvme0n1 -- mkpart ESP fat32 1MB 512MB
parted /dev/nvme0n1 -- set 1 esp on
And the root partition. It will fill the whole drive, minus 512MB at the front for the boot partition.
parted /dev/nvme0n1 -- mkpart primary 512MB 100%
With the partitioning done, we will next format the partitions we just created.
First, lets format the boot partition:
mkfs.fat -F32 -n boot /dev/nvme0n1p1
Boot partitions are always formatted as fat32
, and we label the partition as boot
with -n
.
For the root partition, we will use ext4
:
mkfs.ext4 -L root /dev/nvme0n1p2
-L
labels the partition as root
.
Partition Labels? Most people don't label their partitions. But I think it is a good idea, so that you don't have to keep checking which one is the boot partition and which one is the root partition. Since they are labeled, you can refer to them as
/dev/disk/by-label/root
or/dev/disk/by-label/boot
, which I think is much cleaner than/dev/nvme0n1p1
or/dev/nvme0n1p2
.
With our partitions formatted, let's move on to mounting them.
First, lets create a place to mount our partitions. Say, /mnt/arch
mkdir -p /mnt/arch
Let's mount the root partition:
mount /dev/disk/by-label/root /mnt/arch
And the boot partition:
mount --mkdir /dev/disk/by-label/boot /mnt/arch/efi
the --mkdir
option will create the directory at /mnt/arch/efi
, since it doesn't exist yet.
Normally people create an entire partition for swap space, but I think that this is unnecessary. Instead, we will create a swap file:
mkswap -U clear --size 4G --file /mnt/arch/swapfile
And now enable the swap file:
swapon /mnt/arch/swapfile
Later, we will have to add it to the /etc/fstab
file to mount at boot
Yeah, that's right, all of that was just pre-installation. Now we're on to the fun part! The basic procedure is to use pacman
to install the base system into our /etc/arch
directory, now that we have everything set up.
To make the installation go faster, let's tell Arch Linux to use mirrors closer to our current location:
reflector --protocol https \
--latest 10 \
--sort rate \
--save /etc/pacman.d/mirrorlist
Another thing we should do first is update the Arch Linux keyring. If your ISO is not up-to-date, you might get errors in the installation later on, so its safer to just do it now:
pacman -Sy archlinux-keyring
Now, we can install the system (this might take a while):
pacstrap /mnt/arch base linux linux-firmware
Note that you can add whatever other packages you want here. Normally I add my favorite shell, a text editor, and networking utilities as well:
pacstrap /mnt/arch base linux linux-firmware helix fish iwd
Before we enter our brand new Arch Linux system, lets generate an fstab
file to tell the system what partitions to mount at boot:
genfstab -L /mnt/arch > /mnt/arch/etc/fstab
Note, the -L
option only works if you choose to label your partitions. Otherwise, use -U
to use the partitions' UUIDs.
Now that we've installed the base system, let's enter it!
arch-chroot /mnt/arch
There's still a lot we need to do to make our system workable.
First, list available timezones to find yours. For example, for America:
timedatectl list-timezones | grep "America"
Once you've found your timezone, set it by creating a symlink. For example, for Chicago:
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
Next, generate /etc/adjtime
and set your hardware clock:
hwclock --systohc
To verify your timezone is set correctly:
timedatectl status
First, edit the file /etc/locale.gen
, and uncomment the line that says en_US.UTF-8 UTF-8
:
...
#en_SG.UTF-8 UTF-8
#en_SG ISO-8859-1
en_US.UTF-8 UTF-8
#en_US ISO-8859-1
#en_ZA.UTF-8 UTF-8
...
If you installed helix
, you could this sequence of commands:
%sen_US\.UTF-8<RET><SPACE>c
Then generate the locales:
locale-gen
One more thing. Edit the file /etc/locale.conf
, and add this line:
LANG=en_US.UTF-8
echo "$YOUR_HOSTNAME" > /etc/hostname
Also set up your /etc/hosts
file:
127.0.0.1 localhost
::1 localhost
Here's how you create a user account.
Fist, pick a privilege escalation program. sudo
is by far the most popular of these, but opendoas
is also an option, and there is also run0
by systemd.
[!NOTE]- Instructions for
sudo
first, installsudo
:sudo pacman -S sudoThen allow users in the
wheel
group to execute commands as root. First, open the configuration file:EDITOR=hx visudothen uncomment the line that says
:wheel ALL=(ALL) ALL
.
[!NOTE]- Instructions for
doas
Installopendoas
:sudo pacman -S opendoasThen allow users in the
wheel
group to execute commands as root. First open the configuraton file:hx /etc/doas.confThen add the following line:
permit persist :wheel
Run this command to create a new user. For example, collin
:
useradd -mG wheel -s /bin/fish collin
Then set the user's password:
passwd collin
Whew! That was a lot. There is only one more step, then you can reboot into your system. Let's set up a bootloader. We'll use systemd-boot
for this guide, because it's more lightweight than traditional grub
.
First, install it:
bootctl install
If it has an error about not being able to find the EFI System Partition, you can pass --esp-path=/efi
to force it to install in the right location.
UKIs are cool. Since systemd-boot
has first-class support for UKI, let's set it up.
We can use Arch Linux's mkinitcpio
to automatically create our Unified Kernel Images.
If you are on an intel or amd system, you should install the intel-ucode
or amd-ucode
package.
Normally, we would specify kernel parameters in GRUB_CMDLINE
, but we're not using grub anymore. The solution is to put our parameters in /etc/cmdline.d/*
.
Here are some required parameters, placed in /etc/cmdline.d/root.conf
:
root=LABEL=root rw
This obviously only works if you're using labels.
We will edit /etc/mkinitcpio.d/linux.preset
to tell it to generate to bundle the microcode, kernel, and initramfs into a unified kernel image.
The file should look like this after editing:
# mkinitcpio preset file for the 'linux' package
ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux"
ALL_microcode=(/boot/*-ucode.img)
PRESETS=('default')
#default_config="/etc/mkinitcpio.conf"
#default_image="/boot/initramfs-linux.img"
default_uki="/efi/EFI/Linux/arch-linux.efi"
default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp"
#fallback_config="/etc/mkinitcpio.conf"
#fallback_image="/boot/initramfs-linux-fallback.img"
#fallback_uki="/efi/EFI/Linux/arch-linux-fallback.efi"
#fallback_options="-S autodetect"
With our mkinitcpio
preset set up, let's generate our UKI:
mkinitpcio -p linux
pacman
will also regenerate our UKI every time it is necessary to do so.
Since systemd-boot
has first-class support for UKIs, it automatically looks for Unified Kernel Images in /efi/EFI/Linux
, so we don’t have to do anything to install it.