FS#18734 - [grub2] grub-probe fails to detect LVM device for /boot/grub

Attached to Project: Arch Linux
Opened by Mikhail Vorozhtsov (mvorozhtsov) - Thursday, 18 March 2010, 07:54 GMT
Last edited by Tobias Powalowski (tpowa) - Monday, 12 July 2010, 18:45 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Ronald van Haren (pressh)
Architecture All
Severity Critical
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 8
Private No

Details

Description:

I'm using grub-1.98-4, kernel26-2.6.33.1-1 and udev-151-3.
grub-install fails due to grub-probe error:

# grub-probe -t device /boot/grub
grub-probe: error: cannot find a device for /boot/grub (is /dev mounted?).
# mount | grep boot
/dev/mapper/WS-boot on /boot type ext3 (rw)

The problem is that LVM devices in my /dev/mapper are just symlinks to /dev/dm-N
(this is not the case for at least 2.6.30 from 2009.08 livecd, which I successfully used for chroot+grub-install)
# ls -l /dev/mapper/WS-boot
lrwxrwxrwx 1 root root 7 Mar 18 12:40 /dev/mapper/WS-boot -> ../dm-4
and grub-probe ignores both symlinks and dm-N (see util/getroot.c:find_root_device)

Attached patch fixes the problem by treating symlinks in /dev/mapper as regular device nodes.
This task depends upon

Closed by  Tobias Powalowski (tpowa)
Monday, 12 July 2010, 18:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  fixed 1.98-5
Comment by Tobias Powalowski (tpowa) - Friday, 19 March 2010, 06:47 GMT
where did you got that patch?
Comment by Mikhail Vorozhtsov (mvorozhtsov) - Friday, 19 March 2010, 06:54 GMT
I wrote it myself.
Comment by Mario Vazquez (darkcoder) - Thursday, 01 April 2010, 07:41 GMT
This may sound not related, but do you use the old /dev/sdx or the UUID (/dev/disk/by-uuid/xxx) in grub2?

Mikhail, if your grub2 use uuid (which is the default), switch back to the old /dev/sdx, and test again. If you use grub-mkconfig to generate grub.conf, then uncomment #GRUB_DISABLE_LINUX_UUID=true in /etc/default/grub to enable old sdx device naming, and recreate your config again.

Why this suggestion?
Debian (and Ubuntu) have a patch that fixes a problem when using UUID devices and LVM. The patch make some changes to the code in grub.d/10_linux

01_uuids_and_lvm_dont_play_along_nicely.diff
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index c2da413..cbd9d6b 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -36,7 +36,8 @@ case ${GRUB_DEVICE} in
esac

if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
- || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then
+ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
+ || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}

While I can't test if the patch fixes the issue, at least it patches without problems against the other patches used in this package, as long if its invoked after the archlinux-fixes patch.
Comment by Mikhail Vorozhtsov (mvorozhtsov) - Thursday, 01 April 2010, 10:44 GMT
No, I don't use grub-mkconfig. My config is (it's LVM-over-Software-RAID):

menuentry "Arch Linux" {
insmod mdraid
insmod lvm
insmod ext2
set root=(WS-boot)
linux /vmlinuz26 root=/dev/mapper/WS-root ro quiet
initrd /kernel26.img
}

The actual command I use to install is 'grub-install /dev/sda' (/dev/sda is part of /dev/md0 which is the physical volume of my LVM configuration).
Comment by Mikhail Vorozhtsov (mvorozhtsov) - Thursday, 01 April 2010, 10:49 GMT
Sorry, /dev/md0 is built on /dev/sda1, not /dev/sda.
Comment by Walter Sullivan (wajasu) - Saturday, 03 April 2010, 18:26 GMT
I had this problem using tpows's archboot, where it segfaulted at the end, trying to install grub2. Since most of the grub2 apps (grub-install, grub-mkconfig, grub-install, grub-setup) use grub-probe, the installer segfaulted when running the installl bootloader option. And in my case i was setting up the same thing as Mikhail(above). I added the lvm-detection.patch and it made the segfault go away and i was able to install grub2 with /boot in lvm.

The segfault was in a grub_util_get_dev_abstraction routine's strncpy call. But the patch allowed a device to be found, thus this segfault bug was averted. (grub2 upstream bug?).

The problem was related to the introduction of symlinks in /dev/mapper to point to /dev/dm-0 devices, which changed over time by the kernel/udev folks. It seems at this point in time, the grub2 folks might have not fully dealt with this yet. There is a lot of logic to ignore certain files (symlinks, etc) and intelligently find a root device. Grub2 ignores the symlink, thus the lvm-detection patch, to discern /dev/mapper links and not ignore them. [kind of confused as to the intent for this inthe grub logic]

TODO: I need to see if installing to /dev/dm-0 is broken with this though, as someone on the #grub channel said would be the case.

Comment by Dave (zosodk69) - Monday, 19 April 2010, 14:33 GMT
I can confirm that the above patch (lvm-detection.patch) resolves my issue.

/ and /boot are both logical volumes on my system. Previous to installing the above patch, Ie had to boot to 2009.08 in order to run grub-mkconfig, else I was plagued with /sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).

I ran the patch against grub2-1.98-4 as the last patch applied (after hidden-timeout-fix.patch).
Comment by Karol Babioch (johnpatcher) - Sunday, 16 May 2010, 02:55 GMT
I can also confirm that the patch attached above worked for me. I've also have some logical devices (encrypted lvm) and they won't get recognized without the patch.
Comment by Linus (linus) - Saturday, 22 May 2010, 17:52 GMT
Can you give me some more detailed instructions to get grub2 working? I could apply the patch but can't build grub. Did you use make install or grub-mkimage? Even better would be an AUR grub 1.98 package with efi support. Thanks
Comment by Mikhail Vorozhtsov (mvorozhtsov) - Sunday, 23 May 2010, 07:23 GMT
Download files from http://repos.archlinux.org/wsvn/packages/grub2/trunk/, put the patch into the same directory, and replace the PKGBUILD with http://aur.pastebin.com/dfvfTCCz
I've never built/used grub-efi, I guess you just need to add --with-platform=efi to the configure flags.
$ makepkg -s -f
# pacman -U <package.file>
Then edit/replace /boot/grub/grub.cfg (installer should generate /boot/grub/grub.cfg.example via grub-mkconfig).
# grub-install <device>
Comment by MkFly (MkFly) - Friday, 28 May 2010, 17:35 GMT
I can confirm that the patch [lvm-detection.patch; md5sum: e8f6abf04cea836fd87c2132538b1503] worked here for an LVM on top of a LUKS partition.
Comment by Tobias Powalowski (tpowa) - Sunday, 30 May 2010, 08:00 GMT
grub2 supports luks? i'm surprised, it is bootable even if grub2 cannot unlock it?
Comment by Chris Mann (chpln) - Monday, 28 June 2010, 10:51 GMT
The patch resolves the issue for me, using an LVM over software RAID configuration similar to Mikhail's.
Comment by Colin Watson (cjwatson) - Monday, 12 July 2010, 17:33 GMT
I fixed this upstream some time ago. You can upgrade to a current snapshot, or backport the patch.

2010-05-28 Colin Watson <cjwatson@ubuntu.com>

Make grub-probe work with symbolic links under /dev/mapper as well
as with real block devices. The Linux world seems to be (at best)
in transition here, and GRUB shouldn't get caught in the middle.

* kern/emu/getroot.c (find_root_device): Follow symbolic links under
/dev/mapper.

Loading...