Aller au contenu
  1. Tutorials/

installer Arch Linux (intégralement chiffré)

·3 mins
  • ! Sans LVM
  • LUKS2
  • Déverrouillage automatique via TPM2
  • Secure Boot activé
  • UEFI + systemd + systemd-boot
  • Root chiffrée, swap chiffrée

Hypothèses techniques #

  • Démarrage UEFI uniquement
  • Firmware avec TPM 2.0 activé
  • Secure Boot en mode Setup (clés non encore installées)
  • Disque : /dev/nvme0n1
  • Système simple : / + swap + /boot

1) Partitionnement GPT (UEFI) #

Schéma :

PartitionTailleTypeUsage
p11 GiBEFI/boot
p2resteLinuxLUKS2 (/)
p316 GiBLinuxswap chiffré
sgdisk --zap-all /dev/nvme0n1

sgdisk -n1:0:+1G   -t1:ef00 -c1:EFI  /dev/nvme0n1
sgdisk -n2:0:-16G  -t2:8300 -c2:ROOT /dev/nvme0n1
sgdisk -n3:0:0     -t3:8300 -c3:SWAP /dev/nvme0n1

partprobe /dev/nvme0n1

2) Chiffrement LUKS2 (racine) #

Choix sûrs (AES-XTS, SHA-256, PBKDF Argon2id).

cryptsetup luksFormat \
  --type luks2 \
  --cipher aes-xts-plain64 \
  --key-size 512 \
  --hash sha256 \
  --pbkdf argon2id \
  /dev/nvme0n1p2

cryptsetup open /dev/nvme0n1p2 racine

3) Chiffrement swap (clé volatile) #

Le swap est chiffré sans passphrase, clé aléatoire à chaque boot.

cryptsetup open \
  --type plain \
  --key-file /dev/urandom \
  /dev/nvme0n1p3 swap

4) Systèmes de fichiers #

mkfs.fat -F32 /dev/nvme0n1p1
mkfs.ext4 /dev/mapper/racine
mkswap /dev/mapper/swap

5) Montage #

mount /dev/mapper/racine /mnt

mkdir /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot

swapon /dev/mapper/swap

6) Installation Arch #

pacstrap -K /mnt \
  base linux linux-firmware \
  systemd systemd-boot \
  cryptsetup \
  sbctl \
  tpm2-tools \
  efibootmgr

genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt

7) Initramfs (mkinitcpio) #

Objectif :

  • déchiffrement LUKS via systemd
  • support TPM2
  • aucun fallback initramfs inutile
sed -i 's/^HOOKS=.*/HOOKS=(base systemd autodetect modconf block sd-encrypt filesystems keyboard fsck)/' /etc/mkinitcpio.conf
mkinitcpio -P

8) Récupération UUID #

UUID_LUKS=$(blkid -s UUID -o value /dev/nvme0n1p2)
echo "$UUID_LUKS"

9) Configuration systemd-boot #

bootctl install

loader.conf #

cat > /boot/loader/loader.conf <<EOF
default arch
timeout 3
editor no
console-mode max
EOF

entrée noyau #

cat > /boot/loader/entries/arch.conf <<EOF
title Arch Linux (LUKS + TPM2)
linux /vmlinuz-linux
initrd /initramfs-linux.img
options rd.luks.name=$UUID_LUKS=racine root=/dev/mapper/racine rw
EOF

10) crypttab #

cat > /etc/crypttab <<EOF
racine UUID=$UUID_LUKS - tpm2-device=auto
swap   /dev/nvme0n1p3 /dev/urandom swap,cipher=aes-xts-plain64,size=256
EOF

11) Enrôlement TPM2 (clé scellée) #

Déverrouillage automatique lié à l’état Secure Boot + PCR.

systemd-cryptenroll \
  --tpm2-device=auto \
  --tpm2-pcrs=0+2+7 \
  /dev/nvme0n1p2

PCR utilisés :

  • 0 firmware
  • 2 option ROM
  • 7 Secure Boot state

12) Secure Boot (sbctl) #

Création et installation des clés #

sbctl create-keys
sbctl enroll-keys --microsoft

Signature des binaires EFI #

sbctl sign -s /boot/vmlinuz-linux
sbctl sign -s /boot/EFI/systemd/systemd-bootx64.efi

Vérification #

sbctl verify

13) Services système #

systemctl enable systemd-boot-update
systemctl enable systemd-networkd
systemctl enable systemd-resolved

14) Finalisation #

passwd
exit
umount -R /mnt
reboot

Résultat final #

Sécurité #
  • Données totalement chiffrées
  • Clé liée au TPM
  • Secure Boot empêche tout boot non signé
  • Aucun mot de passe demandé au boot (sauf changement PCR)
Schéma disque #
nvme0n1
 ├─p1 EFI        → /boot
 ├─p2 LUKS2      → /
 │   └─racine
 └─p3 swap       → swap (clé volatile)

Comportement au boot #

ÉtatRésultat
Boot normalDéverrouillage automatique
Bootloader modifiéRefus TPM
Noyau non signéBlocage Secure Boot
TPM réinitialiséDemande passphrase