This will be a reminder for myself on how to set up a basic Arch Linux and not a guide with a lot of variety on how to set up arch. I will update this post when I learn something new, while installing arch on one of my machines again. In the past I did some experiments with btrfs
, but had some problems while rebalancing, and actually used none of the fancy features like snapshots, btrfs send
or other cool things. Therefore, I decided to go back to plain old ext4 with lvm. [1] Well, I actually used local snapshots bet never had to recover anything. A lot of this is based on the excellent (german) post from Thomas Leister [2]. Everything is (as always) documented in the arch wiki. [3]
Overview
Just a quick overview about the features before we get started.
- ext4 Filesystem with lvm
- encrypted root partition next to unencrypted
/boot
- EFI-Boot with systemd
Steps
1. Setup partitions
The disk Layout will look like this:
So let's get started with the partitioning. At first we will create the boot partition. I will use /dev/sda
as a placeholder, this could be anything on your local machine.
1 = boot partition:
gdisk /dev/sda
o
n
enter
enter
+512M
ef00
After the boot partition is set up, we will use the rest of the space for our data partition.
2 = data:
n
2
enter
enter
enter
Write the changes to disk with w
. Now we are ready for the next step, the encryption.
Setup LUKS encryption
Now to the disk encryption, dev/sda2
is the earlier created data partition.
cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --use-random luksFormat /dev/sda2
LVM and format partitions
# Open the earlier created encrypted disk partition
cryptsetup luksOpen /dev/sda2 lvm
pvcreate /dev/mapper/lvm
vgcreate main /dev/mapper/lvm
# Adjust to the actual memory size
lvcreate -L 16G -n swap main
lvcreate -l 100%FREE -n root main
mkswap /dev/mapper/main-swap
# You can use whatever you want instead of ext4
mkfs.ext4 /dev/mapper/main-root
# The ESP must be formated as vfat
mkfs.vfat /dev/sda1
Mount disks
mount /dev/mapper/main-root /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
swapon /dev/mapper/main-swap
Get network access
If you have an ethernet jack on your device this should work out of the box.
Get the fastest local mirror
Get the fastest local mirror to speed up the installation of the base system.
reflector --latest 10 --country Germany --sort rate --save /etc/pacman.d/mirrorlist
Install base system
Don't forget to install dhcpcd
as it was removed from base
.
pacstrap /mnt base linux linux-firmware lvm2 neovim dhcpcd
genfstab -U /mnt >> /mnt/etc/fstab
# Chroot in the installation
arch-chroot /mnt
# Set timezone info
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 and other needed locales.
Generate the locales by running: locale-gen
/etc/locale.conf
LANG=en_US.UTF-8
# Set hostname
nvim /etc/hostname
# Change root password
passwd
Boot
Edit /etc/mkinitcpio.conf
HOOKS="base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck"
Run mkinitcpio -p linux
bootctl --path=/boot install
/boot/loader/loader.conf
default arch
/boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options cryptdevice=/dev/sda2:main:allow-discards root=/dev/mapper/main-root resume=/dev/mapper/main-swap
:allow-discards
to enable TRIM support.
Run systemctl enable fstrim.timer
to enable fstrim
.
Reboot
- Exit chroot with
exit
umount /mnt/boot
umount /mnt
Next steps
You can now follow the post-installation recommendation. [4]
- Add a user
- Install software
- ...
Conclusion
I used this guide a few time for my personal machines. Overall the installation of Arch is straight forward, but as always with Arch you have a lot of possibilities (or opportunities) to use more or less equivalent software to reach the same goal. In this guide I decided on a lot of tools (e.g. systemd-boot instead of grub), because I simply like them or have no idea about newer and maybe better tools for the same problem. If you have any recommendations or improvements, don't hesitate to share them with me via mail.