Skip to content
Andrei Pozolotin edited this page Apr 26, 2020 · 17 revisions

How to re-build initramfs after an mkinitcpio configuration error resulted in a broken boot?

Approach

  • unlock crypto root disk and bring system up inside systemd-nspawn container, then re-build

  • use only systemd-nspawn: non-systemd containers, such as chroot are not supported

Assumptions

   /dev/sda1 -> /boot
   /dev/sda2 -> [swap]
   /dev/sda3 -> [luks root]

Recovery Steps

  • boot into archiso usb disk as host

  • review soon-to-be-container disk layout

lsblk
NAME     MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda        8:0    0 232.9G  0 disk  
├─sda1     8:1    0   499M  0 part  
├─sda2     8:2    0   4.9G  0 part  
└─sda3     8:3    0 227.5G  0 part  
  • unlock root partition form archiso host
cryptsetup luksOpen /dev/sda3 root
  • prepare boot and root mounts for the container
mkdir -p /mnt/{boot,root}
mount /dev/sda1 /mnt/boot
mount /dev/mapper/root /mnt/root
systemd-nspawn --boot --bind=/mnt/boot:/boot --directory=/mnt/root

mkinitcpio Rebuild Steps