2022-05-20 21:26:28 +02:00
---
title: Arch
2022-11-19 15:25:20 +01:00
visible: true
2022-05-20 21:26:28 +02:00
---
2022-06-06 18:38:51 +02:00
[toc]
2022-12-16 11:50:40 +01:00
2024-06-01 21:38:25 +02:00
Last modified: 2024-06-01
2023-11-17 14:42:26 +01:00
2022-05-20 21:26:28 +02:00
## Keyboard layout
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
[shroot]
```
loadkeys de_CH-latin1
```
[/shroot]
2022-05-20 21:26:28 +02:00
## Check UEFI mode
2022-12-16 11:50:40 +01:00
2024-05-28 18:42:48 +02:00
If the following command works, the system is booted in EFI.
2023-11-17 14:42:26 +01:00
[shroot]
```
ls /sys/firmware/efi/efivars
```
[/shroot]
2022-05-20 21:26:28 +02:00
## Verify internet connection
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
[shroot]
```
ping wiki.exu.li
```
[/shroot]
2022-05-20 21:26:28 +02:00
## Update system clock
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
[shroot]
```
timedatectl set-ntp true
```
[/shroot]
2022-05-20 21:26:28 +02:00
## Creating partitions
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
[shroot]
```
cfdisk
```
[/shroot]
2022-05-20 21:26:28 +02:00
Use `EFI System` for EFI partition
2022-12-16 11:50:40 +01:00
Use `Linux filesystem` for other partitions
2022-05-20 21:26:28 +02:00
## (LUKS) Create encrypted partition
2022-12-16 11:50:40 +01:00
_Note: Do not put your /efi partition on an encrypted partition!_
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
Create encrypted Partition with a label. This label will later be used to identified the bootdevice as a simpler alternative to UUIDs.
2023-11-17 14:42:26 +01:00
[shroot]
```
cryptsetup luksFormat --label=(label) /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
Open the partition and specify a name
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[shroot]
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
```
cryptsetup open /dev/(partition) (name)
```
[/shroot]
2022-05-20 21:26:28 +02:00
Check if this worked with `ls /dev/mapper/`
2022-12-16 11:50:40 +01:00
The name should show up there
2022-05-20 21:26:28 +02:00
## Format partitions
2022-12-16 11:50:40 +01:00
2024-05-28 18:42:48 +02:00
### EFI or BIOS partition
Fat 32:
2023-11-17 14:42:26 +01:00
[shroot]
```
mkfs.fat -F32 /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
### Root and other partitions
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
**Ext4**
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[shroot]
```
mkfs.ext4 /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
**Btrfs**
2023-11-17 14:42:26 +01:00
[shroot]
```
mkfs.btrfs /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
**Bcachefs**
[shroot]
```
bcachefs format /dev/(partition)
```
[/shroot]
2022-05-20 21:26:28 +02:00
## Mounting partitions
2022-12-16 11:50:40 +01:00
2022-05-20 21:26:28 +02:00
Generally partitions have to be mounted where you will later use them in your system.
2023-11-17 14:42:26 +01:00
BTRFS with its subvolumes is a special case, see the additional chapter below.
Be careful in choosing you EFI mountpoint when using full disk encryption.
Using `/efi` will lead to much longer boot times in GRUB and be completely unsupported in other bootloaders.
See [this feature comparison ](https://wiki.archlinux.org/title/Arch_boot_process#Boot_loader ) for details.
For `/efi` size really doesn't matter much and can be 1 or 2 megabytes. 16MB is probably a good size.
2024-05-28 18:42:48 +02:00
If you're using `/boot` , the kernel and initramfs will also be stored on this partition among others. Recommended sizes range from 256MB to 512MB
2022-12-16 11:50:40 +01:00
2022-05-20 21:26:28 +02:00
```
Root: /mnt
EFI: /mnt/efi or /mnt/boot
Home: /mnt/home
etc...
```
### (BTRFS) Btrfs preparation of subvolumes and mounting
2022-12-16 11:50:40 +01:00
2024-05-28 18:42:48 +02:00
Mount root partition
2023-11-17 14:42:26 +01:00
[shroot]
```
mount /dev/(partition) /mnt
```
[/shroot]
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
Root subvolume
2023-11-17 14:42:26 +01:00
[shroot]
```
btrfs subv create /mnt/@
```
[/shroot]
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
Home subvolume
2023-11-17 14:42:26 +01:00
[shroot]
```
btrfs subv create /mnt/@home
```
[/shroot]
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
Snapshots subvolume for snapper
2022-06-05 15:14:33 +02:00
2023-11-17 14:42:26 +01:00
[shroot]
```
btrfs subv create /mnt/@snapshots
```
[/shroot]
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
Var subvolume
2023-11-17 14:42:26 +01:00
[shroot]
```
btrfs subv create /mnt/@var_log
```
[/shroot]
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[shroot]
```
umount /mnt
```
[/shroot]
2022-05-20 21:26:28 +02:00
Mount root
2023-11-17 14:42:26 +01:00
`mount -o noatime,compress-force=zstd,subvol=@ /dev/(partition) /mnt`
2022-05-20 21:26:28 +02:00
With /efi
2024-05-28 18:42:48 +02:00
`mkdir -p /mnt/{efi,home,.snapshots,var/log}`
2022-05-20 21:26:28 +02:00
With /boot
2024-05-28 18:42:48 +02:00
`mkdir -p /mnt/{boot,home,.snapshots,var/log}`
2022-05-20 21:26:28 +02:00
Mount home
2023-11-17 14:42:26 +01:00
`mount -o noatime,compress-force=zstd,subvol=@home /dev/(partition) /mnt/home`
2022-05-20 21:26:28 +02:00
Mount snapshots for snapper
2023-11-17 14:42:26 +01:00
`mount -o noatime,compress-force=zstd,subvol=@snapshots /dev/(partition) /mnt/.snapshots`
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
Mount var/log
2023-11-17 14:42:26 +01:00
`mount -o noatime,compress-force=zstd,subvol=@var_log /dev/(partition) /mnt/var/log`
2022-05-20 21:26:28 +02:00
2022-12-16 11:50:40 +01:00
**Don't forget mounting other partitions!!**
2022-05-20 21:26:28 +02:00
## Essential packages
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
Install a few essential packages using `pacstrap` .
2024-05-28 18:42:48 +02:00
Additional packages might also be necessary, see the list below.
2023-11-17 14:42:26 +01:00
[shroot]
```
pacstrap /mnt base base-devel linux linux-firmware linux-headers vim git openssh networkmanager dialog
```
[/shroot]
2022-05-20 21:26:28 +02:00
### Microcode
2022-12-16 11:50:40 +01:00
`amd-ucode`
`intel-ucode`
2022-05-20 21:26:28 +02:00
### Filesystems
2022-12-16 11:50:40 +01:00
2022-05-20 21:26:28 +02:00
Fat32:
2022-12-16 11:50:40 +01:00
`dosfstools mtools`
2022-05-20 21:26:28 +02:00
Ext4:
2022-12-16 11:50:40 +01:00
`e2fsprogs`
2022-05-20 21:26:28 +02:00
Btrfs:
2022-12-16 11:50:40 +01:00
`btrfs-progs compsize`
2022-05-20 21:26:28 +02:00
### Wifi
2022-12-16 11:50:40 +01:00
`wpa_supplicant`
2022-05-20 21:26:28 +02:00
### Snapper
2022-12-16 11:50:40 +01:00
`snapper`
2022-05-20 21:26:28 +02:00
### Certificates
2022-12-16 11:50:40 +01:00
`ca-certificates ca-certificates-mozilla`
2022-05-20 21:26:28 +02:00
### other
2022-12-16 11:50:40 +01:00
`cups hplip xdg-utils xdg-user-dirs inetutils`
2022-05-20 21:26:28 +02:00
## Generate fstab
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
[shroot]
```
genfstab -U /mnt >> /mnt/etc/fstab
```
[/shroot]
2022-12-16 11:50:40 +01:00
**Make sure the fstab file has everything included**
2022-05-20 21:26:28 +02:00
## Chroot into the system
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
[shroot]
```
arch-chroot /mnt
```
[/shroot]
2022-05-20 21:26:28 +02:00
## Set timezone
2022-12-16 11:50:40 +01:00
`ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime`
2022-05-20 21:26:28 +02:00
## Set hardware clock
2022-12-16 11:50:40 +01:00
`hwclock --systohc`
2022-05-20 21:26:28 +02:00
## Set locale
2022-12-16 11:50:40 +01:00
2022-05-20 21:26:28 +02:00
`vim /etc/locale.gen`
Uncomment the locales that should be generated.
2022-12-16 11:50:40 +01:00
Make sure to use a UTF-8 entry.
2022-05-20 21:26:28 +02:00
2022-12-16 11:50:40 +01:00
`locale-gen`
2022-05-20 21:26:28 +02:00
2022-12-16 11:50:40 +01:00
`echo "LANG=de_CH.UTF-8" > /etc/locale.conf`
2022-05-20 21:26:28 +02:00
## Set keymap permanently
2022-12-16 11:50:40 +01:00
`echo "KEYMAP=de_CH-latin1" > /etc/vconsole.conf`
2022-05-20 21:26:28 +02:00
## Set hostname
2022-12-16 11:50:40 +01:00
`echo "(hostname)" > /etc/hostname`
Edit `/etc/hosts`
2022-05-20 21:26:28 +02:00
```
2023-11-17 14:42:26 +01:00
127.0.0.1 localhost (hostname)
2022-05-20 21:26:28 +02:00
::1 localhost
```
## Change root password
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
[shroot]
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
```
passwd
```
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[/shroot]
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
## Bootloader installation
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
### rEFInd
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[shroot]
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
```
pacman -S refind
```
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[/shroot]
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
Use the rEFInd installation script. In most cases no specific configuration is necessary
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[shroot]
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
```
refind-install
```
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[/shroot]
2022-12-16 11:50:40 +01:00
2024-05-28 18:42:48 +02:00
**Manual editing of the generated configuration file is necessary when installing rEFInd from the Arch boot ISO**
2024-06-25 17:07:40 +02:00
#### Autodetection
2022-05-20 21:26:28 +02:00
2024-06-25 17:07:40 +02:00
`/boot/refind_linux.conf`
2023-11-17 16:05:11 +01:00
```
"Boot with standard options" "rw loglevel=3 quiet cryptdevice=LABEL=(label):(name) root=/dev/mapper/(name) rootflags=subvol=@"
```
2022-05-20 21:26:28 +02:00
2024-06-25 17:07:40 +02:00
#### Manual boot stanza
Assuming you use a `/boot` partition containing the `EFI` directory and linux kernels.
`refind-nord-theme` is required for the icon configured below. Install it from the AUR or change the icon to `/EFI/refind/icons/os_arch.png` .
`/boot/EFI/refind/refind.conf`
```
menuentry "Arch Linux" {
icon /EFI/refind/themes/nord/icons/os_arch.png
loader /vmlinuz-linux
initrd /initramfs-linux.img
options "rw loglevel=3 quiet cryptdevice=LABEL=(label):(name) root=/dev/mapper/(name) rootflags=subvol=@"
submenuentry "Boot using fallback initramfs" {
initrd /initramfs-linux-fallback.img
}
submenuentry "Boot to terminal" {
add_options "systemd.unit=multi-user.target"
}
}
```
Edit `/boot/EFI/refind/themes/nord/theme.conf` to show keyboard options by removing `hints` from `hideui`
```
...
hideui singleuser,badges
...
```
2024-05-28 18:42:48 +02:00
### GRUB
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
[shroot]
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
```
pacman -S grub efibootmgr
```
2022-12-16 11:50:40 +01:00
2024-05-28 18:42:48 +02:00
[/shroot]
Make sure the `/boot` or `/efi` partition is mounted
[shroot]
```
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
```
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
[/shroot]
2024-06-01 21:38:25 +02:00
Generate the grub config file
[shroot]
```
grub-mkconfig -o /boot/grub/grub.cfg
```
[/shroot]
2024-05-28 18:42:48 +02:00
### (LUKS) mkinitcpio with LUKS
Some additional settings are necessary in `/etc/mkinitcpio.conf` in order to enable booting from LUKS-encrypted disks.
Edit the `HOOKS` section in `/etc/mkinitcpio.conf` by adding `encrypt` after `block` and before `filesystems`
Also ensure `keyboard keymap` are present before `encrypt` in order to allow the loading of the default keyboard language from `/etc/vconsole.conf` to enter the decryption password.
Regenerate all initramfs presets
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[shroot]
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
```
mkinitcpio -P
```
2022-05-20 21:26:28 +02:00
2023-11-17 14:42:26 +01:00
[/shroot]
2022-05-20 21:26:28 +02:00
## Networking
2022-12-16 11:50:40 +01:00
`systemctl enable NetworkManager`
2022-05-20 21:26:28 +02:00
## (CUPS) Printing
2022-12-16 11:50:40 +01:00
`systemctl enable cups`
2022-05-20 21:26:28 +02:00
## Add user
2022-12-16 11:50:40 +01:00
`useradd -mG wheel (user)`
2022-05-20 21:26:28 +02:00
Set password
2022-12-16 11:50:40 +01:00
`passwd (user)`
2022-05-20 21:26:28 +02:00
### Enable sudo
2022-12-16 11:50:40 +01:00
2022-05-20 21:26:28 +02:00
`visudo`
2022-12-16 11:50:40 +01:00
Uncomment `%wheel ALL=(ALL) ALL`
2022-05-20 21:26:28 +02:00
## Finishing installation
2022-12-16 11:50:40 +01:00
2022-05-20 21:26:28 +02:00
`exit`
`poweroff`
2022-12-16 11:50:40 +01:00
Remove the installation cd
2022-05-20 21:26:28 +02:00
## (Snapper) Setup
2022-12-16 11:50:40 +01:00
`# umount /.snapshots`
`# rm -r /.snapshots`
2022-05-20 21:26:28 +02:00
Create snapper config
2022-12-16 11:50:40 +01:00
`# snapper -c root create-config /`
2022-05-20 21:26:28 +02:00
Delete unneeded volume
2022-12-16 11:50:40 +01:00
`# btrfs subv del /.snapshots/`
2022-05-20 21:26:28 +02:00
2022-12-16 11:50:40 +01:00
`# mkdir /.snapshots`
2022-05-20 21:26:28 +02:00
Mount snapshots volume
2022-12-16 11:50:40 +01:00
`# mount -a`
2022-05-20 21:26:28 +02:00
2022-12-16 11:50:40 +01:00
`# chmod 750 /.snapshots`
2022-05-20 21:26:28 +02:00
2022-12-16 11:50:40 +01:00
`# vim /etc/snapper/configs/root`
2022-05-20 21:26:28 +02:00
Change these things:
2022-12-16 11:50:40 +01:00
`ALLOW_USERS="(user)"`
2022-05-20 21:26:28 +02:00
```
TIMELINE_LIMIT_HOURLY="5"
TIMELINE_LIMIT_DAILY="7"
2023-11-17 14:42:26 +01:00
TIMELINE_LIMIT_WEEKLY="4"
2022-05-20 21:26:28 +02:00
TIMELINE_LIMIT_MONTHLY="0"
TIMELINE_LIMIT_YEARLY="0"
```
Enable snapper
`# systemctl enable --now snapper-timeline.timer`
2022-12-16 11:50:40 +01:00
`# systemctl enable --now snapper-cleanup.timer`
2022-05-20 21:26:28 +02:00
Allow user to access snapshots
`# chmod a+rx /.snapshots`
2022-12-16 11:50:40 +01:00
`# chown :(user) /.snapshots`
2022-05-20 21:26:28 +02:00
## Install AUR helper
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
### paru
[shuser]
2022-12-16 11:50:40 +01:00
2023-11-17 14:42:26 +01:00
```
cd $(mktemp -d)
git clone https://aur.archlinux.org/paru-bin.git
cd paru-bin
2022-05-20 21:26:28 +02:00
makepkg -si
```
2023-11-17 14:42:26 +01:00
[/shuser]
## Automatic snapshots on package changes
[shroot]
2022-12-16 11:50:40 +01:00
2022-05-20 21:26:28 +02:00
```
2023-11-17 14:42:26 +01:00
pacman -S snap-pac
```
[/shroot]
## (rEFInd) Show snapshots in bootmenu
2024-06-25 17:07:40 +02:00
This requires a manual boot entry definition in `/boot/EFI/refind/refind.conf` as shown in [Manual boot stanza ](#manual-boot-stanza )
2022-05-20 21:26:28 +02:00
2024-05-28 18:42:48 +02:00
`paru -S refind-btrfs`
2022-12-16 11:50:40 +01:00
2024-06-25 17:07:40 +02:00
In `/etc/refind-btrfs.conf` , embed the btrfs logo.
```
...
[boot-stanza-generation.icon]
mode = "embed_btrfs_logo"
...
```
Use the inverted logo for darker themes such as Nord.
```
...
[boot-stanza-generation.icon.btrfs-logo]
variant = "inverted"
...
```
2023-11-17 14:42:26 +01:00
`systemctl enable --now refind-btrfs.service`
2024-05-28 18:42:48 +02:00
2024-06-25 17:07:40 +02:00
**NOTE:** this doesn't work yet, as the UUID naming scheme is not supported by refind-btrfs.
See [issue 46 ](https://github.com/Venom1991/refind-btrfs/issues/46 ) for details.