Grub2 and framebuffer

Linux Kernel, Network, and Services configuration.
Message
Author
User avatar
stoffepojken
Posts: 707
Joined: 2007-01-25 01:21
Location: Stockholm, Sweden

Grub2 and framebuffer

#1 Post by stoffepojken »

Hi

I cant get my framebuffer to work in the console with grub2. The framebuffer work with the grub boot screen but as son as the boot process start it no longer work. I have changed the values in /etc/default/grub and runned update-grub. I am running Sid fully updated. Any ideas?

/etc/default/grub:

Code: Select all

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet vga=0x0365"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# 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=1440x900@32

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
/boot/grub/grub.cfg:

Code: Select all

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
set root=(hd0,2)
search --no-floppy --fs-uuid --set 8536ee88-26ed-409d-9dff-e0d74c26e47a
if loadfont /usr/share/grub/ascii.pf2 ; then
  set gfxmode=1440x900@32
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, Linux 2.6.30-1-amd64" {
        set root=(hd0,2)
        search --no-floppy --fs-uuid --set 8536ee88-26ed-409d-9dff-e0d74c26e47a
        linux   /boot/vmlinuz-2.6.30-1-amd64 root=UUID=8536ee88-26ed-409d-9dff-e0d74c26e47a ro  quiet vga=0x0365
        initrd  /boot/initrd.img-2.6.30-1-amd64
}
menuentry "Debian GNU/Linux, Linux 2.6.30-1-amd64 (recovery mode)" {
        set root=(hd0,2)
        search --no-floppy --fs-uuid --set 8536ee88-26ed-409d-9dff-e0d74c26e47a
        linux   /boot/vmlinuz-2.6.30-1-amd64 root=UUID=8536ee88-26ed-409d-9dff-e0d74c26e47a ro single 
        initrd  /boot/initrd.img-2.6.30-1-amd64
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file is an example on how to add custom entries
### END /etc/grub.d/40_custom ###

toto
Posts: 16
Joined: 2007-07-25 01:06

Re: Grub2 and framebuffer

#2 Post by toto »

Hi,

At the moment there's no configuration support for gfxpayload in /etc/default/grub. See Debians bugreport: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=536453.

But you can edit /boot/grub/grub.cfg directly.

Code: Select all

set gfxpayload=1440x900x32
Add the above line below 'set gfxmode=1440x900x32' in your /boot/grub/grub.cfg, here's mine:

Code: Select all

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
set root=(hd0,1)
search --no-floppy --fs-uuid --set 43061a27-132b-46e8-ae0a-702cd6c2f3e2
if loadfont /usr/share/grub/ascii.pf2 ; then
  set gfxmode=640x480
  set gfxpayload=1024x768x16
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, Linux 2.6.30-1-686" {
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 43061a27-132b-46e8-ae0a-702cd6c2f3e2
	linux	/boot/vmlinuz-2.6.30-1-686 root=UUID=43061a27-132b-46e8-ae0a-702cd6c2f3e2 ro  quiet
	initrd	/boot/initrd.img-2.6.30-1-686
}
menuentry "Debian GNU/Linux, Linux 2.6.30-1-686 (recovery mode)" {
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 43061a27-132b-46e8-ae0a-702cd6c2f3e2
	linux	/boot/vmlinuz-2.6.30-1-686 root=UUID=43061a27-132b-46e8-ae0a-702cd6c2f3e2 ro single 
	initrd	/boot/initrd.img-2.6.30-1-686
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file is an example on how to add custom entries
### END /etc/grub.d/40_custom ###
The only drawback is that everytime you update grub or run update-grub these settings are overwritten.
BTW 'vga=' still works but it gives a little warning about it being deprecated and that you should use gfxpayload instead.

User avatar
stoffepojken
Posts: 707
Joined: 2007-01-25 01:21
Location: Stockholm, Sweden

Re: Grub2 and framebuffer

#3 Post by stoffepojken »

Thank you very much toto!

It works. Now my console is usable again :D

User avatar
m_l
Posts: 58
Joined: 2008-04-27 11:28

Re: Grub2 and framebuffer

#4 Post by m_l »

Code: Select all

set gfxpayload=1024x768x16
Worked for me also. Thank You :)

User avatar
jheaton5
Posts: 1488
Joined: 2008-08-20 01:40
Location: Newnan, GA, USA

Re: Grub2 and framebuffer

#5 Post by jheaton5 »

It worked for me too. But I would like to know how to add it with the grub-mkconfig series of files. /etc/default/grub sets gfxmode, but I can't find a file that sets gfxpayload. It has to be something simple. I have read that modifying /etc/grub.d/00_header will do the trick, but I don't know enough about bash scripting for the edit to be apparent. It would be nice if anyone who does bash scripting could help us out.
debian sid

User avatar
bugsbunny
Posts: 5355
Joined: 2008-07-06 17:04
Been thanked: 1 time

Re: Grub2 and framebuffer

#6 Post by bugsbunny »

It is simple :)
Simply modify /etc/grub.d/00_header as follows:
On approximately line 77 you should see:

Code: Select all

if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
  set gfxmode=${GRUB_GFXMODE}
  insmod gfxterm
Insert one line as follows:

Code: Select all

if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
  set gfxmode=${GRUB_GFXMODE}
  set gfxpayload=keep
  insmod gfxterm
That will cause the console size to be the same as the grub screen size. The grub screen size is obtained from GRUB_GFXMODE, which is set in /etc/default/grub.

Code: Select all

GRUB_GFXMODE=1600x1200x32
works here. You do, of course, have to run update-grub.

Taking this a step further if you want to set your own background for the grub boot screen:
Modify 05_debian_theme. The line to modify is (approx) line 16. Mine currently looks as follows:

Code: Select all

  for i in {/boot/grub,/boot/grub2-background}/serenity.{png,tga,jpg,jpeg} ; do
This will search /boot/grub and /boot/grub2-background (a directory I created) for a file called serenity with an extension of png, tga, jpg, or jpeg If found this image will be used as the grub background image.

I had to stick the image directory onto the boot device due to the fact that lvm isn't active at that point yet, so anything else isn't yet available (on my system) (remember this is before you even select a system to boot). I think that you can somehow configure grub to boot off an lvm drive, but I haven't gotten that far yet :)

User avatar
jheaton5
Posts: 1488
Joined: 2008-08-20 01:40
Location: Newnan, GA, USA

Re: Grub2 and framebuffer

#7 Post by jheaton5 »

I have GFXMODE set to 640x480 which gives me a full screen menu. I wanted GFXPAYLOAD set to 1440x900 so using your solution I changed GFXPAYLOAD=keep to GFXPAYLOAD=1440x900x32 in /etc/grub.d/00_header. Then I ran update-grub and the /boot/grub/grub.cfg was changed to

Code: Select all

if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  set gfxpayload=1440x900x32
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
Success!
Thanks bugsbunny
debian sid

User avatar
Modo
Posts: 2
Joined: 2009-10-22 21:27
Location: Mainz, Germany

Re: Grub2 and framebuffer

#8 Post by Modo »

Unfortunately I had no success with that method. grub.cfg - header looks now like this:

Code: Select all

### BEGIN /etc/grub.d/00_header ###
set default=0
insmod ext2
set root=(hd0,2)
search --no-floppy --fs-uuid --set d3b9e534-2907-4ae2-a390-d1761066dcc0
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  set gfxpayload=1400x1050x16
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
set timeout=5
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
insmod ext2
set root=(hd0,2)
search --no-floppy --fs-uuid --set d3b9e534-2907-4ae2-a390-d1761066dcc0
insmod png
if background_image /boot/grub/moreblue-orbit-grub.png ; then
  set color_normal=black/black
  set color_highlight=magenta/black
else
  set menu_color_normal=cyan/blue
  set menu_color_highlight=white/blue
fi
### END /etc/grub.d/05_debian_theme ###
....
but my grub still has a resolution of 640x480 and no background-image. And the same resolution on the console. I use Squeeze with some apt-pinning packes from Sid.

Thank you

Christian

Smjert
Posts: 8
Joined: 2009-11-04 00:39

Re: Grub2 and framebuffer

#9 Post by Smjert »

Now i didn't tried what you did, but i have a previous issue: where GRUB_FONT_PATH is taken?

Since my grub.cfg header it's:

Code: Select all

### BEGIN /etc/grub.d/00_header ###
set default=0
insmod ext2
set root=(hd0,6)
search --no-floppy --fs-uuid --set 1cea2dc6-e7b9-42b9-9d6c-cccf38ebceaa
if loadfont /share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
set timeout=5
### END /etc/grub.d/00_header ###
As you can see the path is wrong, but when i fix it directly in the grub.cfg, adding /usr, then at the reboot it don't uses anymore the png but it switch the theme to the old grub!?!?
I think that this issue is to be fixed first since otherwise the bash will never read what's inside that if..

Smjert
Posts: 8
Joined: 2009-11-04 00:39

Re: Grub2 and framebuffer

#10 Post by Smjert »

Well i have recompiled a custom version of the debian kernel and now it shows the right resolution even with the older kernels.
The only problem is that at the start the res and the fonts is ok.. but then it runs a console script that says "Setting up console fonts" or something like that and the font type change.. how to avoid this?

josephg
Posts: 82
Joined: 2009-01-03 14:01
Location: surrey england

Re: Grub2 and framebuffer

#11 Post by josephg »

Not working for me either! I get the frame buffer with a nice font at the grub boot screen, but the boot process starts with the ugly screen/font. What am I missing?

I am running debian stable with a stock kernel from the repository

Code: Select all

$ uname -srv
Linux 2.6.26-2-686 #1 SMP Wed Nov 4 20:45:37 UTC 2009
My grub.cfg contains

Code: Select all

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=2
set timeout=5
set root=(hd0,2)
search --fs-uuid --set b131478c-f3db-4e03-9bfe-9c94ca72bb78
if font /usr/share/grub/ascii.pff ; then
  set gfxmode=640x480
  set gfxpayload=800x600x16
  insmod gfxterm
  insmod vbe
  terminal gfxterm
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
#set menu_color_normal=cyan/blue
#set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_hurd ###
### END /etc/grub.d/10_hurd ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, linux 2.6.26-2-686" {
        set root=(hd0,2)
        search --fs-uuid --set b131478c-f3db-4e03-9bfe-9c94ca72bb78
        linux   /boot/vmlinuz-2.6.26-2-686 root=/dev/hda2 ro
        initrd  /boot/initrd.img-2.6.26-2-686
}
menuentry "Debian GNU/Linux, linux 2.6.26-2-686 (single-user mode)" {
        set root=(hd0,2)
        search --fs-uuid --set b131478c-f3db-4e03-9bfe-9c94ca72bb78
        linux   /boot/vmlinuz-2.6.26-2-686 root=/dev/hda2 ro single
        initrd  /boot/initrd.img-2.6.26-2-686
}
### END /etc/grub.d/10_linux ###

User avatar
Modo
Posts: 2
Joined: 2009-10-22 21:27
Location: Mainz, Germany

Re: Grub2 and framebuffer

#12 Post by Modo »

@Smjert: at my grub.cfg the font-path is complete:

Code: Select all

if loadfont /usr/share/grub/unicode.pf2 ; then
so this doesn't cause any problems. Do you have a "prefix=/usr"-line in your /etc/grub.d/00_header? I think this is responsible for prober path?

ColdStar
Posts: 1
Joined: 2009-11-29 20:53

Re: Grub2 and framebuffer

#13 Post by ColdStar »

It doesn't work for me. Im using ubuntu studio 9.10, grub version is GNU GRUB 1.97~beta4. When pressed Ctrl+Alt+F1, the console font is too small. I changed the /etc/grub.d/00_header and /etc/default/grub, then run update-grub. I checked the /boot/grub/grub.cfg, I got these two lines:

set gfxmode=640x480
set gfxpayload=800x600x16

The boot is right in 640x480 mode, but the console doesn't change. Is that sign between 640 and 480 is lower case of "X"? Or it just not work for ubuntu studio? What did I miss?

User avatar
jheaton5
Posts: 1488
Joined: 2008-08-20 01:40
Location: Newnan, GA, USA

Re: Grub2 and framebuffer

#14 Post by jheaton5 »

GFXPAYLOAD is supported by grub 1.97

Do not edit /boot/grub/grub.cfg.

In /etc/default/grub find the line:

Code: Select all

GRUB_GFXMODE=1440x900@32
underneath that line insert:

Code: Select all

GRUB_GFXPAYLOAD=1440x900x32
then in /etc/grub.d/00_header find the line:

Code: Select all

if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=1440x900x32 ; fi
then insert

Code: Select all

if [ "x${GRUB_GFXPAYLOAD}" = "x" ] ; then GRUB_GFXPAYLOAD=1440X900x32 ; fi
below it.
In the same file, but farther down the page, find the line:

Code: Select all

set gfxmode=${GRUB_GFXMODE}
insert below that line:

Code: Select all

set gfxpayload=${GRUB_GFXPAYLOAD}
Now run

Code: Select all

 # update-grub2
Substitute your own screen resolution for mine.
debian sid

User avatar
m_l
Posts: 58
Joined: 2008-04-27 11:28

Re: Grub2 and framebuffer

#15 Post by m_l »

Thank you for the update, bugsbunny and jheaton5.

User avatar
vortex7
Posts: 1
Joined: 2009-12-30 07:17
Location: Athens, Greece

Re: Grub2 and framebuffer

#16 Post by vortex7 »

In order not to have problems on upgrades, to set the console graphics mode,
I considered this as a customization and added the following lines at the end of
/etc/grub.d/40_custom

Code: Select all

# Set console mode (equivalent to kernel parameter vga=791)
  set gfxpayload=1024x768x16
and it works perfect [after an update_grub]

Other vga mode numbers mappings can be found in
http://en.wikipedia.org/wiki/VESA_BIOS_Extensions
under the "Linux video mode numbers" section.

My grub2 version is 1.98~20091229-1

Famelis George
Debian Sid ;-) with KDE 4

User avatar
dbbolton
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Grub2 and framebuffer

#17 Post by dbbolton »

jheaton5 wrote:GFXPAYLOAD is supported by grub 1.97

Do not edit /boot/grub/grub.cfg.

In /etc/default/grub find the line:

Code: Select all

GRUB_GFXMODE=1440x900@32
underneath that line insert:

Code: Select all

GRUB_GFXPAYLOAD=1440x900x32
then in /etc/grub.d/00_header find the line:

Code: Select all

if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=1440x900x32 ; fi
then insert

Code: Select all

if [ "x${GRUB_GFXPAYLOAD}" = "x" ] ; then GRUB_GFXPAYLOAD=1440X900x32 ; fi
below it.
In the same file, but farther down the page, find the line:

Code: Select all

set gfxmode=${GRUB_GFXMODE}
insert below that line:

Code: Select all

set gfxpayload=${GRUB_GFXPAYLOAD}
Now run

Code: Select all

 # update-grub2
Substitute your own screen resolution for mine.
Thanks for sharing this. It worked perfectly with my laptop, but not on my desktop, due to my own negligence:

Code: Select all

 grep -n GFX /etc/grub.d/00_header 
38:if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=1440x900x32 ; fi
39:if [ "x${GRUB_GFXPAYLOAD}" = "x" ] ; then GRUB_GFXPAYLOAD=1440X900x32 ; fi
81:  set gfxmode=${GRUB_GFXMODE}
82:  set gfxpayload=${GRUB_GFXPAYLOAD}
 
It took me a minute or two to spot it.
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

Jack450
Posts: 6
Joined: 2010-01-16 18:33

Re: Grub2 and framebuffer

#18 Post by Jack450 »

Can anyone help me with this problem too I've follow the steps to getting the Virtual Console to change resolution but I'm still getting the same low resolution. My grub changed to 1440x900 but not the Console when I press Ctrl+Alt+F2, does anyone know what I'm doing wrong?

User avatar
dbbolton
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Grub2 and framebuffer

#19 Post by dbbolton »

Jack450 wrote:Can anyone help me with this problem too I've follow the steps to getting the Virtual Console to change resolution but I'm still getting the same low resolution. My grub changed to 1440x900 but not the Console when I press Ctrl+Alt+F2, does anyone know what I'm doing wrong?
Look for errors like I did

Code: Select all

grep -n GFX /etc/default/grub

grep -n GFX /etc/grub.d/00_header
You should see something like

Code: Select all

16:GRUB_GFXMODE=1024x768x32
17:GRUB_GFXPAYLOAD=1024x768x32
and

Code: Select all

38:if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=1024x768x32 ; fi
39:if [ "x${GRUB_GFXPAYLOAD}" = "x" ] ; then GRUB_GFXPAYLOAD=1024x768x32 ; fi
81:  set gfxmode=${GRUB_GFXMODE}
82:  set gfxpayload=${GRUB_GFXPAYLOAD}
only "1440x900x32" in your case.
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

User avatar
Raffles10
Posts: 192
Joined: 2008-12-09 16:36
Location: London, UK

Re: Grub2 and framebuffer

#20 Post by Raffles10 »

Jack450 wrote:Can anyone help me with this problem too I've follow the steps to getting the Virtual Console to change resolution but I'm still getting the same low resolution. My grub changed to 1440x900 but not the Console when I press Ctrl+Alt+F2, does anyone know what I'm doing wrong?
All I had to do was:

edit: /etc/grub.d/00_header

From line 81 you need to add 'set gfxpayload=keep' to show:

if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
set gfxmode=${GRUB_GFXMODE}
set gfxpayload=keep
insmod gfxterm

Then edit: /etc/default/grub

# 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=1440x900x32

and then:

Code: Select all

$ sudo update-grub
Debian Squeeze + KDE 4.4.4 + AMD Athlon™ 64 X2 Dual Core Processor 6000 + nVidia GeForce 8600

Post Reply