Simple Arch Linux Installation or “I (now) use Arch btw”
Motivation
I’ve wanted to use Linux as my daily driver ever since I got my current job. All dev machines at work run on linux (Ubuntu or Arch,whatever you want. We get full reign!) and it’s been such a pleasant experience that I’ve decided to run linux on my personal machine. There was some apprehension at first, with how familiar I’d become with MacOS, but let’s be honest, Mac is just linux with extra ricing.
After little deliberation I decided to bite the bullet, and psycopath that I am, chose to use Arch as my daily driver. Now you might think I’m crazy (and you’re not wrong to do so) but I had other motives when making this decision. You see, the more i used linux the more fascinated I became with the idea of being in total control of my system. Having complete mastery of your tools is probably one of the most satisfying feelings any practitioner can have and nothing helps you master your tools as a software engineer like linux! You get an insight into how your computer works and the effects that has on your work cannot be overstated!
Why Arch?
So enter Arch. Why Arch? I don’t think any other distro gives you the level of control Arch gives you over your system. No desktop environment, no preinstalled packages, no bloatware. Just you and your terminal. You get to choose what you want to install and how you want to configure it. It’s like building a house from scratch, brick by brick, nail by nail. It can certainly be intimidating at first, but it’s actually a liberating and empowering experience, to know that you built your system from the ground up, and that you can change it however you want. However, Arch’s greatest strength is also it’s greatest weakness. Most of us just cannot afford to spend hours ricing up our system and would rather have a pre-baked machine up and running. I guess that’s why every year is the year of the Linux Desktop. That being said, there’s a solution to that problem as there are a lot of people on the internet who give you their setup for free. I personally used Omarchy which gives you a decent but minimal Arch setup. You get the best of both worlds because you still have to install Arch and setup encryption, networking, partitioning and all that jazz, but don’t have to worry about numerous config files and packages. Thank God for the internet!
The Process
I decided to write this guide as a simple bullet point list of the steps you need to take. I personally like this approach since you don’t have the extra cognitive load of reading a paragraph to get the information you need. Just follow the steps!
This guide assumes you have a basic understanding of how to use the terminal and some familiarity with Linux. You will see a lot of foreign terms being used so I highly recommend you read the Arch Wiki as you follow along. It’s a great resource and has a lot of information on how to use Arch.
Now that’s enough yapping. Let’s get into it!
- create the bootable and boot sytem into arch
- connect to wifi. first run
iplink
to check network connection - then
iwctl
to enter wifi connection mode - choose network by running
station wlan0 connect <network name>
- check system is available for remote access through ssh.
systemctl status sshd.service
. this checks sshdaemon is running - check
.ssh
is empty. do this because we want to setup authentication - to setup auth run
passwd
in.ssh
directory - should be able to ssh in through the password
setting up the system
- check keyboard is correct using
localetcl list-keymaps
and choose your desired keyboard map. - update system clock by running
timedatectl
partioning disks
- use
lsblk
to get a look into the currently attached disks and their partitions
- will be using lvm for partitioning. lvm basically creates a /boot partition and then uses the rest as one big partition. it is in this big partition it creates “logical volumes” of storage which can then be freely resized. it also lets logical volumes span multiple storage devices.
- start partitioing using
fdisk /dev/nvmen01
- we’re going to be using lvm so i’ve cleared the disk. it should be fresh and have no partitions.
- create a new partition table with
g
command and follow that withn
to create new partition. - creating boot partiton with
+1G
to have one GB for /boot. accept the defaults except size default. - use
t
to change partition type though since we want it to be boot partition. look forEFI
partition type and use that - create the linux lvm partition.
- accept default first section and last section since its the rest of the disk
- change type to use
Linux LVM
encrypt disk
- will be using ‘LVM on LUKS’ format so we can encrypt the entire disk. [link to arch wiki]
- run
cryptsetup luksFormat /dev/<name of large partition>
. save passphrase soemwhere safe - run
cryptsetup open /dev/<name> cryptlvm
to open the encrypted partition - create a physical volume on the parittion using
pvcreate /dev/mapper/cryptlvm
- create volume group using
vgcreate <name> /dev/mapper/cryptlvm
- create logical volumes which will be the actual volumes.
- create swap logical volume
lvcreate <volume group name> -L <swap_size> -n swap
- create root and home and data partitions
- create filesystem for each partition you made using
mkfs .ext4 /dev/<volume group name>/<partition name>
- call
mkswap /dev/<volume group name>/swap
- make fat32 filesystem for boot partition:
mkfs.fat -F32 /dev/<boot partition>
- make sure to mount root before boot!
- mount boot using
mount --mkdir /dev/<boot partition> /mnt/boot
- use
lvremove /dev/<volume group>/<partition>
if you want to remove logical volume - use
lvresize /dev/<group>/<partition> -L <size>
to resize after remvoing a block - run
resize2fs <partition>
to resize after messing with any of the volumes - specify swap partition by running
swapon <partition>
installing the OS
- at this point we need to download the linux kernel and any other packages that would be needed. to do this run
pacstrap -K /mnt base linux linux-firmware intel-ucode
now if you cd into/mnt
you’ll see a regular linux filesystem. - Now run
genfstab -U /mnt >> /mnt/etc/fstab
to genrate an fstab file - next
chroot
into the system.arch-chroot /mnt
. You are now in a linux OS.
Basic Setup
-
change the timezone by running
ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime
you can substitute the regions here are required. -
run
hwclock --systohc
to generate/etc/adjtime
-
now if you run
date
you will see you date and timezone info. -
Next install some essential packages using
pacman -Syu man which sudo grep man-pages texinfo man-db
-
open
/etc/locale.gen
and uncomment your desired locale. i’ll be usingLANG=en_US.UTF-8
so i’ll uncomment that line. -
next generate locales using
locale-gen
-
open
/etc/locale.conf
file and put in your desired locale there. in my case i’ll be using en_us which will mean I have this line in my fileLANG=en_US.UTF-8
Networking
We want to enable networking capabilities using ether or wlan. for those we will be using systemd-networkd
and iwd
for wired and wireless respectively.
- run
systemctl enable systemd-networkd.service systemd-resolved.service
resolved
is needed for DNS configuration - you want to make sure you have a valid conf forresolved
at/etc/resolv.conf
so that you don’t have DNS resolution problems. To do this simply runsudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
to create a symlink from thesystemd
stub file.- create a network configuration file by running
vim /etc/systemd/network/25-wireless.network
and paste the following inside the file:
[Match]
Name=wlan0
[Network]
DHCP=yes
IgnoreCarrierLoss=3s
- install
iwd
by runningpacman -Syu iwd
- enable
systemd
service:systemctl enable iwd.service
- setup hostname by putting desired hostname in
/etc/hostname
Customise initramfs
initramfs
is a scheme that loads a temporary root file system into RAM that aids in the linux startup process.
- Open
/etc/mkinitcpio.conf
. There should be a defaultHOOKS
array that we want to edit. Since we’re using asystemd
basedinitramfs
we want to replaceudev
withsystemd
and also addlvm2
since we’re using LVM partitions. We also want to replaceencrypt
withsd-encrypt
- open
/etc/vconsole.conf
and add a font from/usr/share/kbd/consolefonts
:
FONT=latarcyrheb-sun32
we do this because we specified `vconsole` in hooks.
-
edit
root
kernel parameter in bootloader to point toroot
logical volume. -
run
mkinitcpio -P
to regenerateinitramfs
. Make surelvm2
package is installed to avoid errors. -
you’ll see a few warnings after running this. don’t worry about these for now.
Configure boot loader
when you startup a computer the follwoing process happens:
POST (POWER ON SELF TEST) ---> LOAD BIOS --> SCAN DISK FOR BOOT PARTITION --> LOOK FOR BOOTLOADER in /boot -->
- will be using
systemd-boot
as boot loader that comes preinstalled . - run
bootctl install
. - you might get some warnings about
/boot
being world accessible. This is because of insufficient permissions on the filesystem. when we rungenfstab
it automatically generated some permissions regarding files and directories in thefmask
anddmask
options. These look different because FAT filesystems don’t recognise UNIX permissions.- to fix our problem we simply want to change the values for
fmask
anddmask
to0137
and0027
respectively. - then unmount and remount our bootloader using
umount /boot
andmount /boot
- now rerun
bootctl install
- run
bootctl update
to verify bootloader is installed.
- to fix our problem we simply want to change the values for
- update boot loader entry for arch OS by adding this snippet:
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options rd.luks.name=<device_UUID>=cryptlvm root = <rootpartition> rw
# where <device_UUID> is the UUID of the entire encrypted LVM partition (get this by running blkid. basically the second partition apart from /boot)
# <rootpartition> is the mounted root partition logical volume, e.g: /dev/voluemgroup/mount
to /boot/loader/entries/arch.conf
1
Setup User and authentication
- run
useradd -m <name>
- give them root permission by running
usermod -aG wheel <name>
- run
visudo
and uncomment this line in there:%wheel ALL=(ALL:ALL) ALL
- if
visudo
doesn’t work you might need to installsudo
with pacman.
- if
- setup root password by running
passwd
as root and setup password for chubi by runningpasswd chubi
Bonus: Configuring SSH
Now that you have a barebones Arch install up and running you might want to be able to make changes to your system from another machine. In my case I had Arch running on my desktop and wanted to lie down on my bed and configure things with my laptop :)
setup
- Install
openssh
withsudo pacman -Syu openssh
- Start the ssh daemon:
sudo systemctl start sshd
- You can enable it if you want it running on boot:
sudo systemctl enable sshd
- You can enable it if you want it running on boot:
- get the system’s ip address with
ip a
- Now on the client machine simply
ssh <user>@<ip address>
Footnotes
-
when in vim normal mode you can type
!!
to insert linux commands into the current buffer. ↩