Problem with 'grub-mkconfig' in Arch Linux installation: 'grub-mkconfig' fails to connect to lvmetad

I’ve been having a problem with a reinstallation of Arch Linux on a machine that’s dual booted with Windows 10.

For various unrelated reasons, I decided to back up everything in my old Arch Linux installation and start fresh. I have the Arch Linux live media on a USB, so I went ahead and booted from it (in UEFI), formatted my Linux partition and went through the Arch Linux installation guide.

Everything seemed to be working fine until I got to the ‘install bootoloader’ section. I wasn’t 100% sure what to do here, as the beginner’s guide that I used before has been deleted in favor of the (much, much more brief) installation guide.

I know that my EFI partition already had all the GRUB stuff it needed, but I figured it would need to be changed for a new installation.

  • I deleted the /boot/EFI/grub.efi stub, and renamed /boot/grub/ to /boot/grub.bak.
  • I ran
    pacman -S grub os-prober
    

    ran the grub-install command from the arch installation guide with target=x86_64-efi and directory=/boot (my mount point for my EFI partition) and then ran

    grub-mkconfig -o /boot/grub/grub.cfg
    

This is where my trouble started. Running the grub-mkconfig command gave me a ‘failed to connect to lvmetad‘ error, and said it was reverting to fallback mode. It successfully produced a grub.cfg file in the correct directory, however there were no menu entries present.

When I try to boot, all I get is a GRUB command line. Going back into my Arch Linux live media and redoing the arch-chroot, I went into my /boot/grub.bak and copied the menu entry sections for Arch Linux from there, making sure to replace the old UUID with the one currently reported in my fstab for my root directory. This brought the GRUB menu back when I rebooted, but selecting Arch Linux gave me an error that /vmlinux couldn't be found.

I went back into my chroot on the live media, and reran grub-config. Still no menu entries. I found this question with a similar issue that said there was a known problem with the grub-mkconfig helper script. This was from 2014, so I thought it was unlikely that my issue was the same, but I followed the best answer there. The suggestion was to do the following:

ran across the same issue just now, and found another workaround. Basically, it involves making the hosts /run directory available to the guest.

First, we mount /run where it can be accessed by the guest. I will assume that your install partition is mounted at /mnt.

mkdir /mnt/hostrun
mount --bind /run /mnt/hostrun

Then, we chroot into the guest, and mount our host’s /run/lvm in the guest’s /run.

arch-chroot /mnt /bin/bash
mkdir /run/lvm
mount --bind /hostrun/lvm /run/lvm

You can then run grub-mkconfig and grub-install without any LVM errors. This also makes the commands behave if you are installing
with LVM, for what it’s worth.

When done, remember to umount /run/lvm before exiting the chroot.

Doing so actually got rid of my fails to connect to lvmetad error, but replaces it with a /dev/sdx not initialized in UDEV. The command still produces a grub.cfg without menu entries.

I’m able to get into Windows by selecting the Windows Boot Manager from my laptop’s ‘hammer F12 while booting’ menu.

Asked By: Joseph Morgan

||

I had the same problem. This is an old post but I will post my work-around in case it helps someone.

Like yourself, I had a complete backup, including a working grub.cfg file. I extracted the required menu entries from the old grub.cfg file and added them to /etc/grub.d/40_custom. Next I re-ran

grub mkconfig -o /boot/grub/grub.cfg

All is well now.

os-prober is a low priority convenience item and not really essential. Personally I would not spend much time trying to get it to work. It is a personal choice. Some people love trying to troubleshoot this kind of thing and I thank them for their efforts, but others need their systems for real work, have time constraints, and need to get up and running.

Eventually this problem will be fixed either through software or documentation. If you have questions about how to set up menu entries in the 40_custom file, you will find numerous examples through a web search.

Answered By: bhold

The problem appears only because you are in arch-chroot and using os-prober. What solved my case was:

  • Backup current grub.cfg, if you haven’t backed up yet.
  • Remove os-prober (pacman -R os-prober, or you can disable it)
  • Run grub-mkcondig
  • Reboot into Arch
  • Install os-prober
  • Run grub-mkconfig again
Answered By: Ezra Steinmetz
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.