Installing Arch Linux

Navigate to https://archlinux.org/download and download the latest installer. It’s refreshed every month, but again you don’t have to keep redownloading it, you’ll only need it once. Again, the updated installation media doesn’t represent a new version of Arch to upgrade to, but rather a new version of the installer to get started with. The only thing that changes primarily between installer versions is the fact that the contents are kept up to date.

 

Booting the Installer and Connecting to the Internet

To boot the installer, all we have to do is access our computer’s boot menu. To access your computer’s boot menu, you’ll press a specific key immediately when your computer first starts up. The specific key you’ll press varies from one manufacturer to another.

 

Before we jump into that though, the first requirement is that we have Internet access. If you’re using wired ethernet and have connected a cable, you should have an IP address already. To check that, we can run this command:

 

ip addr show

 

If we have an IP address here, then we’re good to go.

 

However, some of you need to use WiFi – in fact, some laptops don’t even have an Ethernet port nowadays.

 

If you want to set up WiFi, we’ll use the following command to get started with that:

 

iwctl

 

You’ll notice that the prompt changed, and that’s because we’re now inside the WiFi management utility of Arch Linux, where we can enter commands directly to configure WiFi. We’ll first need to know the identifier that was assigned to our WiFi card, which we can get from the following command:

 

device list

 

In my case, my WiFi card is wlan0, which will be very common. But if yours is something different, then replace wlan0 with whatever yours is anytime I reference it. Anyway, the next thing we’ll do is trigger a WiFi network scan:

 

station wlan0 scan

 

We won’t see any output, and that’s because we simply triggered a scan – which will happen in the background. After several seconds, we can run the following command to see the networks the scanner was able to find:

 

station wlan0 get-networks

 

After that, we’ll connect to one of the networks, and the command will look similar to this:

 

station wlan0 connect SSID

 

It’ll ask us for our WiFi password, and that’s it. We can type “exit” to return to the normal prompt. And now, we should have an IP address assigned to our WiFi card:

 

ip addr show

 

To test it, we can issue a simple ping command:

 

ping -c 3 google.com

 

If we get responses to our ping, we’re good to go.

 

With that done, we’re clear to get started.

 

So, let’s begin installing Arch!

 

Update the system clock

The live system needs accurate time to prevent package signature verification failures and TLS certificate errors. The systemd-timesyncd service is enabled by default in the live environment and time will be synchronized automatically once a connection to the internet is established. Use timedatectl command to ensure the system clock is synchronized:

 

timedatectl

 

Partitioning our Disk

The first thing we’ll do is see what hard disks we have installed on our system:

 

lsblk

 

What we’re looking for here is the device name for our hard disk, which, in my case is /dev/nvme0n1. All you have to do at this point is just make a note of your device name.

 

Continuing, we’ll use the fdisk command to partition our disk. There’s other utilities you can use aside from fdisk, but fdisk has always worked well for me – so I’ve just stuck with it. That said, we’ll enter the following command to start partitioning our system:

 

fdisk /dev/nvme0n1

 

Notice I didn’t include a partition number after /dev/nvme0n1, because the numbers in my output represent partition numbers, and by excluding the number we’re telling fdisk we want to work with the entire disk, not an existing partition. If you just built your system and have a brand new hard disk, you may not see any partitions – and that’s fine, we’ll create them now.

 

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

 

g
n
1
enter
+256M

 

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

 

n
2
enter
+1G

 

And again, for the third partition:

 

n
3
enter
enter
t
3
44
w

 

Now, we’ll begin the process of formatting our new partitions:

 

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

 

mkfs.fat -F32 /dev/nvme0n1p1

 

Format the Boot partition (the second 1GB partition created):

 

mkfs.ext4 /dev/nvme0n1p2

 

Next, before we set up our third partition, let’s encrypt it first. By setting up encryption we’re increasing the security of our system, and will be protected against data theft. The following commands will help us set this up:

 

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

 

Setting up LVM

 

Next, we’re going to set up what’s called a Logical Volume Manager, or LVM for short. With LVM, we can easily expand our disk if we ever upgrade it, and it also supports snapshots, so it’s good to have. It’s possible you may never use it, but it’s easy to set up and works very well, so let’s do that now.

 

pvcreate /dev/mapper/lvm

 

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

 

vgcreate vg0 /dev/mapper/lvm

 

After that, we’ll create a 128GB logical volume named root:

 

lvcreate -L 128GB vg0 -n root

 

We’ll then create a second logical volume with the remaining disk space available, this time named home:

 

lvcreate -l +100%FREE vg0 -n home

 

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

 

modprobe dm_mod

 

vgscan

 

vgchange -ay

 

When it comes to formatting and mounting our partitions, we’ll focus on root and 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/vg0/root

 

mkfs.ext4 /dev/vg0/home

 

Next, we’ll mount root:

 

mount /dev/vg0/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/vg0/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

 

Time

For human convenience (e.g. showing the correct local time or handling Daylight Saving Time). In my case, I am located in the central timezone in the United States, to set the time zone, I will use the following command:

 

ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

 

Then run hwclock to generate /etc/adjtime:

 

hwclock --systohc

 

Install basic packages

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

 

pacman -S base-devel dosfstools grub efibootmgr plasma sddm sddm-kcm lvm2 mtools nano networkmanager os-prober sudo linux linux-headers linux-firmware mesa konsole dolphin dolphin-plugins

 

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 dje

 

Then, set a password for your account:

 

passwd dje

 

Add user to the sudo group:

 

groupadd sudo

 

usermod -aG sudo dje

 

Edit /etc/mkinitcpio.conf:

 

nano /etc/mkinitcpio.conf

 

Add "sd-encrypt lvm2" in between block and filesystems Generate kernel ramdisk(s)

 

mkinitcpio -p linux

 

Generate locales:

 

To use the correct region and language specific formatting (like dates, currency, decimal separators), edit /etc/locale.gen and uncomment the UTF-8 locales you will be using.

 

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

 

nano /etc/locale.gen

 

Generate the lacales by running:

 

locale-gen

 

Next, we’ll need to edit the /etc/default/grub file. But first, we’ll need to know what the UUID is of our third partition, and in fact we can use the following command to generate exactly what we need:

 

echo “rd.luks.name=$(blkid -s UUID -o value /dev/nvme0n1p3)=lvm”

 

Now, make a copy of that line, or at least take a photo of it, we’ll need it to edit the bootloader configuration:

 

nano /etc/default/grub

 

Within that file, look for a line containing GRUB_CMDLINE_LINUX and add: "rd.luks.name=UUID=lvm root=/dev/vg0/root” into it. For example, a typical configuration line of this type might look like this:

 

GRUB_CMDLINE_LINUX="rd.luks.name=c5b20e77-eedb-4b11-962e-4ea0ea40d6f5=lvm root=/dev/vg0/root"

 

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 SDDM to start when you reboot:

 

systemctl enable sddm

 

Enable NetworkManager so networking will function when you reboot:

 

systemctl enable NetworkManager

 

Wrapping Up:

 

Exit chroot environment:

 

exit

 

Unmount all partitions:

 

umount -a

 

Reboot the system:

 

reboot

 

And that’s it! If the system starts up without problems, you'll have an Arch Linux system running KDE Plasma.

 

Leave a comment