How to recover a GRUB bootloader on a filesystem with LUKS and LVM

Albert De La Fuente Vigliotti

Recently an upgrade on my notebook went bad and broke something. I wasn’t sure what went wrong but since I had just one system at that time, I had to figure out how to fix it with the help of my phone. Basically what I did is install EtchDroid to be able to download an iso and flash it to a flash drive on my phone directly. Later I could boot form that flash drive, mount the LUKS/LVM partitions and fix the bootloader. Here is a short how to.

(OPTIONAL) Create a boot flash disk using android #

EtchDroid USB writer | F-Droid - Free and Open Source Android App Repository #

Mounting and chrooting the system #

#+begin_src sh

cryptsetup luksOpen /dev/disk/by-partlabel/cryptlvm lvm

mount /dev/storage/root /mnt mount /dev/storage/home /mnt/home

mount /dev/sda1 /mnt/boot

cd mnt mount -t proc /proc proc #mount -t sysfs sys sys #mount -o bind dev dev mount -o bind run run

arch-chroot /mnt

dhcpcd eth0 #+end_src sh

Edit the /etc/default/grub file #

#+begin_src sh

GRUB_CMDLINE_LINUX=“cryptdevice=/dev/sda2:lvm” GRUB_PRELOAD_MODULES=“part_gpt part_msdos cryptodisk luks” #+end_src sh

Config and install GRUB and create the ramdisk #

#+begin_src sh

grub-mkconfig > /boot/grub/grub.cfg grub-install –efi-directory=/boot –target=x86_64-efi /dev/sda

mkinitcpio -p linux #+end_src sh

References #

[SOLVED] Grub with lvm on LUKS -> rescue mode. Incomplete grub.cfg? / Installation / Arch Linux Forums #