Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 522428 - =sys-boot/grub-2.02_beta2: grub-probe/grub-mkconfig problems
Summary: =sys-boot/grub-2.02_beta2: grub-probe/grub-mkconfig problems
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Mike Gilbert
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 522314
  Show dependency tree
 
Reported: 2014-09-09 10:33 UTC by Coacher
Modified: 2014-09-10 21:04 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info grub (info,5.16 KB, text/plain)
2014-09-09 10:35 UTC, Coacher
Details
/etc/default/grub (grub,2.03 KB, text/plain)
2014-09-09 10:36 UTC, Coacher
Details
floppym's /etc/default/grub (grub,1.90 KB, text/plain)
2014-09-09 18:50 UTC, Mike Gilbert
Details
grub2-probe: fix -0 option (0002-Fix-grub-probe-0-option.patch,1.13 KB, text/plain)
2014-09-09 21:22 UTC, Coacher
Details
grub2-probe: trailing spaces fix (0003-Fix-partmap-cryptodisk-and-abstraction-handling-in-g.patch,9.78 KB, patch)
2014-09-09 21:22 UTC, Coacher
Details | Diff
grub2-mkconfig: fix typo (0001-Fix-typo-gettext_print-instead-of-gettext_printf.patch,574 bytes, patch)
2014-09-09 21:24 UTC, Coacher
Details | Diff
grub2-probe: fix -0 option (0002-Fix-grub-probe-0-option.patch,1.12 KB, patch)
2014-09-09 21:43 UTC, Coacher
Details | Diff
grub2-probe: trailing spaces fix (0003-Fix-partmap-cryptodisk-and-abstraction-handling-in-grub-mkconfig.patch,9.77 KB, patch)
2014-09-09 21:44 UTC, Coacher
Details | Diff
grub2-mkconfig: fix typo (0001-Fix-typo-gettext_print-instead-of-gettext_printf.patch,566 bytes, patch)
2014-09-09 21:45 UTC, Coacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Coacher 2014-09-09 10:33:46 UTC
Hello.

I have in my /etc/default/grub file the following line:
GRUB_PRELOAD_MODULES="lvm diskfilter raid5rec mdraid1x part_gpt ext2"

With sys-boot/grub-2.00_p5107-r2 the resulting grub.cfg had these lines:
        insmod part_gpt
        insmod part_gpt
        insmod part_gpt
        insmod part_gpt
        insmod diskfilter
        insmod mdraid1x
        insmod ext2

With sys-boot/grub-2.02_beta2 I get these lines instead:
        insmod part_gpt gpt gpt gpt
        insmod diskfilter mdraid1x
        insmod ext2

There is no such module as "gpt" and also there is an extra trailing space in the end of "insmod part_gpt gpt gpt gpt" line.

Reproducible: Always
Comment 1 Coacher 2014-09-09 10:35:17 UTC
Created attachment 384450 [details]
emerge --info grub
Comment 2 Coacher 2014-09-09 10:36:21 UTC
Created attachment 384452 [details]
/etc/default/grub

Example grub config
Comment 3 Mike Gilbert gentoo-dev 2014-09-09 18:42:06 UTC
Your config file for 2.00 is pretty broken too; part_gpt should not show up 4 times.

Also I am unable to reproduce this with 2.02_beta2. I get the following output in my config file.

### BEGIN /etc/grub.d/00_header ###
insmod lvm
insmod diskfilter
insmod raid5rec
insmod mdraid1x
insmod part_gpt
insmod ext2
Comment 4 Coacher 2014-09-09 18:46:04 UTC
(In reply to Mike Gilbert from comment #3)
> Your config file for 2.00 is pretty broken too; part_gpt should not show up
> 4 times.

Indeed. At least it insmod's proper module.
 
> Also I am unable to reproduce this with 2.02_beta2. I get the following
> output in my config file.
> 
> ### BEGIN /etc/grub.d/00_header ###
> insmod lvm
> insmod diskfilter
> insmod raid5rec
> insmod mdraid1x
> insmod part_gpt
> insmod ext2

Can you please share you /etc/default/grub file?
Comment 5 Mike Gilbert gentoo-dev 2014-09-09 18:50:51 UTC
Created attachment 384472 [details]
floppym's /etc/default/grub

Here you go.
Comment 6 Coacher 2014-09-09 18:52:43 UTC
(In reply to Coacher from comment #4)
> (In reply to Mike Gilbert from comment #3)
> > Your config file for 2.00 is pretty broken too; part_gpt should not show up
> > 4 times.
> 
> Indeed. At least it insmod's proper module.
>  
> > Also I am unable to reproduce this with 2.02_beta2. I get the following
> > output in my config file.
> > 
> > ### BEGIN /etc/grub.d/00_header ###
> > insmod lvm
> > insmod diskfilter
> > insmod raid5rec
> > insmod mdraid1x
> > insmod part_gpt
> > insmod ext2
> 
> Can you please share you /etc/default/grub file?

*insmods
*your
Comment 7 Coacher 2014-09-09 20:47:27 UTC
(In reply to Mike Gilbert from comment #5)
> Created attachment 384472 [details]
> floppym's /etc/default/grub
> 
> Here you go.

Ok. Here is what I've found so far.


1. Trailing space in files/grub.default-3 on line 10. Please kill it.

2. Trailing space after part_gpt in boot sections of grub.cfg is due to prepare_grub_to_access_device() function, which can be found in /usr/share/grub/grub-mkconfig_lib. More specifically, this part is in charge of part_gpt inserted before every boot entry:
  old_ifs="$IFS"
  IFS='
'
  partmap="`"${grub_probe}" --device $@ --target=partmap`"
  for module in ${partmap} ; do
    case "${module}" in
      netbsd | openbsd)
        echo "insmod part_bsd";;
      *)
        echo "insmod part_${module}";;
    esac
  done

The problem is with grub2-probe, which returns "gpt " when called like this `grub2-probe --device /dev/sda1 --target=partmap` on my machine. This problem should be fixed in this commit: http://git.savannah.gnu.org/cgit/grub.git/commit/?id=24024dac7f51d3c0df8e1bec63c02d52828de534

3. Lots of "part_gpt"s with 2.00_p5107 and lots of "gpt "s after "part_gpt" with 2.02_beta2 is due to the fact that / is LVM on top of RAID5 with 4 drives and /boot is RAID1 across the same number of drives. grub just spits out 4 "gpt"s altogether because it cannot handle this setup properly.
For example, on this machine I have:
# grub2-probe --device /dev/md/boot --target=partmap
gpt gpt gpt gpt
Previously mentioned commit by the looks of it should hopefully fix it as well.

Stay tuned while I'll test this commit.
Comment 8 Coacher 2014-09-09 21:19:03 UTC
I can confirm that after applying patch from the said commit (+ a couple of extras) I no longer have problems 2 and partially 3. I still get four lines of "insmod part_gpt", but they at least work as opposed to "insmod part_gpt gpt gpt gpt". I guess grub is unaware of RAID setups such as mine.

Please add attached patches in tree.

Thanks.
Comment 9 Coacher 2014-09-09 21:22:11 UTC
Created attachment 384480 [details]
grub2-probe: fix -0 option

Had to rip out Changelog changes from patch otherwise it won't apply on top of beta2 tarball.
Comment 10 Coacher 2014-09-09 21:22:58 UTC
Created attachment 384482 [details, diff]
grub2-probe: trailing spaces fix

Had to rip out Changelog changes from patch otherwise it won't apply on top of beta2 tarball.
Comment 11 Coacher 2014-09-09 21:24:47 UTC
Created attachment 384484 [details, diff]
grub2-mkconfig: fix typo

Not really needed, but would be nice to add while you're adding previous two.

Had to rip out Changelog changes from patch otherwise it won't apply on top of beta2 tarball.
Comment 12 Mike Gilbert gentoo-dev 2014-09-09 21:26:29 UTC
So this has nothing to do with GRUB_PRELOAD_MODULES.

Good work finding those patches. Will apply asap.
Comment 13 Coacher 2014-09-09 21:40:44 UTC
(In reply to Mike Gilbert from comment #12)
> So this has nothing to do with GRUB_PRELOAD_MODULES.

Yes.

> Good work finding those patches. Will apply asap.

Ok, thanks.
Comment 14 Coacher 2014-09-09 21:43:16 UTC
Created attachment 384486 [details, diff]
grub2-probe: fix -0 option

Restore original subject.
Comment 15 Coacher 2014-09-09 21:44:34 UTC
Created attachment 384488 [details, diff]
grub2-probe: trailing spaces fix

Restore original subject.
Comment 16 Coacher 2014-09-09 21:45:34 UTC
Created attachment 384490 [details, diff]
grub2-mkconfig: fix typo

Restore original subject.
Comment 17 Mike Gilbert gentoo-dev 2014-09-09 22:00:32 UTC
Commited as grub-2.02_beta2-r1. Can you please give it a quick test?

+*grub-2.02_beta2-r1 (09 Sep 2014)
+
+  09 Sep 2014; Mike Gilbert <floppym@gentoo.org> +files/2.02_beta2/0001-Makefile
+  .util.def-Link-grub-ofpathname-with-zfs-libs.patch, +files/2.02_beta2/0002-gru
+  b-install-support-for-partitioned-partx-loop-devi.patch,
+  +files/2.02_beta2/0003-Fix-grub-probe-0-option.patch, +files/2.02_beta2/0004-F
+  ix-partmap-cryptodisk-and-abstraction-handling-in-g.patch,
+  +files/2.02_beta2/0005-Fix-typo-gettext_print-instead-of-gettext_printf.patch,
+  +grub-2.02_beta2-r1.ebuild:
+  Backport several patches to resolve issues with grub-probe and grub-mkconfig.
+  Bug 522428, thanks to Coacher.
+
Comment 18 Coacher 2014-09-10 13:33:49 UTC
(In reply to Mike Gilbert from comment #17)
> Commited as grub-2.02_beta2-r1. Can you please give it a quick test?

I cannot reproduce problems described above with 2.02-beta2-r1, thanks.

Can you please also remove trailing space on line 10 in files/grub.default-3 file? It is pointless to have it, though it doesn't affect functionality.

By looking at log of git commits in grub repo I've spotted several of them that might be usefult to add as patches as well. Here they are:
http://git.savannah.gnu.org/cgit/grub.git/commit/?id=0901e7855f922e770cbfeb58262cb8fded518190

http://git.savannah.gnu.org/cgit/grub.git/commit/?id=d99d2f84166b0f60673d5c0714605a153946c0fc

http://git.savannah.gnu.org/cgit/grub.git/commit/?id=c4badfe8363cc41dbedfabaa238b6c8a884e03c8
Comment 19 Mike Gilbert gentoo-dev 2014-09-10 20:59:07 UTC
+*grub-2.02_beta2-r2 (10 Sep 2014)
+
+  10 Sep 2014; Mike Gilbert <floppym@gentoo.org>
+  +files/2.02_beta2/0006-change-stop-condition-to-avoid-infinite-loops.patch,
+  +files/2.02_beta2/0007-Improve-LVM-logical_volumes-string-matching.patch,
+  +files/2.02_beta2/0008-Fix-an-infinite-loop-in-grub-mkconfig.patch,
+  +files/2.02_beta2/0009-Fix-incorrect-address-reference-in-btrfs.patch,
+  +grub-2.02_beta2-r2.ebuild, -grub-2.02_beta2-r1.ebuild:
+  More backports, bug 522428.
Comment 20 Coacher 2014-09-10 21:04:27 UTC
(In reply to Mike Gilbert from comment #19)
> +*grub-2.02_beta2-r2 (10 Sep 2014)
> +
> +  10 Sep 2014; Mike Gilbert <floppym@gentoo.org>
> + 
> +files/2.02_beta2/0006-change-stop-condition-to-avoid-infinite-loops.patch,
> +  +files/2.02_beta2/0007-Improve-LVM-logical_volumes-string-matching.patch,
> +  +files/2.02_beta2/0008-Fix-an-infinite-loop-in-grub-mkconfig.patch,
> +  +files/2.02_beta2/0009-Fix-incorrect-address-reference-in-btrfs.patch,
> +  +grub-2.02_beta2-r2.ebuild, -grub-2.02_beta2-r1.ebuild:
> +  More backports, bug 522428.

Thanks a lot!