Basic Arch Linux Installation on a VM (With or Without Full Disk Encryption)

Introduction

The icon of joy and frustration

Sometimes, going it alone is THE way to go.

TLDR: Because learning how to install Arch Linux on your own is such a great opportunity to learn new skills, I highly advise you to use this article ONLY IF you feel the official guide was unclear on a particular step.

Quick Overview

Step 1: Creating a VM and booting to Arch live environment

Live boot screen
Arch live system
ls /sys/firmware/efi/efivars
If this directory exists and has files similar to these, you are booted in EFI mode
timedatectl set-ntp true

Step 2: Setting up partitions

parted /dev/sda
mklabel gpt
mkpart "efi partition" fat32 1MiB 300MiB
set 1 esp on
mkpart "swap partition" linux-swap 300MiB 3000MiB
mkpart "root partition" ext4 3000MiB 100%
quit
Running parted commands to partition our virtual hard disk
An example run of “print free”
mkfs.fat /dev/sda1 -F 32
mkswap /dev/sda2
swapon /dev/sda2
Formatting the boot partition and enabling swap
mkfs.ext4 /dev/sda3
mount /dev/sda3 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
Formatting the root partition and mounting as prep for installation
cryptsetup -y -v luksFormat /dev/sda3
Running cryptsetup to encrypt a block device
cryptsetup open /dev/sda3 cryptroot
mkfs.ext4 /dev/mapper/cryptroot
mount /dev/mapper/cryptroot /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
Decrypting, formatting, and mounting the encrypted root partition

Step 3: Installing OS and packages

pacstrap /mnt base linux linux-firmware intel-ucode amd-ucode grub efibootmgr
# Pick which *ucode package you need based on your CPU or just install both.
pacstrap /mnt man-db man-pages texinfo
# These packages give you access to offline program documentation.
pacstrap /mnt net-tools iproute2 dhcp dhcpcd
# These packages are networking tools.
pacstrap /mnt xorg xorg-server xfce4 xfce4-goodies lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice
# These packages install the XFCE4 GUI, should you want it.
pacstrap /mnt vi vim nano gedit
# These packages are text editor programs. The GUI section will need to be installed for gedit to work.
pacstrap /mnt pulseaudio pulseaudio-alsa pulseaudio-bluetooth
# These packages are for enabling audio to play. They play nice with the GUI.
pacstrap /mnt base linux linux-firmware intel-ucode amd-ucode grub efibootmgr man-db man-pages texinfo vi vim nano gedit net-tools iproute2 dhcp dhcpcd xorg xorg-server xfce4 xfce4-goodies lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice pulseaudio pulseaudio-alsa pulseaudio-bluetooth
# Full installation command
genfstab -U /mnt >> /mnt/etc/fstab

Step 4: Setting up OS for boot

arch-chroot /mnt
nano /etc/mkinitcpio.conf
HOOKS=(base udev autodetect keyboard keymap consolefont modconf block encrypt filesystems fsck)
Initial mkinitcpio.conf file; notice the HOOKS line is NOT commented
An appropriately edited HOOKS line to deal with full drive encryption
blkid
Finding the right UUID for GRUB to use later
nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet cryptdevice=UUID={UUID}:cryptroot root=/dev/mapper/cryptroot"
Default kernel parameters
Edited kernel parameters to deal with full disk encryption
arch-chroot /mnt
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
# Change "America/New_York" as needed for the correct timezone
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
nano /etc/locale.gen
Edited locale.gen file
nano /etc/hostname
nano /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.0.1 {chosen_hostname}.localdomain {chosen_hostname}
Example “/etc/hosts” file
mkinitcpio -P
Example run of “mkinitcpio -P”
passwd
grub-install --target=x86_64-efi --efi-directory=boot --bootloader-id=GRUB
Installing GRUB on the root partition
CONFIG_BLK_DEV_INITRD=Y;
CONFIG_MICROCODE=y;
CONFIG_MICROCODE_INTEL=Y;
CONFIG_MICROCODE_AMD=y;
grub-mkconfig -o /boot/grub/grub.cfg
Creating the GRUB config file
systemctl enable lightdm
echo "exec startxfce4" > /etc/skel/.xinitrc
useradd -m -d /home/sandy -s /bin/bash testuser
passwd testuser
systemctl enable dhcpcd
exit
umount -R /mnt
reboot
GRUB menu
Decryption prompt
Lightdm GTK greeter
XFCE4 desktop

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store