Search

How to Install Arch Linux: A Comprehensive Step-by-Step Guide

Arch Linux is one of the best rolling-release distributions around, but sometimes it can be a challenge to install. In this video, Jay will walk you through not one but TWO methods of installing Arch Linux. The first method will feature arch-install, which is geared more toward beginners. During the second half of the video, Jay will walk you through the manual method – which is perfect for control freaks (you know who you are).

YouTube player

If you’re now running Arch, consider buying an “I run Arch” shirt to help support Learn Linux TV!

Video Notes

Connecting to WiFi

The following commands were used to connect to WiFi from within the Arch installer (basically, the command line method).

Find your WiFi device name

If you’re planning on using WiFI, you can set it up with the iwctl command. But first, we’ll need to know the device name of our WiFi adapter so we can refer to it later:

ip addr show

You should see your wireless device name in the output.

Scan for available WiFi Networks

Next, we’ll see if we can detect any nearby WiFi networks:

iwctl

After running that command, you’ll be inside of a different shell with a unique prompt. This is expected. The next thing we’ll do is scan for networks:

station wlan0 get-networks

If your WiFi adapter is functioning properly, a list of nearby WiFi networks should appear. Make note of the one you want to connect to. We can exit the iwctl shell now:

exit

Finally, we can run the following command to connect to the desired network:

iwctl --passphrase <passphrase> station <interface> connect NetworkName

Manual Installation Notes

In this section, I’ll list some of the commands that were used during the video.

Display current partition info:

lsblk

Beginning the partitioning process:

fdisk nvme0n1

Note: Replace nvme0n1 with the appropriate device name.

fdisk: Print current partition layout:

p

Fdisk: Create Partitions:

The following commands (within the fdisk shell) will help you create our first partition:

  • g (to create an empty GPT partition table)
  • n
  • 1
  • enter
  • +1G

We’ll run through the process again for the second partition:

  • 2
  • enter
  • +1G

And again, for the third partition:

  • n
  • 3
  • enter
  • enter
  • t
  • 3
  • 44
  • w

Format the EFI partition (the first partition we created):

mkfs.fat -F32 /dev/nvme0n1p1

Format the Boot partition:

mkfs.ext4 /dev/nvme0n1p2

Set up encryption

Encrypting our third partition would be a good idea, since that’s where our data will ultimately go. The following command will encrypt partition nvme0n1p3:

cryptsetup luksFormat /dev/nvme0n1p3

After that’s done, let’s unlock that volume so we can set it up:

cryptsetup open --type luks /dev/nvme0n1p3 lvm

Set up lvm

Logical Volume Manager (LVM) gives us additional storage flexibility, including (but not limited to) online resizing and snapshots. I’ve covered LVM in the past, if you want to learn more about it. Anyway, let’s set up LVM.

pvcreate /dev/mapper/lvm

Next, we’ll create a volume group and name it volgroup0:

vgcreate volgroup0 /dev/mapper/lvm

After that, we’ll create a logical volume named lv_root:

lvcreate -L 30GB volgroup0 -n lv_root

We’ll then create a second logical volume, this time named lv_home:

lvcreate -L 250GB volgroup0 -n lv_home

Then, we’ll activate our volume group by running the following commands:

modprobe dm_mod
vgscan
vgchange -ay

Format and mount the partitions

When it comes to formatting and mounting our partitions, we’ll focus on lv_root and lv_home for now. There is another partition we haven’t touched yet, but we don’t need to do anything with that yet. The following commands will format our two logical volumes:

mkfs.ext4 /dev/volgroup0/lv_root
mkfs.ext4 /dev/volgroup0/lv_home

Next, we’ll mount lv_root:

mount /dev/volgroup0/lv_root /mnt

Continuing, we’ll create a directory that will ultimately become our boot directory:

mkdir /mnt/boot

Then we’ll mount our second partition there:

mount /dev/nvme0n1p2 /mnt/boot

Our next goal is to set up and mount our home volume. Let’s create a directory for it:

mkdir /mnt/home

And then mount it:

mount /dev/volgroup0/lv_home /mnt/home

Preparing the Arch installation environment

Now that we have our partitions mounted, let’s install the set of base packages for Arch:

pacstrap -i /mnt base

After that’s done, we can generate an fstab file to ensure our installation knows where to find its partitions:

genfstab -U -p /mnt >> /mnt/etc/fstab

Then, we’ll access our in-progress installation so we can fine-tune it:

arch-chroot /mnt

User accounts

To protect the root account, we can set a password for it:

passwd

It would also be a good idea to create a user for yourself.

useradd -m -g users -G wheel jay

Then, set a password for your account:

passwd jay

Install basic packages

The following command will install the majority of the packages that we’ll need:

pacman -S base-devel dosfstools grub efibootmgr gnome gnome-tweaks lvm2 mtools nano networkmanager openssh os-prober sudo

If you want to use SSH, add: openssh

If you did choose to install openssh, enable it: systemctl enable sshd

Install at least one kernel:

pacman -S linux linux-headers linux-lts linux-lts-headers

Install firmware files:

pacman -S linux-firmware

Inspect GPU:

The following command will list PCI devices on your system, which may help if you’re not sure what kind of GPU you have. The output may offer clues.

lspci

If you have an Intel or AMD GPU, install mesa:

pacman -S mesa

If you have an Nvidia GPU:

pacman -S nvidia nvidia-utils

If you have an Nvidia GPU and you installed the LTS kernel earlier:

pacman -S nvidia-lts

If you need support for accelerated video decoding, consider installing these packages.

Intel (Broadwell and newer): intel-media-driver
Intel GMA 4500 up to Coffee Lake: libva-mesa-driver
AMD: libva-mesa-driver
Nvidia: Already taken care of with nvida-utils, which was installed earlier

Edit /etc/mkinitcpio.conf:

nano /etc/mkinitcpio.conf

Add encrypt lvm2 in between block and filesystems

Generate kernel ramdisks

If you installed the linux package:

mkinitcpio -p linux

If you installed the linux-lts package:

mkinitcpio -p linux-lts

Edit /etc/locale.gen and uncomment en_US.UTF-8:

nano /etc/locale.genlocale-gen

Set up GRUB:

Edit the /etc/default/grub file.

vim /etc/default/grub

Within that file, look for a line containing GRUB_CMDLINE_LINUX_DEFAULT and add cryptdevice=/dev/<device-name>:<volume-group> to the end of it. For example, a typical configuration line of this type might look like this:

cryptdevice=/dev/nvme0n1p3:volgroup0

Next, create the /boot/EFI directory and mount our first partition to it:

mkdir /boot/EFI
mount /dev/nvme0n1p1 /boot/EFI

Now we can install GRUB:

grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck

The next command will copy locale files for GRUB’s messaging to our boot directory:

cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Generate a config file for GRUB:

grub-mkconfig -o /boot/grub/grub.cfg

Enable GDM to start when you reboot:

systemctl enable gdm

Enable NetworkManager so networking will function when you reboot:

systemctl enable NetworkManager

Wrapping Up

Exit our chroot environment:

exit

Unmount all partitions:

umount -a

Reboot the system:

reboot

New Linux Products!


Support LearnLinuxTV and receive 5% off an LPI exam voucher!