OSDev.org https://forum.osdev.org/ |
|
A question about GRUB https://forum.osdev.org/viewtopic.php?f=13&t=31757 |
Page 1 of 1 |
Author: | teeuwen [ Fri May 05, 2017 9:34 am ] |
Post subject: | A question about GRUB |
Not specifically OS dev. related so I thought I'd just post it here. After compilation of my kernel has finished, the linked binary is copied to a root directory which in turn is written to an ISO image by genisoimage, pretty normal stuff. Instead of using grub-mkrescue however (which is recommended by the Wiki if I remember correctly and many of you probably also do it like this), I'm using grub-mkimage so that I can select which GRUB modules I want and the image doesn't immediately become 20 megabytes. The modules I have included are Code: i386-pc biosdisk boot iso9660 multiboot normal Works like a charm for booting from cdrom The thing is that comments in my grub.cfg file are interpreted instead of ignored, which results 3 (the amount of comments in the file) ugly warnings during boot: Code: Unknown command '#'. Unknown command '#'. Unknown command '#'. I've looked through a bunch of docs (and even tried to find it in the enormous GRUB2 source which is pretty much impossible) but I just can't seem to find what I'm missing. If anyone knows about a module or switch that resolves this, I'd love to hear it! |
Author: | dozniak [ Sat May 06, 2017 7:33 am ] |
Post subject: | Re: A question about GRUB |
Do these comments start on the start of the line? (Column 1) or somewhere after a few whitespaces? The grub2 docs mention that starting a line with # makes it a comment, but it warns if a command has been broken in the middle then parser will be upset. |
Author: | teeuwen [ Sat May 06, 2017 10:26 am ] |
Post subject: | Re: A question about GRUB |
dozniak wrote: Do these comments start on the start of the line? (Column 1) or somewhere after a few whitespaces? The grub2 docs mention that starting a line with # makes it a comment, but it warns if a command has been broken in the middle then parser will be upset. Nope, it contains exactly this: Code: # # /boot/grub/grub.cfg: configuration file for GRUB # multiboot /boot/kernel root=/sys/dev/hda0 rootfs=iso9660 console=/sys/dev/con0 boot Unix line endings, nothing out of the ordinary. And I should mention that this works just fine if I'm using grub-mkrescue, so it has nothing to do with syntax errors. Thanks for your reply though! |
Author: | dozniak [ Sat May 06, 2017 2:28 pm ] |
Post subject: | Re: A question about GRUB |
teeuwen wrote: Unix line endings, nothing out of the ordinary. And I should mention that this works just fine if I'm using grub-mkrescue, so it has nothing to do with syntax errors. Thanks for your reply though! Does mkrescue probably strip the comments from the cfg file before writing it to the image? I haven't looked into the grub code itself, but it may be worth doing just to see where exactly the `#` parsing and stripping takes place. |
Author: | teeuwen [ Sat May 06, 2017 3:19 pm ] |
Post subject: | Re: A question about GRUB |
dozniak wrote: teeuwen wrote: Unix line endings, nothing out of the ordinary. And I should mention that this works just fine if I'm using grub-mkrescue, so it has nothing to do with syntax errors. Thanks for your reply though! Does mkrescue probably strip the comments from the cfg file before writing it to the image? I haven't looked into the grub code itself, but it may be worth doing just to see where exactly the `#` parsing and stripping takes place. I have, like I mentioned before, and here's my findings: So after downloading the source I did a grep for '#', which gives about 2 dozen results. Note that all the relevant results are in the grub-core/ directory and utilities like grub-mkrescue and grub-mkimage are in utils/. This (probably) rules out the possibility that mkrescue strips out comments, because this is all handled by the "normal" module (which I did include) and I couldn't find any comment stripping code in the mkrescue source. The exact location where the comments are stripped is: grub-core/normal/main.c > grub_cmd_normal > grub_enter_normal_mode > grub_normal_executable > read_config_file > read_config_file_getline (on line 96 in the GRUB git repo). No arguments to any of the functions to ignore comments or anything like that. This just seems like a dead end to me. It may even be a bug. |
Author: | eryjus [ Sat May 06, 2017 3:25 pm ] |
Post subject: | Re: A question about GRUB |
It was a simple test for me... grub2-mkrescue did not strip comments. Just curious, is this grub or grub2? |
Author: | teeuwen [ Sat May 06, 2017 3:33 pm ] |
Post subject: | Re: A question about GRUB |
eryjus wrote: It was a simple test for me... grub2-mkrescue did not strip comments. Just curious, is this grub or grub2? GRUB2, 2.02~rc2 to be specific. But what do mean when you say that grub-mkrescue does NOT strip comments for you? Because it sure does for me. |
Author: | eryjus [ Sat May 06, 2017 3:39 pm ] |
Post subject: | Re: A question about GRUB |
teeuwen wrote: But what do mean when you say that grub-mkrescue does NOT strip comments for you? I added a comment into my grub.cfg and ran grub2-mkrescue. In fact: Code: grub2-mkrescue -o $@ $(I686-KERNEL-SYSROOT) 2> /dev/null the command line is rather simple. I opened the resulting .iso with ark and navigated to the grub.cfg therein and opened it. The comments were still there as I wrote them. I also checked that the image was bootable and I was able to boot both my MB and MB2 header from the resulting .iso. For the record: Code: [adam@os-dev century]$ grub2-mkrescue --version grub2-mkrescue (GRUB) 2.02~beta3 and I am running on FC25 and I am patch-current as of 7 days ago. |
Author: | teeuwen [ Sat May 06, 2017 3:58 pm ] |
Post subject: | Re: A question about GRUB |
eryjus wrote: teeuwen wrote: But what do mean when you say that grub-mkrescue does NOT strip comments for you? I added a comment into my grub.cfg and ran grub2-mkrescue. In fact: Code: grub2-mkrescue -o $@ $(I686-KERNEL-SYSROOT) 2> /dev/null the command line is rather simple. I opened the resulting .iso with ark and navigated to the grub.cfg therein and opened it. The comments were still there as I wrote them. I also checked that the image was bootable and I was able to boot both my MB and MB2 header from the resulting .iso. For the record: Code: [adam@os-dev century]$ grub2-mkrescue --version grub2-mkrescue (GRUB) 2.02~beta3 and I am running on FC25 and I am patch-current as of 7 days ago. I think you're missing the point here I'm afraid. Attachment: 2017-05-06-235603_3200x1080_scrot.png [ 7.25 KiB | Viewed 5422 times ] And grub-mkrescue is the one that is working just fine. The problem is with grub-mkimage. |
Author: | eryjus [ Sat May 06, 2017 5:07 pm ] |
Post subject: | Re: A question about GRUB |
teeuwen wrote: I think you're missing the point here I'm afraid. Perhaps I did. I thought one comment was that mkrescue was stripping comments in grub.cfg. I was going after that comment and I was not clear. Anyway, I'm more than happy to run a test for you here if you feel that would help. Just send me your command line. |
Author: | teeuwen [ Sun May 07, 2017 4:08 am ] |
Post subject: | Re: A question about GRUB |
I've filed a bug report: https://savannah.gnu.org/bugs/?50963 We'll see what happens now. EDIT: Got a reply: Quote: Embedded config is interpreted by rescue parser, not by normal.mod. It is intended for limited use cases and not for general purpose scripting. For some reason I don't quite believe the guy (even though he's a maintainer) as I've looked though the normal.mod code myself but I guess I'm gonna have to use grub-mkrescue or simply remove the comment after all. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |