Empty grub.cfg?

I’m trying to get Grub2 to work at my full screen resolution and have therefore edited /etc/default/grub and then run grub2-mkconfig -o /boot/grub2/grub.cfg, without success. Trying to figure out what was going on, I peeked into /boot/grub2/grub.cfg and found it empty! Now before I go any further in pursuing my original goal, that seems an obvious stumbling block. YAST, interestingly enough, reads the new resolutions correctly (presumably from /etc/default/grub rather than grub.cfg, but saving the new configuration from YAST also makes no difference to the emptiness of grub.cfg.
Not sure if it’s significant, but I’ve also noticed that /boot has another /boot directory within, with the entire grub2 collection of files in that, and completely identical to the higher level (including the dates and the empty grub.cfg). Very puzzling.
What I have at the moment is the ugliest grub menu I’ve ever seen on a Linux computer, like a ZX81 projected onto my 1920x1200 monitor. Text mode looks much prettier!
(and before anyone points it out, yes, I need to amend my signature - I’m using a freshly installed 12.2 on my desktop…).

I presume you’re aware that you have to run this command as root. If you did and grub.cfg is still empty, run grub2-mkconfig without argument and watch the output. Are there error messages?

I have a bash script that is helpful in dealing with Grub 2 you can find here:

GNU Grub2 Command Help/Config Editor - Version: 1.82 - Blogs - openSUSE Forums

And for Fast Reboots have a look here:

FastBoot for Grub 2 or Grub Legacy Menu using Kexec - Version 2.13 - Blogs - openSUSE Forums

And to edit any system file outside of my scripts have a look here:

SYSEdit - System File Editor - Version 1.00 - Blogs - openSUSE Forums

Thank You,

Yes, of course I ran it as root, don’t think it would let me otherwise (always executed without error). No error messages when run without arguments either.

Don’t get mad, try out my bash script and see what you get. Here is what mine has. Added the nomodeset command for nVIDIA.

# Modified by YaST2. Last modification on Sun Sep 16 21:22:09 CDT 2012
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader

# If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' afterwards to update
# /boot/grub2/grub.cfg.
GRUB_DISTRIBUTOR=openSUSE
GRUB_DEFAULT=saved
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=8
GRUB_CMDLINE_LINUX_DEFAULT=" video=1920x1200 resume=/dev/disk/by-id/ata-Corsair_Performance3_SSD_1117810101000341020B-part1 splash=silent quiet nomodeset showopts"
# kernel command line options for failsafe mode
GRUB_CMDLINE_LINUX_RECOVERY="showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=gfxterm
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=auto
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY=true
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
GRUB_THEME=/boot/grub2/themes/openSUSE/theme.txt
GRUB_BACKGROUND=/boot/grub2/themes/openSUSE/background.png

If Grub2Cmd shows it is blank, just use my copy from above, removing the nomodeset command from “GRUB_CMDLINE_LINUX_DEFAULT”

Thank You,

And so what do you see? It should just print the text that it would save in /boot/grub2/grub.cfg if you would run:

# grub2-mkconfig -o /boot/grub2/grub.cfg

And notice that you could write this ouput anywhere, for example:

# grub2-mkconfig -o /tmp/grub.cfg

which does the same as

# grub2-mkconfig 2>/dev/null > /tmp/grub.cfg

Another option is updategrub (from my repo) which does the same as the first grub2-mkconfig above.

# updategrub

But if grub2-mkconfig doesn’t work, updategrub is not going to work either.

OK, humble apologies! Thanks to James’ neat script, which immediately showed the contents of grub.cfg, I soon figured out that the user does not have read permissions for that file - as I didn’t intend to edit it, I thought I could just peek without being root: my bad (all the system files I’ve ever had to deal with only needed root for editing but not for reading, such as fstab and others).
I’ll start another thread for the original problem: getting grub2 to come up with anything other than an ugly mess in graphical mode…

Run “sh -x /usr/sbin/grub2-mkconfig” and post full output.

Hi James,
my /etc/default/grub looks pretty much the same as yours, except that I’ve specified the resolution under GRUB_GFXMODE rather than in the menu entry. Here it is, in case you spot something that’s eluded me:

# Modified by YaST2. Last modification on Sun Sep 23 21:57:45 EST 2012
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader
# If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' afterwards to update
# /boot/grub2/grub.cfg.
GRUB_DISTRIBUTOR="openSUSE 12.2"
GRUB_DEFAULT=saved
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_CMDLINE_LINUX_DEFAULT=" resume=/dev/disk/by-id/ata-ST31000528AS_9VP23T38-part1 splash=silent quiet showopts"
# kernel command line options for failsafe mode
GRUB_CMDLINE_LINUX_RECOVERY="showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM=0x01234567,0xfefefefe,0x89abcdef,0xefefefef
# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=gfxterm
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=1920x1200
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY=true
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
GRUB_BACKGROUND=/boot/grub2/themes/openSUSE/background.png
GRUB_THEME=/boot/grub2/themes/openSUSE/theme.txt

If you have this in grub.cfg, something is really screwed up. It is content of /etc/default grub, not /boot/grub2/grub.cfg.

Already edited in the post: it’s late night here in Oz…

Way back when I installed openSUSE 12.2 rc1 using zypper dup, I got a blank /boot/grub2/grub.cfg file due to the fact I got switched some how back to using Grub Legacy. I had to reinstall Grub 2 though now I know I might have been able to do the same thing from the YaST boot Loader module, which I did not know about at the time. This grub 2 boot menu file should get filled with your menu when you run this command:

grub2-mkconfig -o /boot/grub2/grub.cfg

As stated in a previous message here and it could only be blank if you are not really using Grub 2 and further, even if the file was blank after an install, the same above command would recreate it and it would not matter if you had blanked it yourself before running this same command. Its the reason why editing this file will be undone on the next Grub 2 update anytime a new kernel version gets installed.

Thank You,

Thanks James, but see message 7 in this thread: it never was blank, it’s just that I couldn’t read it as an ordinary user…

Sorry to miss that fact. You indeed must be root to edit this file. According to my safp (S.A.F.P. - SUSE Automated File Permissions - Version 1.0.4 - Blogs - openSUSE Forums) bash script, this is what you get…

-rw------- (600) 1 root root 9045 Sep 21 17:20 /boot/grub2/grub.cfg

You can use my Grub2Cmd (GNU Grub2 Command Help/Config Editor - Version: 1.82 - Blogs - openSUSE Forums) Bash script to edit this file and a whole lot more.

Thank You,