Red Hat Bugzilla – Bug 647976
Augeas does not support GRUB 2 configuration (as used by Ubuntu etc)
Last modified: 2013-04-30 19:42:20 EDT
Created attachment 456606 [details]
GRUB 2 /boot/grub/grub.cfg from Ubuntu 10.10
Description of problem:
There is no way to parse the GRUB 2 configuration used in
operating systems like Ubuntu. Augeas lists nothing under
//files/boot and nothing relevant under //files/etc.
The GRUB 2 configuration format is slightly crazy though.
I have attached one from Ubuntu 10.10.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Run augtool on Ubuntu 10.10.
2. Look for configuration in //files/boot and //files/etc
No configuration found.
We really should be able to parse GRUB 2 configuration,
particularly for virtualization.
Sigh; when will people learn that a script is a horrible config file ?
I am not even sure how what's in the file would be presented in the tree; maybe look for the 'menuentry' stanzas ? I'd suspect that they can contain random scripts, too, though.
What would make a useful tree for your purposes ?
I'm trying to remember what I needed to parse grub configuration
for. I think it was so I could find out which kernel is installed
/ booted. In fact we removed that capability when we rewrote
I think we can leave this one for now.
I will welcome a list of linux kernels in menu (menuentry) and associated arguments.
Especially changing arguments. However if the grub2 is using scripting, it's...
For anybody coming to this, this file is generated automatically. It comes with a warning at the top not to edit the file, as it is automatically generated. Its format is undocumented as far as I can determine, but appears to contain a mixture of scripting features and directives. The only reliable way to write a parser for it will be to RTFS, and then we may want to be selective about which parts we parse.
From what I can determine from a brief look, the most interesting user-editable configuration is in /etc/default/grub, which is a shellvars format file. Menu entries for individual kernels are generated by globbing /boot for linux kernels, and using the values from /etc/default/grub. There doesn't appear to be a sane way to add or remove an individual kernel.
That means that Roman's list of linux kernels is best determined by an equivalent glob (i.e. not by augeas). Kernel arguments are best read from /etc/default/grub. However, to get functionality equivalent to the grub lens, we'll want to explicitly parse GRUB_CMDLINE_LINUX.
But seriously, a set of scripts which generate another script, which is the actual config? That's up there with the simplicity of sendmail. You might as well just provide the user with a C compiler and call the program their custom config (Wait... UW IMAP actually did that. Stop! That wasn't a serious suggestion!).
This increase in theoretical flexibility has lead to a decrease in practical flexibility. We might do better long term to fix grub2 instead.
Closing as can't fix; grub2 config appears to be completely uneditable