Skip to content

Instantly share code, notes, and snippets.

@saikocat
Last active October 12, 2024 01:15
Show Gist options
  • Save saikocat/b3490e4d074921575b6fdc842f3a1726 to your computer and use it in GitHub Desktop.
Save saikocat/b3490e4d074921575b6fdc842f3a1726 to your computer and use it in GitHub Desktop.
arch-chroot recover lvm for mid upgrade run out of space

After performing a reboot, when the system kernel upgrade failed due to no disk space left (hence initramfs failed to regenerate)

Failed to execute /init (error -8)
Starting init: /sbin/init exists but couldn't execute it (error -8)
Starting init: /bin/init exists but couldn't execute it (error -8)

Mounting for chroot environment

$ fdisk -lu

Device           Start       End   Sectors   Size Type
/dev/nvme0n1p1    2048   1128447   1126400   550M EFI System
/dev/nvme0n1p2 1128448 976773134 975644687 465.2G Linux LVM
...
other LVM info here

Scan LVM volume and activate them

$ pvscan
$ vgscan
$ vgchange -a y
$ lvscan

Mount needed mountpoints

mount /dev/arch-vg/root-lv /mnt
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

For boot and efi mount point, see fdisk -l result above. DO NOT MOUNT BOOT & EFI BLINDLY. Check /etc/fstab if unsure after mounting root

# /dev/nvme0n1p1
UUID=39BC-E40F          /boot           vfat ...

Then finally mount boot + efi

mount /dev/nvme0n1p1 /mnt/boot
# mount /xxx/xxx /mnt/boot/efi | EFI  depending on yoursystem if needed

Final enter chroot to perform repair

arch-chroot /mnt

Exit and Unmount before reboot

exit
umount -R /mnt

Reinstall

pacman -Qqn | pacman -S -

Offline mode

pacman --root /mnt --cachedir=/mnt/var/cache/pacman/pkg -S $(pacman --root /mnt -Qqn $(pacman --root /mnt -Qoq /mnt/usr))

Troubleshooting

chroot: failed to run command 'usr/bin/zsh': No such file or directory

Either zsh is not installed, or system package was in weird state. Can perform pacman --sysroot /mnt -S zsh etc... to repair / install extra packages.

pacman -Qkk

To see corrupted files from pacman

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