Bug 805310 - Corrupted grub2.cfg content: trailing { missing in menuentry lines
Corrupted grub2.cfg content: trailing { missing in menuentry lines
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: grubby (Show other bugs)
17
Unspecified Unspecified
unspecified Severity urgent
: ---
: ---
Assigned To: Peter Jones
Fedora Extras Quality Assurance
AcceptedNTH RejectedBlocker
:
Depends On:
Blocks: F17Beta-accepted/F17BetaFreezeExcept
  Show dependency treegraph
 
Reported: 2012-03-20 16:37 EDT by Stefan Becker
Modified: 2012-03-23 13:43 EDT (History)
10 users (show)

See Also:
Fixed In Version: grubby-8.11-1.fc17
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-03-23 13:43:54 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
grub2.cfg before running new-kernel-pkg (8.71 KB, text/plain)
2012-03-21 12:33 EDT, Stefan Becker
no flags Details
grub2.cfg after running new-kernel-pkg (8.71 KB, text/plain)
2012-03-21 12:35 EDT, Stefan Becker
no flags Details
after updating to kernel 3.3.0-1 (6.64 KB, text/plain)
2012-03-21 13:16 EDT, Brian Lane
no flags Details
grub2.cfg before munging by grubby (4.83 KB, text/plain)
2012-03-21 13:59 EDT, Adam Williamson
no flags Details
grub2.cfg after munging by grubby: using grubby 8.8-3 (5.64 KB, text/plain)
2012-03-21 14:00 EDT, Adam Williamson
no flags Details
grub2.cfg after munging by grubby: using grubby 8.10-1 (5.69 KB, text/plain)
2012-03-21 14:17 EDT, Adam Williamson
no flags Details
grub after removing kernel with yumex (35.89 KB, text/plain)
2012-03-21 14:36 EDT, Flóki Pálsson
no flags Details
grub after grub2-mkconfig -o /boot/grub2/grub.cfg (36.07 KB, text/plain)
2012-03-21 14:37 EDT, Flóki Pálsson
no flags Details
grub2.cfg after munging by grubby: using grubby 8.11-1 (5.69 KB, text/plain)
2012-03-21 15:35 EDT, Adam Williamson
no flags Details
grub2.cfg after removing the initial kernel, using grubby 8.11-1 (2.96 KB, text/plain)
2012-03-21 15:37 EDT, Adam Williamson
no flags Details

  None (edit)
Description Stefan Becker 2012-03-20 16:37:27 EDT
Description of problem:

After the first installation and the first kernel update I ended up with a non-bootable system, because /boot/grub2/grub.cfg was corrupted. Closer inspection revealed that grubby forgets the trailing '{' add each newly generated menuentry line.

Version-Release number of selected component (if applicable):
grubby-8.10-1.fc17.x86_64
grub2-1.99-19.fc17.x86_64

How reproducible: always


Steps to Reproduce:
1. update kernel package
2. inspect /boot/grub2/grub.cfg
3.
  
Actual results: trailing '{' missing in menuentry line. grub2 fails to parse the configuration file and stops, leading to an unbootable system.


Expected results: correctly updated /boot/grub2/grub.cfg


Additional info:
Comment 1 Stefan Becker 2012-03-21 01:55:49 EDT
suggested by adamw
Comment 2 Stefan Becker 2012-03-21 02:04:45 EDT
BTW: after each kernel update I recompile the latest git HEAD for the nouveau/drm/ttm modules against it and update the initrd.img with

  /sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --update <new kernel version>

I copied this command straight out of kernel's posttrans scriptlet. Maybe the --update functionality is broken?
Comment 3 Adam Williamson 2012-03-21 12:06:12 EDT
Could you please, if possible, attach the grub2.cfg file as it existed before the bad update, and then as it existed after the bad update? (Or can anyone else who's hit this bug do the same)? Thanks.



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers
Comment 4 Stefan Becker 2012-03-21 12:33:40 EDT
Created attachment 571764 [details]
grub2.cfg before running new-kernel-pkg
Comment 5 Stefan Becker 2012-03-21 12:35:17 EDT
Created attachment 571766 [details]
grub2.cfg after running new-kernel-pkg

Executed command:

/sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --update 3.3.0-1.fc17.x86_64

i.e. I just refreshed the currently active kernel.
Comment 6 Chris Murphy 2012-03-21 12:42:00 EDT
I have a nearly identical grub.cfg after update with the inserted/modified menuentry lines lacking { at the end. GRUB stumbles through the cfg until it finds the first entry that is properly bracketed and executes, which happens to be the old kernel.
Comment 7 John Reiser 2012-03-21 12:54:45 EDT
This bug obviously is "just a typo" [or similar], but "defensive parsing" has been around for decades, and does not require excessive space.  In particular, the occurrence of keywords such as 'load_video' or 'insmod' (etc.) should terminate a 'menuentry'.
Comment 8 Brian Lane 2012-03-21 13:16:00 EDT
Created attachment 571778 [details]
after updating to kernel 3.3.0-1
Comment 9 Adam Williamson 2012-03-21 13:56:22 EDT
I think this is caused by the new fancy 'nested' layout grub2-mkconfig generates in the new grub2 (2.00-beta2).

I can't reproduce this on my desktop, which still has the old-style grub2.cfg since I haven't manually run grub2-mkconfig after the update, but can reproduce in a VM which was installed with the new grub2 and hence got the nested layout.

I'll attach my pre and post configs. grubby does, indeed, miss out the { that should terminate the 'menuentry' line, for the new entry.

I think we could maybe consider this a more general bug, though, that grubby ought to be doing something rather different for the new grub2.cfg layout. It should add a new entry to the 'Advanced options for Fedora Linux' submenu and *update* the 'Fedora Linux' entry to point to the new kernel, right?



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers
Comment 10 Adam Williamson 2012-03-21 13:59:46 EDT
Created attachment 571799 [details]
grub2.cfg before munging by grubby
Comment 11 Adam Williamson 2012-03-21 14:00:33 EDT
Created attachment 571800 [details]
grub2.cfg after munging by grubby: using grubby 8.8-3
Comment 12 Adam Williamson 2012-03-21 14:06:15 EDT
I just tested with grubby 8.10 from updates-testing. good news! it's even worse. it ditches rather more {s, breaking even more of the entries. Attaching that config.
Comment 13 Adam Williamson 2012-03-21 14:17:07 EDT
Created attachment 571804 [details]
grub2.cfg after munging by grubby: using grubby 8.10-1

Here's grub2.cfg after doing a kernel update with grubby 8.10-1 installed. it's somewhat worse than 8.8-3.
Comment 14 Flóki Pálsson 2012-03-21 14:34:50 EDT
This happs also if kernel is removed with yumex.
With grub2-mkconfig -o /boot/grub2/grub.cfg then it ok again.
See atthachments after removing kernel with yumex and after grub2-mkconfig.

Version-Release number of selected component (if applicable):
grub2-1.99-19.fc17.x86_64
grubby-8.10-1.fc17.x86_64
yumex-3.0.4-2.fc17.noarch
yum-3.4.3-18.fc17.noarch
Comment 15 Flóki Pálsson 2012-03-21 14:36:26 EDT
Created attachment 571810 [details]
grub after removing kernel with yumex

grub after removing kernel with yumex
Comment 16 Flóki Pálsson 2012-03-21 14:37:50 EDT
Created attachment 571811 [details]
grub after grub2-mkconfig -o /boot/grub2/grub.cfg

grub after grub2-mkconfig -o /boot/grub2/grub.cfg
Comment 17 Fedora Update System 2012-03-21 15:14:15 EDT
grubby-8.11-1.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/grubby-8.11-1.fc17
Comment 18 Adam Williamson 2012-03-21 15:33:44 EDT
So, I did some testing with 8.11.

Broadly, here's what happens.

The way I'm testing is to start from a base with kernel 3.3.0-1.fc17 installed, and an entirely clean grub2.cfg as produced directly from installation with just that kernel installed - installation was with grub2 1.99-19, so it has the 'nested' layout. This is the attachment listed as "grub2.cfg before munging by grubby" above. It contains a 'Fedora Linux' entry which doesn't do anything smart but is actually just a straight call to the 3.3.0-1 kernel and initramfs, and an 'Advanced options for Fedora Linux' submenu. This has one entry which is a straight listing for the 3.3.0-1 kernel, and one entry which is the same thing only in 'rescue mode'.

The first test I try is just to install a new kernel, 3.3.0-3.fc17. With 8.8 and 8.10, this results in a substantially messed up config file with several entries that fail to boot, as discussed so far and shown in my "grub2.cfg after munging by grubby: using grubby 8.8-3" and "grub2.cfg after munging by grubby: using grubby 8.10-1" attachments.

With 8.11-1, the result is a broadly valid grub2.cfg which boots 3.3.0-3.fc17 by default, so broadly, things are okay. It's clearly not exactly how upstream envisaged the menu looking, though. What you wind up with is a new entry for the 3.3.0-3.fc17 kernel *above* the 'Fedora Linux' and 'Advanced options for Fedora Linux' entries. These other entries are all untouched: they are exactly as described above. They all still boot 3.3.0-1.fc17. I will attach this grub2.cfg as "grub2.cfg after munging by grubby: using grubby 8.11-1".

I then tried a further step - I yum remove'd kernel 3.3.0-1.fc17. This actually behaved somewhat better than I was worried it would. The 'Fedora Linux' entry gets removed, as do each of the two entries in the 'Advanced options for Fedora Linux' submenu. That submenu still 'exists' as a kind of stub in the config file, but it's apparently not a 'valid' stub, as it doesn't get shown at all in the actual menu presented to the user on bootup. What you actually see when booting is, quite simply, a single entry for 3.3.0-3.fc17.

So in the end, the behaviour - though ever so slightly 'skewiff' - is broadly within the parameters we want, so far as I've tested. After installing a new kernel you get the new kernel by default, but you can still boot the old ones (though the menu entry names don't really *indicate* this). After removing the old kernel, all entries that point to it are removed. I'm just slightly worried that there may be other consequences to this slight 'culture clash' between how grub2-mkconfig operates and how grubby operates which don't show up in this fairly simple test but may show up in more complex configurations.
Comment 19 Adam Williamson 2012-03-21 15:35:10 EDT
Created attachment 571822 [details]
grub2.cfg after munging by grubby: using grubby 8.11-1

This is what you get on the first additional kernel install with grubby 8.11-1.
Comment 20 Adam Williamson 2012-03-21 15:37:08 EDT
Created attachment 571823 [details]
grub2.cfg after removing the initial kernel, using grubby 8.11-1

This is the grub2.cfg you get if you start at "grub2.cfg after munging by grubby: using grubby 8.11-1" and do 'yum remove kernel-3.3.0-1.fc17.x86_64'. It's slightly whacky, but it works.
Comment 21 Adam Williamson 2012-03-21 15:39:26 EDT
I vote +1 NTH, -1 blocker on this, now its consequences are well understood: it messes up post-install kernel updates, and taking it as a post-beta update isn't totally ideal, but it's actually unlikely to ever leave the system completely unbootable so I don't think it's strictly a blocker. But we should definitely take the fix.
Comment 22 Chris Murphy 2012-03-21 15:55:36 EDT
(In reply to comment #18)
> It's clearly not exactly how upstream
> envisaged the menu looking, though. What you wind up with is a new entry for
> the 3.3.0-3.fc17 kernel *above* the 'Fedora Linux' and 'Advanced options for
> Fedora Linux' entries.

Basically it's sneezing entries all over the grub menu. It's immediately messy and confusing. I don't like it. It's icky UI. 

If the GRUB menu were hidden by default, I'd feel better about the crusty mess appearing behind the scene, but anyone who stumbles on that menu before it gets cleaned up is going to have a bit of a WTF moment.

> I yum remove'd kernel 3.3.0-1.fc17. This actually
> behaved somewhat better than I was worried it would. The 'Fedora Linux' entry
> gets removed, as do each of the two entries in the 'Advanced options for Fedora
> Linux' submenu.

So only upon a, what, 3rd kernel being installed do we get an old kernel automatically removed and hence a clean up of the grub.cfg, which is still messier than how it started out upon a fresh install.

 *sigh* It's like helping a 3 year old blow their nose.
Comment 23 Adam Williamson 2012-03-21 16:08:57 EDT
chris: yeah, that's how I read it. after three kernel updates you'll wind up with a simple old-school menu that just lists kernels.



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers
Comment 24 Peter Jones 2012-03-21 17:53:34 EDT
If somebody wanted to write a patch that stores the line number of the "default" template and inserts the new menu entry at the same place, I'd be happy to review and test it.
Comment 25 Kevin Fenzi 2012-03-21 18:54:08 EDT
+1 NTH, -1 beta blocker.
Comment 26 Jared Smith 2012-03-21 19:06:04 EDT
+1 NTH, -1 blocker
Comment 27 Adam Williamson 2012-03-21 19:09:05 EDT
three matching votes, accepted as Beta NTH, rejected as blocker.



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers
Comment 28 Bruno Wolff III 2012-03-21 22:32:14 EDT
+1 NTH (hopefully before the first post freeze kernel update) -1 blocker
Comment 29 Adam Williamson 2012-03-21 23:58:55 EDT
bruno: 'hopefully' depends on it getting karma. ;)



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers
Comment 30 Stefan Becker 2012-03-22 12:40:32 EDT
see my comment on bodhi: my test case now works OK.
Comment 31 Fedora Update System 2012-03-23 13:43:54 EDT
grubby-8.11-1.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.