Skip to content

Instantly share code, notes, and snippets.

@4lgn
Last active December 20, 2022 17:49
Show Gist options
  • Save 4lgn/16e4eb7e03673703df606d86da6a7b55 to your computer and use it in GitHub Desktop.
Save 4lgn/16e4eb7e03673703df606d86da6a7b55 to your computer and use it in GitHub Desktop.
Rescuing a broken Arch system

Boot into Live installation medium

  1. Grab a USB and download the Arch ISO
  2. Use balenaEtcher and flash the ISO to the stick
  3. Boot onto stick

Access file system

Firstly, check if you have internet real quick ping 8.8.8.8

If not, I would recommend using iwctl, and follow this for Wi-Fi.

Use lsblk or fdisk -l and find your file system mounts, can have a root, home and an EFI, find 'em all.

Mount the system mount /dev/xxx1 /mnt, ... /mnt/home, ... ... /mnt/boot (or ... /mnt/efi)

Chroot into your system arch-chroot /mnt

In case you can't remember whether you originally mounted to /mnt/efi or /mnt/boot, you can double-check your fstab cat /etc/fstab.

Repair!

Cool, now you have your files safe again, and it's time to be a detective.

Keyring problems?

Try refreshing keys: pacman-key --refresh-keys

Try re-installing archlinux-keyring: pacman -S archlinux-keyring

If something is really wrong with your keyring you might wanna hard-reset it (back up in-case something goes wrong):

mv /etc/pacman.d/gnupg /.../gnupg_backup
mv /root/.gnupg /.../gnupg_root_backup
gpg --refresh-keys
pacman-key --init
pacman-key --populate
pacman-key --refresh-keys

Pacman problems?

Check logs for broken packages: /var/log/pacman.log

Closed pacman rudely? Delete /var/lib/pacman/db.lck manually

Broken boot/kernel stuff?

In some cases the initramfs can become corrupted. Run mkinitcpio -p linux to rebuild it

In case of not being able to find vmlinuz-linux for example, check your /boot /efi and see if it's there.

Keep in mind the default for mkinitcpio is to save under /boot, if you had saved your ESP on /efi when installing, do keep in mind NOT to mount your ESP to /boot when chrooting in, as that would essentially make mkinitcpio save the files to what is effectively mapped to /efi. Check your fstabs for this: cat /etc/fstab. In this case, just mount your ESP to the correct place as in your fstab and re-run building the kernel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment