Arch Linux Installation
Table of Contents
Those are my notes on installing Arch Linux. It closely follows the official guide and gets updated each time I install Arch on a new machine. There's of course no guarantee whatsoever for the guide being correct or complete. Some steps use a default I chose. Read each instruction carefully and decide if you'd like a different keyboard layout and if your disk is really /dev/sda/.
Reach out to me via email (contact at jaott dot de) for feedback or questions.
1. Preparation
1.1. Installation medium
Choose and download ISO from the official site.
Prepare USB installation medium like this.
Plug in drive and boot into live environment.
1.2. Temporary config
The following configuration is necessary or useful for the installation process, but will not persist on the system we'll install later on.
1.2.1. Keyboard
Double font size
$ setfont -d
List available keymaps
$ localectl list-keymaps
Choose keymap. We'll be using us
$ loadkeys us
1.2.2. Internet
Plug in ethernet cable or configure wifi:
$ iwctl
$ [iwd] device list
$ [iwd] station DEVICE scan
$ [iwd] station DEVICE get-networks
$ [iwd] station DEVICE connect SSID
Check connection
$ ping archlinux.org
1.2.3. Timezone
$ timedatectl
$ timedatectl set-timezone Europe/Berlin
1.3. Disks
1.3.1. Partitioning
Partition disks, /dev/sda will be used here, depends on the system.
List block devices
$ lsblk
Display and manipulate the disks partition table
$ cfdisk /dev/sda
If asked, enter gpt for UEFI install. [Delete] old partitions.
Create [New] partitions, values depend on hardware/personal preference.
| Role | Type | Size | Partition |
|---|---|---|---|
| Boot | EFI system partition | 1GB | /dev/sda1 |
| Swap | Linux swap | 4GB | /dev/sda2 |
| System | Linux x86-64 root | remaining space | /dev/sda3 |
[Write] changes to disk and [Quit].
1.3.2. Format & encrypt partitions
Create boot filesystem and set /dev/sda2 to be the swap partition.
$ mkfs.fat -F32 /dev/sda1
$ mkswap /dev/sda2
Encrypt root partition and choose your favorite file system (ext4 in this case)
$ cryptsetup luksFormat /dev/sda3
$ cryptsetup open /dev/sda3 cryptroot
$ mkfs.ext4 /dev/mapper/cryptroot
Turn swap on and mount newly created partitions
$ mount /dev/mapper/cryptroot /mnt
$ mount --mkdir /dev/sda1 /mnt/boot
$ swapon /dev/sda2
2. Installation
Install packages to the system. We don't need lvm2 and cryptsetup if we didn't set up encryption above. vim, networkmanager and man-* are optional, but convenient. If choose to not install some of the optional packages, the respective steps below must be ignored.
$ pacstrap /mnt base base-devel vim networkmanager lvm2 cryptsetup grub efibootmgr linux linux-firmware man-db man-pages
2.1. Troubleshooting
In case of pacman Signature is unknown trust error
$ pacman-key --refresh-keys
3. System configuration
3.1. fstab
$ genfstab -U /mnt > /mnt/etc/fstab
3.2. Chroot
Chroot into system environment
$ arch-chroot /mnt
3.3. Locale, time & clock
$ ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
Sync hardware clock
$ hwclock --systohc
To setup locale, edit /etc/locale.gen, uncomment the desired layout, e.g. en_US.UTF-8 and generate it
$ locale-gen
$ echo "LANG=en_US.UTF-8" > /etc/locale.conf
3.4. Host- and username
Set hostname
$ echo [HOSTNAME] > /etc/hostname
Password for root user
$ passwd
Give users of group wheel to sudo rights. Using visudo, uncomment %wheel ALL=(ALL:ALL) ALL.
$ visudo
Create new sudo user
$ useradd -m -G wheel -s /bin/bash [SUDO-USER-NAME]
$ passwd [SUDO-USER-NAME]
3.5. mkinitcpio
Configure mkinitcpio to be aware of the drive encryption: In /etc/mkinitcpio.conf, edit HOOKS=(…) and insert udev and encrypt as follows
HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block encrypt lvm2 filesystems fsck)
Regenerate initramfs image
$ mkinitcpio -P
3.6. GRUB
Install GRUB on /dev/sda
$ grub-install --efi-directory=/boot --bootloader-id=arch /dev/sda
Since we've encrypted our main drive above, GRUB has to decrypt it on startup (reference).
We'll need the output of the following to commands (call them FIRST and SECOND respectively) to configure GRUB.
$ blkid -o value -s UUID /dev/sda3
$ blkid -o value -s UUID /dev/mapper/cryptroot
In /etc/default/grub, edit the line GRUB_CMDLINE_LINUX_DEFAULT = "…" to look like this:
GRUB_CMDLINE_LINUX_DEFAULT = "loglevel=3 quiet cryptdevice=UUID=[FIRST]:cryptroot root=UUID=[SECOND]"
Generate GRUB config
$ grub-mkconfig -o /boot/grub/grub.cfg
3.7. NetworkManager
$ systemctl enable NetworkManager
3.8. Reboot
The installation is done. Reboot the system and remove USB stick.
$ exit
$ reboot
4. Post installation
4.1. Wifi
$ nmcli d wifi rescan
$ nmcli d wifi list
$ nmcli d wifi connect [SSID] --ask