4

I found few threads that explain how to reinstall grub2 by the mean of chroot but none of them explain how to proceed if my / is encrypted and if there is a plain /boot partition. Thing is I installed Debian in EFI mode and it made an unbootable entry (Japanese character) in the UEFI boot menu.

I tried to make a new entry using efibootmgr from Ubuntu liveUSB but it is still unbootable. I'd like to reinstall grub from Ubuntu liveUSB but I don't know to chroot the encrypted / partition and how the separate /boot partition blends in.

Thomas W.
  • 480
  • Given your configuration, you might want to try my rEFInd boot manager, which tends to handle multi-distribution configurations better than GRUB. Try downloading the USB flash drive or CD-R version to see if it will boot both Debian and Ubuntu. (You may need to add extra boot options to identify your root filesystem by pressing F2 or Delete twice to boot Ubuntu.) If it works, you can install the PPA from Ubuntu or the Debian package in either Debian or Ubuntu. – Rod Smith Jan 10 '16 at 15:16

2 Answers2

3
  1. Boot from an Ubuntu Live USB with a working internet connection.

  2. Open a Terminal window (ApplicationsAccessoriesTerminal).

  3. Type the following commands (pay attention to the comments, starting with #, after some commands):

    sudo -i
    apt-get update
    apt-get install cryptsetup lvm2
    fdisk -l
    cryptsetup luksOpen /dev/sda? TAG           # sda? is your root partition
    vgchange -ay
    vgscan
    vgchange -ay [VOLUME GROUP NAME]           # From the above command
    lvscan
    mount /dev/[VOLUME GROUP NAME]/[LOGICAL VOLUME NAME] /mnt          # LOGICAL VOLUME NAME from above command
    modprobe efivars
    mount /dev/sda? /mnt/boot/efi          # sda? is your efi partition
    mount --bind /dev /mnt/dev 
    mount --bind /dev/pts /mnt/dev/pts
    mount --bind /proc /mnt/proc
    mount --bind /sys /mnt/sys
    cp /etc/resolv.conf /mnt/etc/
    chroot /mnt
    

    then do

    apt-get install --reinstall grub-efi-amd64
    

    or

    apt-get install --reinstall grub-efi
    

    and continue with

    update-grub
    umount /mnt
    vgchange -an
    cryptsetup luksClose TAG
    
kyodake
  • 15,401
  • One should also check out (https://askubuntu.com/a/831241/321153). I used a combined version of this and the one under link to fix my ubuntu 18.04. – Max Mar 18 '20 at 22:00
  • modprobe efivars fails should it be modprobe efivarfs ? – Pavel Niedoba Aug 09 '23 at 12:56
0

Took me a while getting lost doing this. I have the same setup (non-encrypted /boot in ADDITION to a vfat /boot/efi). The following debian guide nails it. Missing pieces from all other guides were mounting the efivars and just comprehensive steps for grub re-installing etc. Hope this helps!

https://wiki.debian.org/GrubEFIReinstall

Details on the specific parts that were missing from other answers here:

  • include the efivars in the chroot whole installing grub

    for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done

  • don't forget to mount /boot and then also /boot/efi in the chroot

  • run *all the grub commands

    apt-get install --reinstall grub-efi

    grub-install /dev/disk

    update-grub

Thank you debian!!

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Pilot6 Oct 23 '22 at 12:55