User:Cvlc/Notes/Installation guide

From ArchWiki
Jump to navigation Jump to search
Warning: WIP Do not follow

Pre-installation

Acquire an installation image

Verify signature

Prepare an installation medium

Boot the live environment

Set the keyboard layout

Verify the boot mode

Connect to the internet

Update the system clock

Partition the disks

Tip: Check that your disk reports the correct sector size

Partition layout

UEFI with GPT
Partition Partition type Size Mount point
/dev/nvme0n1p1 EFI system partition 300 MiB /mnt/boot
/dev/nvme0n1p2 Linux x86-64 root (/) Remainder of the device /mnt
# fdisk /dev/nvme0n1

Use o to create a GPT Partition table, then

  • EFI partition: n with all defaults except last sector +300M, t partition type 1 to set partition type to EFI System
  • Root: n with all defaults to use remaining space

Encryption Setup

# cryptsetup luksFormat /dev/nvme0n1p2
# cryptsetup --allow-discards --perf-no_read_workqueue --perf-no_write_workqueue --persistent open /dev/nvme0n1p2 crypt

See Dm-crypt/Specialties #Discard/TRIM support for solid state drives (SSD) and Dm-crypt/Specialties #Disable workqueue for increased solid state drive (SSD) performance

Optional: create a keyfile on a USB device

To unlock root like a physical key

# mkfs.fat /dev/sdX
# mount /dev/sdX /mnt
# dd bs=512 count=4 if=/dev/random of=/mnt/mykeyfile iflag=fullblock
# chmod 600 /mnt/mykeyfile
# cryptsetup luksAddKey /dev/nvme0n1p2 /mnt/mykeyfile
# umount /mnt

Format the partitions

# mkfs.fat -F 32 /dev/nvme0n1p1
# mkfs.btrfs -L Arch /dev/mapper/crypt

Create subvolumes

# mount /dev/mapper/crypt /mnt
# btrfs subvolume create /mnt/@
# btrfs subvolume create /mnt/@home
# btrfs subvolume create /mnt/@var_cache
# btrfs subvolume create /mnt/@var_log
# btrfs subvolume create /mnt/@var_tmp
# btrfs subvolume create /mnt/@snapshots

See Snapper#Suggested_filesystem_layout and User talk:Lahwaacz#Btrfs layout

# umount /mnt

Mount the file systems

# mount -o compress=zstd,discard=async,subvol=@ /dev/mapper/crypt /mnt
# mkdir -p /mnt/{boot,home,var/{cache,log,tmp},.snapshots}

# mount -o compress=zstd,discard=async,subvol=@home /dev/mapper/crypt /mnt/home
# mount -o compress=zstd,discard=async,subvol=@var_cache /dev/mapper/crypt /mnt/var/cache
# mount -o compress=zstd,discard=async,subvol=@var_log /dev/mapper/crypt /mnt/var/log
# mount -o compress=zstd,discard=async,subvol=@var_tmp /dev/mapper/crypt /mnt/var/tmp
# mount -o compress=zstd,discard=async,subvol=@snapshots /dev/mapper/crypt /mnt/.snapshots

# mount /dev/nvme0n1p1 /mnt/boot

info on discard option.

Installation

Select the mirrors

Install essential packages

# pacstrap /mnt base linux nano btrfs-progs networkmanager iwd reflector bash-completion sudo pacman-contrib base-devel git intel-ucode sof-firmware
Tip: intel-ucode and sof-firmware are device specific (Intel)

Configure the system

Fstab

# genfstab -U /mnt >> /mnt/etc/fstab

Check the resulting /mnt/etc/fstab file, and edit it to remove the subvolid and redundant subvol mount options. Entries should look something like this:

/mnt/etc/fstab
[...] btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache,subvol=@ 0 0 [...]

Chroot

Time zone

Localization

Network configuration

Create the hostname file:

/etc/hostname
myhostname

We will use NetworkManager (for Gnome integration) with the newer iwd backend instead of wpa_supplicant, and systemd-resolved for Name Resolution:

# systemctl enable systemd-resolved NetworkManager iwd
# systemctl mask wpa_supplicant

Enable the iwd backend by creating the following drop-in configuration file

/mnt/etc/NetworkManager/conf.d/wifi_backend.conf
[device]
wifi.backend=iwd

Initramfs

Modify the MODULES and HOOKS variables in /etc/mkinitcpio.conf :

/etc/mkinicpio.conf
MODULES=(i915 vfat)
HOOKS=(base systemd autodetect modconf block filesystems keyboard sd-vconsole sd-encrypt fsck)
Tip: MODULES=() is specific to my setup :

Recreate the initramfs image:

# mkinitcpio -P

Root password

Boot loader

Use bootctl to install systemd-boot into the EFI system partition by running:

# bootctl install

To update the boot-loader automatically after systemd updates, place the following pacman hook in the /etc/pacman.d/hooks/ directory:

# mkdir /etc/pacman.d/hooks
/etc/pacman.d/hooks/100-systemd-boot.hook
[Trigger]
Type = Package
Operation = Upgrade
Target = systemd

[Action]
Description = Updating systemd-boot
When = PostTransaction
Exec = /usr/bin/bootctl update

Adjust the loader configuration :

/boot/loader/loader.conf
default arch.conf
editor no

Copy the example entry file :

# cp /usr/share/systemd/bootctl/arch.conf /boot/loader/entries/arch.conf

Then modify it to this :

/boot/loader/entries/arch.conf
title 	Arch Linux 
linux	/vmlinuz-linux
initrd  /intel-ucode.img
initrd  /initramfs-linux.img
options rd.luks.name=<UUID-OF-nvme0n1p2>=crypt root=/dev/mapper/crypt rootflags=subvol=@ rw quiet

Create a fallback entry:

# cp /boot/loader/entries/arch.conf /boot/loader/entries/arch-fallback.conf

Then modify it to this :

/boot/loader/entries/arch-fallback.conf
title 	Arch Linux (fallback initramfs)
linux	/vmlinuz-linux
initrd  /intel-ucode.img
initrd  /initramfs-linux-fallback.img
options rd.luks.name=<UUID-OF-nvme0n1p2>=crypt root=/dev/mapper/crypt rootflags=subvol=@ rw quiet
Tip:
  • Use Ctrl+t to run blkid -s UUID -o value /dev/nvme0n1p2 from inside nano to get the UUID.
  • If a USB keyfile was created, add options rd.luks.options=keyfile-timeout=10s rd.luks.key=<UUID-OF-nvme0n1p2>=/keyfile:UUID=<UUID-of-USB-key>
  • Warning, /intel-ucode.img is device specific (Intel microcode updates). quiet is for silent boot, together with early KMS

Reboot

Exit the chroot environment by typing exit or pressing Ctrl+d.

Create the /etc/resolv.conf symlink for systemd-resolved as it was not possible while inside chroot.

# ln -sf /run/systemd/resolve/stub-resolv.conf /mnt/etc/resolv.conf

Optionally manually unmount all the partitions with umount -R /mnt: this allows noticing any "busy" partitions, and finding the cause with fuser(1).

Finally, restart the machine by typing reboot: any partitions still mounted will be automatically unmounted by systemd. Remember to remove the installation medium and then login into the new system with the root account.

Post-installation

See User:Cvlc/Notes/General_recommendations