wiki-grav/pages/02.linux/guides/arch/default.en.md

513 lines
7.2 KiB
Markdown
Raw Normal View History

---
title: Arch
visible: true
---
[toc]
2022-12-16 11:50:40 +01:00
2024-05-28 18:44:02 +02:00
Last modified: 2024-05-28
## Keyboard layout
2022-12-16 11:50:40 +01:00
[shroot]
```
loadkeys de_CH-latin1
```
[/shroot]
## 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.
[shroot]
```
ls /sys/firmware/efi/efivars
```
[/shroot]
## Verify internet connection
2022-12-16 11:50:40 +01:00
[shroot]
```
ping wiki.exu.li
```
[/shroot]
## Update system clock
2022-12-16 11:50:40 +01:00
[shroot]
```
timedatectl set-ntp true
```
[/shroot]
## Creating partitions
2022-12-16 11:50:40 +01:00
[shroot]
```
cfdisk
```
[/shroot]
Use `EFI System` for EFI partition
2022-12-16 11:50:40 +01:00
Use `Linux filesystem` for other partitions
## (LUKS) Create encrypted partition
2022-12-16 11:50:40 +01:00
_Note: Do not put your /efi partition on an encrypted partition!_
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.
[shroot]
```
cryptsetup luksFormat --label=(label) /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
Open the partition and specify a name
[shroot]
```
cryptsetup open /dev/(partition) (name)
```
[/shroot]
Check if this worked with `ls /dev/mapper/`
2022-12-16 11:50:40 +01:00
The name should show up there
## Format partitions
2022-12-16 11:50:40 +01:00
2024-05-28 18:42:48 +02:00
### EFI or BIOS partition
Fat 32:
[shroot]
```
mkfs.fat -F32 /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
### Root and other partitions
2024-05-28 18:42:48 +02:00
**Ext4**
[shroot]
```
mkfs.ext4 /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
**Btrfs**
[shroot]
```
mkfs.btrfs /dev/(partition)
```
[/shroot]
2024-05-28 18:42:48 +02:00
**Bcachefs**
[shroot]
```
bcachefs format /dev/(partition)
```
[/shroot]
## Mounting partitions
2022-12-16 11:50:40 +01:00
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.
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
```
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
[shroot]
```
mount /dev/(partition) /mnt
```
[/shroot]
2024-05-28 18:42:48 +02:00
Root subvolume
[shroot]
```
btrfs subv create /mnt/@
```
[/shroot]
2024-05-28 18:42:48 +02:00
Home subvolume
[shroot]
```
btrfs subv create /mnt/@home
```
[/shroot]
2024-05-28 18:42:48 +02:00
Snapshots subvolume for snapper
2022-06-05 15:14:33 +02:00
[shroot]
```
btrfs subv create /mnt/@snapshots
```
[/shroot]
2024-05-28 18:42:48 +02:00
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
2024-05-28 18:42:48 +02:00
`mkdir -p /mnt/{efi,home,.snapshots,var/log}`
With /boot
2024-05-28 18:42:48 +02:00
`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`
2024-05-28 18:42:48 +02:00
Mount var/log
`mount -o noatime,compress-force=zstd,subvol=@var_log /dev/(partition) /mnt/var/log`
2022-12-16 11:50:40 +01:00
**Don't forget mounting other partitions!!**
## Essential packages
2022-12-16 11:50:40 +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.
[shroot]
```
pacstrap /mnt base base-devel linux linux-firmware linux-headers vim git openssh networkmanager dialog
```
[/shroot]
### Microcode
2022-12-16 11:50:40 +01:00
`amd-ucode`
`intel-ucode`
### Filesystems
2022-12-16 11:50:40 +01:00
Fat32:
2022-12-16 11:50:40 +01:00
`dosfstools mtools`
Ext4:
2022-12-16 11:50:40 +01:00
`e2fsprogs`
Btrfs:
2022-12-16 11:50:40 +01:00
`btrfs-progs compsize`
### Wifi
2022-12-16 11:50:40 +01:00
`wpa_supplicant`
### Snapper
2022-12-16 11:50:40 +01:00
`snapper`
### Certificates
2022-12-16 11:50:40 +01:00
`ca-certificates ca-certificates-mozilla`
### other
2022-12-16 11:50:40 +01:00
`cups hplip xdg-utils xdg-user-dirs inetutils`
## Generate fstab
2022-12-16 11:50:40 +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**
## Chroot into the system
2022-12-16 11:50:40 +01:00
[shroot]
```
arch-chroot /mnt
```
[/shroot]
## Set timezone
2022-12-16 11:50:40 +01:00
`ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime`
## Set hardware clock
2022-12-16 11:50:40 +01:00
`hwclock --systohc`
## Set locale
2022-12-16 11:50:40 +01: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-12-16 11:50:40 +01:00
`locale-gen`
2022-12-16 11:50:40 +01:00
`echo "LANG=de_CH.UTF-8" > /etc/locale.conf`
## Set keymap permanently
2022-12-16 11:50:40 +01:00
`echo "KEYMAP=de_CH-latin1" > /etc/vconsole.conf`
## Set hostname
2022-12-16 11:50:40 +01:00
`echo "(hostname)" > /etc/hostname`
Edit `/etc/hosts`
```
127.0.0.1 localhost (hostname)
::1 localhost
```
## Change root password
2022-12-16 11:50:40 +01:00
[shroot]
2022-12-16 11:50:40 +01:00
```
passwd
```
[/shroot]
## Bootloader installation
### rEFInd
[shroot]
```
pacman -S refind
```
[/shroot]
2024-05-28 18:42:48 +02:00
Use the rEFInd installation script. In most cases no specific configuration is necessary
[shroot]
```
refind-install
```
[/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**
_TODO insert config here_
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=@"
```
2024-05-28 18:42:48 +02:00
### GRUB
2024-05-28 18:42:48 +02:00
[shroot]
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
```
2024-05-28 18:42:48 +02:00
[/shroot]
### (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
[shroot]
```
mkinitcpio -P
```
[/shroot]
## Networking
2022-12-16 11:50:40 +01:00
`systemctl enable NetworkManager`
## (CUPS) Printing
2022-12-16 11:50:40 +01:00
`systemctl enable cups`
## Add user
2022-12-16 11:50:40 +01:00
`useradd -mG wheel (user)`
Set password
2022-12-16 11:50:40 +01:00
`passwd (user)`
### Enable sudo
2022-12-16 11:50:40 +01:00
`visudo`
2022-12-16 11:50:40 +01:00
Uncomment `%wheel ALL=(ALL) ALL`
## Finishing installation
2022-12-16 11:50:40 +01:00
`exit`
`poweroff`
2022-12-16 11:50:40 +01:00
Remove the installation cd
## (Snapper) Setup
2022-12-16 11:50:40 +01:00
`# umount /.snapshots`
`# rm -r /.snapshots`
Create snapper config
2022-12-16 11:50:40 +01:00
`# snapper -c root create-config /`
Delete unneeded volume
2022-12-16 11:50:40 +01:00
`# btrfs subv del /.snapshots/`
2022-12-16 11:50:40 +01:00
`# mkdir /.snapshots`
Mount snapshots volume
2022-12-16 11:50:40 +01:00
`# mount -a`
2022-12-16 11:50:40 +01:00
`# chmod 750 /.snapshots`
2022-12-16 11:50:40 +01:00
`# vim /etc/snapper/configs/root`
Change these things:
2022-12-16 11:50:40 +01:00
`ALLOW_USERS="(user)"`
```
TIMELINE_LIMIT_HOURLY="5"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_WEEKLY="4"
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`
Allow user to access snapshots
`# chmod a+rx /.snapshots`
2022-12-16 11:50:40 +01:00
`# chown :(user) /.snapshots`
## Install AUR helper
2022-12-16 11:50:40 +01:00
### paru
[shuser]
2022-12-16 11:50:40 +01:00
```
cd $(mktemp -d)
git clone https://aur.archlinux.org/paru-bin.git
cd paru-bin
makepkg -si
```
[/shuser]
## Automatic snapshots on package changes
[shroot]
2022-12-16 11:50:40 +01:00
```
pacman -S snap-pac
```
[/shroot]
## (rEFInd) Show snapshots in bootmenu
_WIP_
2024-05-28 18:42:48 +02:00
`paru -S refind-btrfs`
2022-12-16 11:50:40 +01:00
`systemctl enable --now refind-btrfs.service`
2024-05-28 18:42:48 +02:00
TODO config