archlinux-installation-standard
My standards of install Arch Linux.
Pre-installation
-
Update the system clock
1
timedatectl set-ntp true
-
Preparing the partitions
Partition layout:
1
2
3
4
5
6
7
8
9
10+-----------------------+------------------------+
| Boot partition | LUKS2 encrypted system |
| | partition |
| | |
| /boot | / |
| | |
| | /dev/mapper/cryptroot |
|-----------------------|------------------------|
| /dev/sda1 | /dev/sda2 |
+-----------------------+------------------------+Preparing non-boot partitions
1
2
3
4
5cryptsetup -y -v --pbkdf-memory=114514 luksFormat /dev/sda2
cryptsetup open /dev/sda2 cryptroot
cryptsetup --allow-discards --perf-no_read_workqueue --perf-no_write_workqueue --persistent refresh cryptroot
mkfs.btrfs -L arch_os /dev/mapper/cryptroot
mount /dev/mapper/cryptroot /mntYou can set the filesystem label later by using
btrfs filesystem label /dev/mapper/cryptroot "arch_os"
Preparing the boot partition
1
mkfs.fat -F32 /dev/sda1
Btrfs subvolumes
- Create top-level subvolumes
1
2
3
4btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@snapshots
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@var_log - Mount top-level subvolumes
Unmount the system partition at /mnt.Now mount the newly created subvolumes by using the1
umount /mnt
subvol=
mount option (with enabled compresszstd
).1
2
3
4
5
6mount -o compress=zstd,subvol=@,discard=async /dev/mapper/cryptroot /mnt
mkdir -p /mnt/{boot,home,.snapshots,var/log}
mount -o discard /dev/sda1 /mnt/boot
mount -o compress=zstd,subvol=@home,discard=async /dev/mapper/cryptroot /mnt/home
mount -o compress=zstd,subvol=@snapshots,discard=async /dev/mapper/cryptroot /mnt/.snapshots
mount -o compress=zstd,subvol=@var_log,discard=async /dev/mapper/cryptroot /mnt/var/log - Create nested subvolumes
Create any nested subvolumes you do not want to have snapshots when taking a snapshot of/
.
Every nested subvolume will be an empty directory inside the snapshot.1
2
3mkdir -p /mnt/var/cache/pacman
btrfs subvolume create /mnt/var/cache/pacman/pkg
btrfs subvolume create /mnt/var/tmp
Installation
- Select mirrors
1
sed -i '1iServer = https://mirrors.cloud.tencent.com/archlinux/$repo/os/$arch' /etc/pacman.d/mirrorlist
Configure the system
1 | arch-chroot /mnt |
Configuring the boot loader
1 | default arch.conf |
AUR helper paru.
1 | mkdir /build |
Reboot to installed system to ensure that systemd is running.
Post-installation
Enable daemons
1 | systemctl enable --now iwd.service |
Enroll TPM key
list installed TPMs and the driver in use:
1 | systemd-cryptenroll --tpm2-device=list |
Binds the key to PCRs 0 and 7 (System firmware and Secure Boot state):
1 | systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/sda2 |
To remove a key enrolled, run:
1 systemd-cryptenroll --wipe-slot=slot_number /dev/sdXwhere
slot_number
is the numeric LUKS slot number in which your TPM key is stored.
Alternatively, run:
1 systemd-cryptenroll --wipe-slot=tpm2 /dev/sdXto remove all TPM-associated keys from your LUKS volume.
Swapfile in a btrfs filesystem and enable hibernation (support dm-crypt)
- Swap file creationAdd appropriate entry in
1
2btrfs filesystem mkswapfile --size 32g --uuid clear /.snapshots/swapfile
swapon /.snapshots/swapfilefstab
:/etc/fstab 1
2...
/.snapshots/swapfile none swap defaults 0 0 - Setting the required kernel parameters
1
2btrfs inspect-internal map-swapfile -r /.snapshots/swapfile
198122980Regenerate UKI:/etc/cmdline.d/root.conf 1
2
3...
resume=/dev/mapper/cryptroot
resume_offset=1981229801
mkinitcpio -P
Tips
-
Run
fc-cache -fv
to rebuild font information cache files. -
Use
blkid
orlsblk -f
to see the persistent block device naming -
Use
ip link
to show network interface names -
Configure memory pressure killing (Here I set it slice wide to make it observable in
oomctl
):shell 1
systemctl edit user.slice
Having this in your editor:
1
2
3[Slice]
ManagedOOMMemoryPressure=kill
ManagedOOMMemoryPressureLimit=50% -
Configure swap-based killing:
1
systemctl edit --force -- -.slice
With this in your edior:
1
2[Slice]
ManagedOOMSwap=kill(Optional) See also oomd.conf(5):
/etc/systemd/oomd.conf 1
2
3[OOM]
SwapUsedLimit=80%
DefaultMemoryPressureDurationSec=20sFurthmore, you can set
OOMPolicy=kill
to a service unit, which says if one of the process belong to this service is being killed by systemd-oomd, the whole service will also get killed (this option sets service’s cgroupmemory.oom.group
to1
, which means all tasks belonging to this cgroup were killed together).
1 | ^[AUR] libva-intel-driver-hybrid intel-hybrid-codec-driver |
archlinux-installation-standard
https://magic0whi.github.io/archlinux-installation-standard/