--- title: Arch visible: true --- [toc] Last modified: 2024-06-01 ## Keyboard layout [shroot] ``` loadkeys de_CH-latin1 ``` [/shroot] ## Check UEFI mode If the following command works, the system is booted in EFI. [shroot] ``` ls /sys/firmware/efi/efivars ``` [/shroot] ## Verify internet connection [shroot] ``` ping wiki.exu.li ``` [/shroot] ## Update system clock [shroot] ``` timedatectl set-ntp true ``` [/shroot] ## Creating partitions [shroot] ``` cfdisk ``` [/shroot] Use `EFI System` for EFI partition Use `Linux filesystem` for other partitions ## (LUKS) Create encrypted partition _Note: Do not put your /efi partition on an encrypted partition!_ Create encrypted Partition with a label. This label will later be used to identified the bootdevice as a simpler alternative to UUIDs. [shroot] ``` cryptsetup luksFormat --label=(label)disk /dev/(partition) ``` [/shroot] Open the partition and specify a name [shroot] ``` cryptsetup open /dev/(partition) (name)mapper ``` [/shroot] Check if this worked with `ls /dev/mapper/` The name should show up there ## Format partitions ### EFI or BIOS partition Fat 32: [shroot] ``` mkfs.fat -F32 /dev/(partition) ``` [/shroot] ### Root and other partitions **Ext4** [shroot] ``` mkfs.ext4 /dev/(partition) ``` [/shroot] **Btrfs** [shroot] ``` mkfs.btrfs /dev/(partition) ``` [/shroot] **Bcachefs** [shroot] ``` bcachefs format /dev/(partition) ``` [/shroot] ## Mounting partitions Generally partitions have to be mounted where you will later use them in your system. 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. 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 ``` Root: /mnt EFI: /mnt/efi or /mnt/boot Home: /mnt/home etc... ``` ### (BTRFS) Btrfs preparation of subvolumes and mounting Mount root partition [shroot] ``` mount /dev/(partition) /mnt ``` [/shroot] Root subvolume [shroot] ``` btrfs subv create /mnt/@ ``` [/shroot] Home subvolume [shroot] ``` btrfs subv create /mnt/@home ``` [/shroot] Snapshots subvolume for snapper [shroot] ``` btrfs subv create /mnt/@snapshots ``` [/shroot] Var subvolume [shroot] ``` btrfs subv create /mnt/@var_log ``` [/shroot] [shroot] ``` umount /mnt ``` [/shroot] Mount root `mount -o noatime,compress-force=zstd,subvol=@ /dev/(partition) /mnt` With /efi `mkdir -p /mnt/{efi,home,.snapshots,var/log}` With /boot `mkdir -p /mnt/{boot,home,.snapshots,var/log}` Mount home `mount -o noatime,compress-force=zstd,subvol=@home /dev/(partition) /mnt/home` Mount snapshots for snapper `mount -o noatime,compress-force=zstd,subvol=@snapshots /dev/(partition) /mnt/.snapshots` Mount var/log `mount -o noatime,compress-force=zstd,subvol=@var_log /dev/(partition) /mnt/var/log` **Don't forget mounting other partitions!!** ## Essential packages Install a few essential packages using `pacstrap`. Additional packages might also be necessary, see the list below. [shroot] ``` pacstrap /mnt base base-devel linux linux-firmware linux-headers vim git openssh networkmanager dialog ``` [/shroot] ### Other packages | Package | Category | Component | | ------------------------- | ------------- | ------------ | | `amd-ucode` | CPU microcode | | `intel-ucode` | CPU microcode | | `dosfstools` | Filesystems | Fat32 | | `mtools` | Filesystems | Fat32 | | `e2fsprogs` | Filesystems | Ext4 | | `btrfs-progs` | Filesystems | Btrfs | | `compsize` | Filesystems | Btrfs | | `wpa_supplicant` | Wifi | | `snapper` | System | Snapshots | | `ca-certificates` | System | Certificates | | `ca-certificates-mozilla` | System | Certificates | | `zram-generator` | System | Zram | | `cups` | Printing | General | | `hplip` | Printing | HP | | `xdg-utils` | System | Defaults | | `xdg-user-dirs` | System | Defaults | | `inetutils` | Tools | Networking | ## Generate fstab [shroot] ``` genfstab -U /mnt >> /mnt/etc/fstab ``` [/shroot] **Make sure the fstab file has everything included** ## Chroot into the system [shroot] ``` arch-chroot /mnt ``` [/shroot] ## Set timezone `ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime` ## Set hardware clock `hwclock --systohc` ## Set locale `vim /etc/locale.gen` Uncomment the locales that should be generated. Make sure to use a UTF-8 entry. `locale-gen` `echo "LANG=de_CH.UTF-8" > /etc/locale.conf` ## Set keymap permanently `echo "KEYMAP=de_CH-latin1" > /etc/vconsole.conf` ## Set hostname `echo "(hostname)" > /etc/hostname` Edit `/etc/hosts` ``` 127.0.0.1 localhost (hostname) ::1 localhost ``` ## Change root password [shroot] ``` passwd ``` [/shroot] ## Configure zram Create the file `/etc/systemd/zram-generator.conf` ```systemd [zram0] zram-size = ram / 2 compression-algorithm = zstd ``` ## Bootloader installation ### rEFInd [shroot] ``` pacman -S refind ``` [/shroot] Use the rEFInd installation script. In most cases no specific configuration is necessary [shroot] ``` refind-install ``` [/shroot] **Manual editing of the generated configuration file is necessary when installing rEFInd from the Arch boot ISO** #### Autodetection `/boot/refind_linux.conf` With LUKS: ``` "Boot with standard options" "rw loglevel=3 quiet cryptdevice=LABEL=